Skip to content

Commit

Permalink
vfs: fix the issue that plock may be unlocked by mistake (#4910)
Browse files Browse the repository at this point in the history
  • Loading branch information
SandyXSD committed Jun 19, 2024
1 parent 6d51266 commit fe546ff
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/vfs/vfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ func (v *VFS) Release(ctx Context, ino Ino, fh uint64) {
v.invalidateAttr(ino)
}
if locks&1 != 0 {
_ = v.Meta.Flock(ctx, ino, owner, F_UNLCK, false)
_ = v.Meta.Flock(ctx, ino, owner^fh, F_UNLCK, false)
}
}
_ = v.Meta.Close(ctx, ino)
Expand Down
2 changes: 1 addition & 1 deletion pkg/vfs/vfs_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func (v *VFS) Flock(ctx Context, ino Ino, fh uint64, owner uint64, typ uint32, b
}
h.addOp(ctx)
defer h.removeOp(ctx)
err = v.Meta.Flock(ctx, ino, owner, typ, block)
err = v.Meta.Flock(ctx, ino, owner^fh, typ, block)
if err == 0 {
h.Lock()
if typ == syscall.F_UNLCK {
Expand Down

0 comments on commit fe546ff

Please sign in to comment.