aboutsummaryrefslogtreecommitdiff
path: root/weed/mount/filehandle.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-09-11 19:44:34 -0700
committerchrislu <chris.lu@gmail.com>2022-09-11 19:44:34 -0700
commit22064c342585bddaa7ebdb21e39cac7db87826df (patch)
treede8af6599b1a2d3702b61829bb96329eef22e1c4 /weed/mount/filehandle.go
parentb9112747b57a45d5c1ef476897ec5940c76fc7e8 (diff)
downloadseaweedfs-22064c342585bddaa7ebdb21e39cac7db87826df.tar.xz
seaweedfs-22064c342585bddaa7ebdb21e39cac7db87826df.zip
mount: ensure ordered file handle lock and unlock
Diffstat (limited to 'weed/mount/filehandle.go')
-rw-r--r--weed/mount/filehandle.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/weed/mount/filehandle.go b/weed/mount/filehandle.go
index 5d1552ce6..aadcb3836 100644
--- a/weed/mount/filehandle.go
+++ b/weed/mount/filehandle.go
@@ -1,6 +1,8 @@
package mount
import (
+ "golang.org/x/sync/semaphore"
+ "math"
"sync"
"golang.org/x/exp/slices"
@@ -28,17 +30,18 @@ type FileHandle struct {
reader *filer.ChunkReadAt
contentType string
handle uint64
- sync.Mutex
+ orderedMutex *semaphore.Weighted
isDeleted bool
}
func newFileHandle(wfs *WFS, handleId FileHandleId, inode uint64, entry *filer_pb.Entry) *FileHandle {
fh := &FileHandle{
- fh: handleId,
- counter: 1,
- inode: inode,
- wfs: wfs,
+ fh: handleId,
+ counter: 1,
+ inode: inode,
+ wfs: wfs,
+ orderedMutex: semaphore.NewWeighted(int64(math.MaxInt64)),
}
// dirtyPages: newContinuousDirtyPages(file, writeOnly),
fh.dirtyPages = newPageWriter(fh, wfs.option.ChunkSizeLimit)