only revert lock table

This commit is contained in:
chrislu 2023-09-23 10:35:29 -07:00
parent 186b1f029b
commit ca1a5457ae
7 changed files with 15 additions and 23 deletions

View file

@ -27,6 +27,7 @@ type FileHandle struct {
dirtyPages *PageWriter dirtyPages *PageWriter
reader *filer.ChunkReadAt reader *filer.ChunkReadAt
contentType string contentType string
sync.RWMutex
isDeleted bool isDeleted bool
@ -101,9 +102,8 @@ func (fh *FileHandle) AddChunks(chunks []*filer_pb.FileChunk) {
} }
func (fh *FileHandle) ReleaseHandle() { func (fh *FileHandle) ReleaseHandle() {
fh.Lock()
fhActiveLock := fh.wfs.fhLockTable.AcquireLock("ReleaseHandle", fh.fh, util.ExclusiveLock) defer fh.Unlock()
defer fh.wfs.fhLockTable.ReleaseLock(fh.fh, fhActiveLock)
fh.entryLock.Lock() fh.entryLock.Lock()
defer fh.entryLock.Unlock() defer fh.entryLock.Unlock()

View file

@ -78,7 +78,6 @@ type WFS struct {
dhmap *DirectoryHandleToInode dhmap *DirectoryHandleToInode
fuseServer *fuse.Server fuseServer *fuse.Server
IsOverQuota bool IsOverQuota bool
fhLockTable *util.LockTable[FileHandleId]
} }
func NewSeaweedFileSystem(option *Option) *WFS { func NewSeaweedFileSystem(option *Option) *WFS {
@ -89,7 +88,6 @@ func NewSeaweedFileSystem(option *Option) *WFS {
inodeToPath: NewInodeToPath(util.FullPath(option.FilerMountRootPath)), inodeToPath: NewInodeToPath(util.FullPath(option.FilerMountRootPath)),
fhmap: NewFileHandleToInode(), fhmap: NewFileHandleToInode(),
dhmap: NewDirectoryHandleToInode(), dhmap: NewDirectoryHandleToInode(),
fhLockTable: util.NewLockTable[FileHandleId](),
} }
wfs.option.filerIndex = int32(rand.Intn(len(option.FilerAddresses))) wfs.option.filerIndex = int32(rand.Intn(len(option.FilerAddresses)))

View file

@ -1,7 +1,6 @@
package mount package mount
import ( import (
"github.com/seaweedfs/seaweedfs/weed/util"
"net/http" "net/http"
"time" "time"
@ -45,16 +44,16 @@ func (wfs *WFS) CopyFileRange(cancel <-chan struct{}, in *fuse.CopyFileRangeIn)
} }
// lock source and target file handles // lock source and target file handles
fhOutActiveLock := fhOut.wfs.fhLockTable.AcquireLock("CopyFileRange", fhOut.fh, util.ExclusiveLock) fhOut.Lock()
defer fhOut.wfs.fhLockTable.ReleaseLock(fhOut.fh, fhOutActiveLock) defer fhOut.Unlock()
if fhOut.entry == nil { if fhOut.entry == nil {
return 0, fuse.ENOENT return 0, fuse.ENOENT
} }
if fhIn.fh != fhOut.fh { if fhIn.fh != fhOut.fh {
fhInActiveLock := fhIn.wfs.fhLockTable.AcquireLock("CopyFileRange", fhIn.fh, util.SharedLock) fhIn.RLock()
defer fhIn.wfs.fhLockTable.ReleaseLock(fhIn.fh, fhInActiveLock) defer fhIn.RUnlock()
} }
// directories are not supported // directories are not supported

View file

@ -1,7 +1,6 @@
package mount package mount
import ( import (
"github.com/seaweedfs/seaweedfs/weed/util"
"syscall" "syscall"
"github.com/hanwen/go-fuse/v2/fuse" "github.com/hanwen/go-fuse/v2/fuse"
@ -36,8 +35,8 @@ func (wfs *WFS) Lseek(cancel <-chan struct{}, in *fuse.LseekIn, out *fuse.LseekO
} }
// lock the file until the proper offset was calculated // lock the file until the proper offset was calculated
fhActiveLock := fh.wfs.fhLockTable.AcquireLock("Lseek", fh.fh, util.SharedLock) fh.RLock()
defer fh.wfs.fhLockTable.ReleaseLock(fh.fh, fhActiveLock) defer fh.RUnlock()
fh.entryLock.RLock() fh.entryLock.RLock()
defer fh.entryLock.RUnlock() defer fh.entryLock.RUnlock()

View file

@ -3,7 +3,6 @@ package mount
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/seaweedfs/seaweedfs/weed/util"
"io" "io"
"github.com/hanwen/go-fuse/v2/fuse" "github.com/hanwen/go-fuse/v2/fuse"
@ -42,8 +41,8 @@ func (wfs *WFS) Read(cancel <-chan struct{}, in *fuse.ReadIn, buff []byte) (fuse
return nil, fuse.ENOENT return nil, fuse.ENOENT
} }
fhActiveLock := fh.wfs.fhLockTable.AcquireLock("Read", fh.fh, util.SharedLock) fh.RLock()
defer fh.wfs.fhLockTable.ReleaseLock(fh.fh, fhActiveLock) defer fh.RUnlock()
offset := int64(in.Offset) offset := int64(in.Offset)
totalRead, err := readDataByFileHandle(buff, fh, offset) totalRead, err := readDataByFileHandle(buff, fh, offset)

View file

@ -7,7 +7,6 @@ import (
"github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/filer"
"github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/util"
"syscall" "syscall"
"time" "time"
) )
@ -90,6 +89,8 @@ func (wfs *WFS) Fsync(cancel <-chan struct{}, in *fuse.FsyncIn) (code fuse.Statu
} }
func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status { func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status {
fh.Lock()
defer fh.Unlock()
// flush works at fh level // flush works at fh level
fileFullPath := fh.FullPath() fileFullPath := fh.FullPath()
@ -104,9 +105,6 @@ func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status {
} }
} }
fhActiveLock := fh.wfs.fhLockTable.AcquireLock("doFlush", fh.fh, util.ExclusiveLock)
defer fh.wfs.fhLockTable.ReleaseLock(fh.fh, fhActiveLock)
if !fh.dirtyMetadata { if !fh.dirtyMetadata {
return fuse.OK return fuse.OK
} }

View file

@ -2,7 +2,6 @@ package mount
import ( import (
"github.com/hanwen/go-fuse/v2/fuse" "github.com/hanwen/go-fuse/v2/fuse"
"github.com/seaweedfs/seaweedfs/weed/util"
"net/http" "net/http"
"syscall" "syscall"
"time" "time"
@ -49,8 +48,8 @@ func (wfs *WFS) Write(cancel <-chan struct{}, in *fuse.WriteIn, data []byte) (wr
tsNs := time.Now().UnixNano() tsNs := time.Now().UnixNano()
fhActiveLock := fh.wfs.fhLockTable.AcquireLock("Write", fh.fh, util.ExclusiveLock) fh.Lock()
defer fh.wfs.fhLockTable.ReleaseLock(fh.fh, fhActiveLock) defer fh.Unlock()
entry := fh.GetEntry() entry := fh.GetEntry()
if entry == nil { if entry == nil {