Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

add file handle locking when changing file entry

Chris Lu77393d3d3042
diff --git a/weed/filesys/file.go b/weed/filesys/file.go
index d9e1f2662b..43f3ddf075 100644
--- a/weed/filesys/file.go
+++ b/weed/filesys/file.go
@@ -106,6 +106,16 @@ func (file *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *f
if err := file.maybeLoadEntry(ctx); err != nil {
return err
}
+ if file.isOpen > 0 {
+ file.wfs.handlesLock.Lock()
+ fileHandle := file.wfs.handles[file.fullpath().AsInode()]
+ file.wfs.handlesLock.Unlock()
+
+ if fileHandle != nil {
+ fileHandle.Lock()
+ defer fileHandle.Unlock()
+ }
+ }
if req.Valid.Size() {