mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-03 02:32:35 +01:00
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:
1 parent
01b3e4a71c
commit
4d04609bb8
2 files changed
+4
-31
No files matched your search
@@ -66,31 +66,6 @@ func (i *FileHandleToInode) AcquireFileHandle(wfs *WFS, inode uint64, entry *fil
|
|||||||
return fh
|
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 {
|
func (i *FileHandleToInode) ReleaseByHandle(fh FileHandleId) *FileHandle {
|
||||||
i.Lock()
|
i.Lock()
|
||||||
defer i.Unlock()
|
defer i.Unlock()
|
||||||
|
|||||||
@@ -63,13 +63,11 @@ Side effects: increments the lookup count on success
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
func (wfs *WFS) Forget(nodeid, nlookup uint64) {
|
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.inodeToPath.Forget(nodeid, nlookup, func(dir util.FullPath) {
|
||||||
wfs.metaCache.DeleteFolderChildren(context.Background(), dir)
|
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user