From 29a6d76f70db78953aaaf7633aba32551c9b0e40 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Mon, 14 Mar 2016 17:16:55 +0000 Subject: CA-203169: store successful writes Previously, we stored the value in the write-cache if the write was unsuccessful. Instead, store it if it was successful. --- xenstoreclient/xenstore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xenstoreclient') diff --git a/xenstoreclient/xenstore.go b/xenstoreclient/xenstore.go index 0d3e2bb..b6a5a86 100644 --- a/xenstoreclient/xenstore.go +++ b/xenstoreclient/xenstore.go @@ -374,7 +374,7 @@ func (xs *CachedXenStore) Write(path string, value string) error { } } err := xs.xs.Write(path, value) - if err != nil { + if err == nil { xs.writeCache[path] = value xs.lastCommit[path] = time.Now() } -- cgit v1.2.3 From 5c06998aee96aa02fddf1f6d3122ad1badbafd55 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Mon, 14 Mar 2016 17:17:05 +0000 Subject: CA-203169: remove write-cache expiry timeout There is no reason to expire cached writes. This lightens the load on xenstore. --- xenstoreclient/xenstore.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'xenstoreclient') diff --git a/xenstoreclient/xenstore.go b/xenstoreclient/xenstore.go index b6a5a86..fa5002c 100644 --- a/xenstoreclient/xenstore.go +++ b/xenstoreclient/xenstore.go @@ -11,7 +11,6 @@ import ( "strconv" "strings" "sync" - "time" ) type Permission int @@ -352,7 +351,6 @@ func (xs *XenStore) StopWatch() error { type CachedXenStore struct { xs XenStoreClient writeCache map[string]string - lastCommit map[string]time.Time } func NewCachedXenstore(tx uint32) (XenStoreClient, error) { @@ -363,20 +361,16 @@ func NewCachedXenstore(tx uint32) (XenStoreClient, error) { return &CachedXenStore{ xs: xs, writeCache: make(map[string]string, 0), - lastCommit: make(map[string]time.Time, 0), }, nil } func (xs *CachedXenStore) Write(path string, value string) error { if v, ok := xs.writeCache[path]; ok && v == value { - if t, ok := xs.lastCommit[path]; ok && t.After(time.Now().Add(-2*time.Minute)) { - return nil - } + return nil } err := xs.xs.Write(path, value) if err == nil { xs.writeCache[path] = value - xs.lastCommit[path] = time.Now() } return err } @@ -415,7 +409,6 @@ func (xs *CachedXenStore) StopWatch() error { func (xs *CachedXenStore) Clear() { xs.writeCache = make(map[string]string, 0) - xs.lastCommit = make(map[string]time.Time, 0) } func getDevPath() (devPath string, err error) { -- cgit v1.2.3