mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Synchronize number of open files
This commit is contained in:
parent
5df38d610d
commit
775dfbae85
|
@ -210,7 +210,9 @@ func (fh *FileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) err
|
||||||
fh.Lock()
|
fh.Lock()
|
||||||
defer fh.Unlock()
|
defer fh.Unlock()
|
||||||
|
|
||||||
|
fh.f.wfs.handlesLock.Lock()
|
||||||
fh.f.isOpen--
|
fh.f.isOpen--
|
||||||
|
fh.f.wfs.handlesLock.Unlock()
|
||||||
|
|
||||||
if fh.f.isOpen <= 0 {
|
if fh.f.isOpen <= 0 {
|
||||||
fh.f.entry = nil
|
fh.f.entry = nil
|
||||||
|
|
|
@ -157,20 +157,21 @@ func (wfs *WFS) AcquireHandle(file *File, uid, gid uint32, writeOnly bool) (file
|
||||||
|
|
||||||
wfs.handlesLock.Lock()
|
wfs.handlesLock.Lock()
|
||||||
existingHandle, found := wfs.handles[inodeId]
|
existingHandle, found := wfs.handles[inodeId]
|
||||||
wfs.handlesLock.Unlock()
|
if found && existingHandle != nil && existingHandle.f.isOpen > 0 {
|
||||||
if found && existingHandle != nil {
|
|
||||||
existingHandle.f.isOpen++
|
existingHandle.f.isOpen++
|
||||||
|
wfs.handlesLock.Unlock()
|
||||||
existingHandle.dirtyPages.SetWriteOnly(writeOnly)
|
existingHandle.dirtyPages.SetWriteOnly(writeOnly)
|
||||||
glog.V(4).Infof("Acquired Handle %s open %d", fullpath, existingHandle.f.isOpen)
|
glog.V(4).Infof("Reuse AcquiredHandle %s open %d", fullpath, existingHandle.f.isOpen)
|
||||||
return existingHandle
|
return existingHandle
|
||||||
}
|
}
|
||||||
|
wfs.handlesLock.Unlock()
|
||||||
|
|
||||||
entry, _ := file.maybeLoadEntry(context.Background())
|
entry, _ := file.maybeLoadEntry(context.Background())
|
||||||
file.entry = entry
|
file.entry = entry
|
||||||
fileHandle = newFileHandle(file, uid, gid, writeOnly)
|
fileHandle = newFileHandle(file, uid, gid, writeOnly)
|
||||||
file.isOpen++
|
|
||||||
|
|
||||||
wfs.handlesLock.Lock()
|
wfs.handlesLock.Lock()
|
||||||
|
file.isOpen++
|
||||||
wfs.handles[inodeId] = fileHandle
|
wfs.handles[inodeId] = fileHandle
|
||||||
wfs.handlesLock.Unlock()
|
wfs.handlesLock.Unlock()
|
||||||
fileHandle.handle = inodeId
|
fileHandle.handle = inodeId
|
||||||
|
|
Loading…
Reference in a new issue