diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2020-10-26 22:01:50 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-26 22:01:50 +0800 |
| commit | 843865f2ca534bb6286b7a3d79c436384d875608 (patch) | |
| tree | 653943fe04caf3fe607416715fb341460a624ab7 /weed/filesys/wfs.go | |
| parent | cf7a1c722fa82fa78c546f68e4814fff7dc6d1e2 (diff) | |
| parent | 44921220b01d21c64755cbc7560ff8932f71984d (diff) | |
| download | seaweedfs-843865f2ca534bb6286b7a3d79c436384d875608.tar.xz seaweedfs-843865f2ca534bb6286b7a3d79c436384d875608.zip | |
Merge pull request #33 from chrislusf/master
sync
Diffstat (limited to 'weed/filesys/wfs.go')
| -rw-r--r-- | weed/filesys/wfs.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index 265fc95a8..759e21b15 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -92,7 +92,14 @@ func NewSeaweedFileSystem(option *Option) *WFS { wfs.chunkCache = chunk_cache.NewTieredChunkCache(256, cacheDir, option.CacheSizeMB, 1024*1024) } - wfs.metaCache = meta_cache.NewMetaCache(path.Join(cacheDir, "meta"), util.FullPath(option.FilerMountRootPath), option.UidGidMapper) + wfs.metaCache = meta_cache.NewMetaCache(path.Join(cacheDir, "meta"), util.FullPath(option.FilerMountRootPath), option.UidGidMapper, func(filePath util.FullPath) { + fsNode := wfs.fsNodeCache.GetFsNode(filePath) + if fsNode != nil { + if file, ok := fsNode.(*File); ok { + file.entry = nil + } + } + }) startTime := time.Now() go meta_cache.SubscribeMetaEvents(wfs.metaCache, wfs.signature, wfs, wfs.option.FilerMountRootPath, startTime.UnixNano()) grace.OnInterrupt(func() { @@ -119,10 +126,12 @@ func (wfs *WFS) AcquireHandle(file *File, uid, gid uint32) (fileHandle *FileHand defer wfs.handlesLock.Unlock() inodeId := file.fullpath().AsInode() - existingHandle, found := wfs.handles[inodeId] - if found && existingHandle != nil { - file.isOpen++ - return existingHandle + if file.isOpen > 0 { + existingHandle, found := wfs.handles[inodeId] + if found && existingHandle != nil { + file.isOpen++ + return existingHandle + } } fileHandle = newFileHandle(file, uid, gid) |
