SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
Synchronize number of open files
byunghwa.yun775dfbae85f1
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.goindex 5cd7ca948a..34affddb90 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) errfh.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 = nildiff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.goindex 0e00509648..84d4bdfa2f 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) (filewfs.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 = entryfileHandle = newFileHandle(file, uid, gid, writeOnly)- file.isOpen++wfs.handlesLock.Lock()+ file.isOpen++wfs.handles[inodeId] = fileHandlewfs.handlesLock.Unlock()fileHandle.handle = inodeId