aboutsummaryrefslogtreecommitdiff
path: root/weed/mount
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-03-19 21:01:47 -0700
committerchrislu <chris.lu@gmail.com>2025-03-19 21:01:47 -0700
commit94bd8b39cf8bca8d2c1f2166c894006bcb270919 (patch)
treefca79c1d78c95ead6bd2d962d681267a5bb88445 /weed/mount
parentcb33ee006ea570dc770f0a8be4af2f6601fd170f (diff)
downloadseaweedfs-94bd8b39cf8bca8d2c1f2166c894006bcb270919.tar.xz
seaweedfs-94bd8b39cf8bca8d2c1f2166c894006bcb270919.zip
refactor
Diffstat (limited to 'weed/mount')
-rw-r--r--weed/mount/filehandle_map.go31
1 files changed, 18 insertions, 13 deletions
diff --git a/weed/mount/filehandle_map.go b/weed/mount/filehandle_map.go
index 852ef9e35..4441de0be 100644
--- a/weed/mount/filehandle_map.go
+++ b/weed/mount/filehandle_map.go
@@ -1,9 +1,10 @@
package mount
import (
- "github.com/seaweedfs/seaweedfs/weed/util"
"sync"
+ "github.com/seaweedfs/seaweedfs/weed/util"
+
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
)
@@ -67,22 +68,26 @@ func (i *FileHandleToInode) ReleaseByInode(inode uint64) {
}
}
}
+
func (i *FileHandleToInode) ReleaseByHandle(fh FileHandleId) {
i.Lock()
defer i.Unlock()
+
inode, found := i.fh2inode[fh]
- if found {
- fhHandle, fhFound := i.inode2fh[inode]
- if !fhFound {
- delete(i.fh2inode, fh)
- } else {
- fhHandle.counter--
- if fhHandle.counter <= 0 {
- delete(i.inode2fh, inode)
- delete(i.fh2inode, fhHandle.fh)
- fhHandle.ReleaseHandle()
- }
- }
+ if !found {
+ return // Handle already released or invalid
+ }
+
+ fhHandle, fhFound := i.inode2fh[inode]
+ if !fhFound {
+ delete(i.fh2inode, fh)
+ return
+ }
+ fhHandle.counter--
+ if fhHandle.counter <= 0 {
+ delete(i.inode2fh, inode)
+ delete(i.fh2inode, fhHandle.fh)
+ fhHandle.ReleaseHandle()
}
}