fix(mount): don't release file handles from FUSE Forget (#9529)

fix(mount): don't release file handles from Forget

Forget(nodeid, nlookup) only decrements the kernel inode lookup count.
File handle lifecycle belongs to FUSE Open/Release. Driving the FH
refcount from Forget coupled two unrelated counters and could tear down
a still-live handle if Forget ever raced ahead of Release.

Drop the ReleaseByInode call (and the now-unused method).
This commit is contained in:
Chris Lu
2026-05-18 01:02:58 -07:00
committed by GitHub
parent 01b3e4a71c
commit 4d04609bb8
2 changed files with 4 additions and 31 deletions

View File

@@ -66,31 +66,6 @@ func (i *FileHandleToInode) AcquireFileHandle(wfs *WFS, inode uint64, entry *fil
return 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()

View File

@@ -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()
}
}