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
fix(mount): don't release file handles from FUSE Forget (#9529)
Chris Lu4d04609bb841
diff --git a/weed/mount/filehandle_map.go b/weed/mount/filehandle_map.goindex f8463f1bbe..8a81eb1fa1 100644--- a/weed/mount/filehandle_map.go+++ b/weed/mount/filehandle_map.go@@ -66,31 +66,6 @@ func (i *FileHandleToInode) AcquireFileHandle(wfs *WFS, inode uint64, entry *filreturn fh}-func (i *FileHandleToInode) ReleaseByInode(inode uint64) *FileHandle {- i.Lock()- defer i.Unlock()- fh, found := i.inode2fh[inode]- if !found {- return nil- }- // If the counter is already <= 0, a prior Release already started the- // drain. Return nil to prevent double-processing (e.g. Forget after Release).- if fh.counter <= 0 {- return nil- }- fh.counter--- if fh.counter <= 0 {- if fh.asyncFlushPending {- // Handle stays in fhMap so rename/unlink can find it during drain.- return fh- }- delete(i.inode2fh, inode)- delete(i.fh2inode, fh.fh)- return fh- }- return nil-}-func (i *FileHandleToInode) ReleaseByHandle(fh FileHandleId) *FileHandle {i.Lock()defer i.Unlock()diff --git a/weed/mount/weedfs_forget.go b/weed/mount/weedfs_forget.goindex 2502c39299..29fc84251f 100644--- a/weed/mount/weedfs_forget.go+++ b/weed/mount/weedfs_forget.go@@ -63,13 +63,11 @@ Side effects: increments the lookup count on success*/func (wfs *WFS) Forget(nodeid, nlookup uint64) {+ // Forget only decrements the kernel's inode lookup count. File handle+ // lifecycle is driven independently by FUSE Open/Release — touching the+ // fhMap here would couple two unrelated refcounts and could tear down a+ // still-live handle if Forget ever raced ahead of Release.wfs.inodeToPath.Forget(nodeid, nlookup, func(dir util.FullPath) {wfs.metaCache.DeleteFolderChildren(context.Background(), dir)})- // ReleaseByInode returns nil if the handle is already draining (counter- // was already <= 0 from a prior Release). Only non-async handles that- // reach counter 0 here need cleanup.- if fhToRelease := wfs.fhMap.ReleaseByInode(nodeid); fhToRelease != nil {- fhToRelease.ReleaseHandle()- }}