Commit e09493f4 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Make DropAll take a []string argument to have selective cache drops.

parent 15487a16
...@@ -100,7 +100,7 @@ func NewCachingFileSystem(fs fuse.FileSystem, ttlNs int64) *CachingFileSystem { ...@@ -100,7 +100,7 @@ func NewCachingFileSystem(fs fuse.FileSystem, ttlNs int64) *CachingFileSystem {
func (me *CachingFileSystem) DropCache() { func (me *CachingFileSystem) DropCache() {
for _, c := range []*TimedCache{me.attributes, me.dirs, me.links, me.xattr} { for _, c := range []*TimedCache{me.attributes, me.dirs, me.links, me.xattr} {
c.DropAll() c.DropAll(nil)
} }
} }
......
...@@ -103,8 +103,15 @@ func (me *TimedCache) RecurringPurge() { ...@@ -103,8 +103,15 @@ func (me *TimedCache) RecurringPurge() {
func() { me.RecurringPurge() }) func() { me.RecurringPurge() })
} }
func (me *TimedCache) DropAll() { func (me *TimedCache) DropAll(names []string) {
me.cacheMapMutex.Lock() me.cacheMapMutex.Lock()
defer me.cacheMapMutex.Unlock() defer me.cacheMapMutex.Unlock()
if names == nil {
me.cacheMap = make(map[string]*cacheEntry, len(me.cacheMap)) me.cacheMap = make(map[string]*cacheEntry, len(me.cacheMap))
} else {
for _, nm := range names {
me.cacheMap[nm] = nil, false
}
}
} }
...@@ -716,10 +716,8 @@ func (me *UnionFs) Rename(src string, dst string) (code fuse.Status) { ...@@ -716,10 +716,8 @@ func (me *UnionFs) Rename(src string, dst string) (code fuse.Status) {
return code return code
} }
// TODO - a DropBranchCache which takes a list of names. func (me *UnionFs) DropBranchCache(names []string) {
me.branchCache.DropAll(names)
func (me *UnionFs) DropBranchCache() {
me.branchCache.DropAll()
} }
func (me *UnionFs) DropDeletionCache() { func (me *UnionFs) DropDeletionCache() {
...@@ -743,7 +741,7 @@ func (me *UnionFs) Open(name string, flags uint32) (fuseFile fuse.File, status f ...@@ -743,7 +741,7 @@ func (me *UnionFs) Open(name string, flags uint32) (fuseFile fuse.File, status f
if name == _DROP_CACHE { if name == _DROP_CACHE {
if flags&fuse.O_ANYWRITE != 0 { if flags&fuse.O_ANYWRITE != 0 {
log.Println("Forced cache drop on", me.Name()) log.Println("Forced cache drop on", me.Name())
me.DropBranchCache() me.DropBranchCache(nil)
me.DropDeletionCache() me.DropDeletionCache()
me.DropSubFsCaches() me.DropSubFsCaches()
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment