mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-05 20:52:50 +08:00
simplify
This commit is contained in:
parent
57dc39c451
commit
e86b0bcaaa
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
type FileHandleToInode struct {
|
type FileHandleToInode struct {
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
nextFh FileHandleId
|
|
||||||
inode2fh map[uint64]*FileHandle
|
inode2fh map[uint64]*FileHandle
|
||||||
fh2inode map[FileHandleId]uint64
|
fh2inode map[FileHandleId]uint64
|
||||||
}
|
}
|
||||||
@ -18,7 +17,6 @@ func NewFileHandleToInode() *FileHandleToInode {
|
|||||||
return &FileHandleToInode{
|
return &FileHandleToInode{
|
||||||
inode2fh: make(map[uint64]*FileHandle),
|
inode2fh: make(map[uint64]*FileHandle),
|
||||||
fh2inode: make(map[FileHandleId]uint64),
|
fh2inode: make(map[FileHandleId]uint64),
|
||||||
nextFh: FileHandleId(util.RandomUint64()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,8 +42,7 @@ func (i *FileHandleToInode) AcquireFileHandle(wfs *WFS, inode uint64, entry *fil
|
|||||||
defer i.Unlock()
|
defer i.Unlock()
|
||||||
fh, found := i.inode2fh[inode]
|
fh, found := i.inode2fh[inode]
|
||||||
if !found {
|
if !found {
|
||||||
fh = newFileHandle(wfs, i.nextFh, inode, entry)
|
fh = newFileHandle(wfs, FileHandleId(util.RandomUint64()), inode, entry)
|
||||||
i.nextFh = FileHandleId(util.RandomUint64())
|
|
||||||
i.inode2fh[inode] = fh
|
i.inode2fh[inode] = fh
|
||||||
i.fh2inode[fh.fh] = inode
|
i.fh2inode[fh.fh] = inode
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,10 +44,7 @@ func NewDirectoryHandleToInode() *DirectoryHandleToInode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (wfs *WFS) AcquireDirectoryHandle() (DirectoryHandleId, *DirectoryHandle) {
|
func (wfs *WFS) AcquireDirectoryHandle() (DirectoryHandleId, *DirectoryHandle) {
|
||||||
wfs.fhmap.Lock()
|
fh := FileHandleId(util.RandomUint64())
|
||||||
fh := wfs.fhmap.nextFh
|
|
||||||
wfs.fhmap.nextFh = FileHandleId(util.RandomUint64())
|
|
||||||
wfs.fhmap.Unlock()
|
|
||||||
|
|
||||||
wfs.dhmap.Lock()
|
wfs.dhmap.Lock()
|
||||||
defer wfs.dhmap.Unlock()
|
defer wfs.dhmap.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user