diff options
| author | byunghwa.yun <combine@combineads.co.kr> | 2021-08-11 22:58:35 +0900 |
|---|---|---|
| committer | byunghwa.yun <combine@combineads.co.kr> | 2021-08-11 23:14:56 +0900 |
| commit | 775dfbae85f1fb3c2bc38cc42c77fa35ecff3811 (patch) | |
| tree | 053c696153f6c01bd78cad3ba6e3fc81e669aece /weed | |
| parent | 5df38d610dc8ba2081088320e546f8a824d232cd (diff) | |
| download | seaweedfs-775dfbae85f1fb3c2bc38cc42c77fa35ecff3811.tar.xz seaweedfs-775dfbae85f1fb3c2bc38cc42c77fa35ecff3811.zip | |
Synchronize number of open files
Diffstat (limited to 'weed')
| -rw-r--r-- | weed/filesys/filehandle.go | 2 | ||||
| -rw-r--r-- | weed/filesys/wfs.go | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index 5cd7ca948..34affddb9 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -210,7 +210,9 @@ func (fh *FileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) err fh.Lock() defer fh.Unlock() + fh.f.wfs.handlesLock.Lock() fh.f.isOpen-- + fh.f.wfs.handlesLock.Unlock() if fh.f.isOpen <= 0 { fh.f.entry = nil diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index 0e0050964..84d4bdfa2 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -157,20 +157,21 @@ func (wfs *WFS) AcquireHandle(file *File, uid, gid uint32, writeOnly bool) (file wfs.handlesLock.Lock() existingHandle, found := wfs.handles[inodeId] - wfs.handlesLock.Unlock() - if found && existingHandle != nil { + if found && existingHandle != nil && existingHandle.f.isOpen > 0 { existingHandle.f.isOpen++ + wfs.handlesLock.Unlock() existingHandle.dirtyPages.SetWriteOnly(writeOnly) - glog.V(4).Infof("Acquired Handle %s open %d", fullpath, existingHandle.f.isOpen) + glog.V(4).Infof("Reuse AcquiredHandle %s open %d", fullpath, existingHandle.f.isOpen) return existingHandle } + wfs.handlesLock.Unlock() entry, _ := file.maybeLoadEntry(context.Background()) file.entry = entry fileHandle = newFileHandle(file, uid, gid, writeOnly) - file.isOpen++ wfs.handlesLock.Lock() + file.isOpen++ wfs.handles[inodeId] = fileHandle wfs.handlesLock.Unlock() fileHandle.handle = inodeId |
