mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-05 20:52:50 +08:00
refactor
This commit is contained in:
parent
cb33ee006e
commit
94bd8b39cf
@ -1,9 +1,10 @@
|
|||||||
package mount
|
package mount
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -67,22 +68,26 @@ func (i *FileHandleToInode) ReleaseByInode(inode uint64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *FileHandleToInode) ReleaseByHandle(fh FileHandleId) {
|
func (i *FileHandleToInode) ReleaseByHandle(fh FileHandleId) {
|
||||||
i.Lock()
|
i.Lock()
|
||||||
defer i.Unlock()
|
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
inode, found := i.fh2inode[fh]
|
||||||
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user