diff options
| author | Jakob Unterwurzacher | 2026-07-16 20:32:51 +0200 |
|---|---|---|
| committer | Jakob Unterwurzacher | 2026-07-16 20:34:45 +0200 |
| commit | a244f1ae9e5a67c1bc2fedb80e82bb646993d936 (patch) | |
| tree | d0dfe8b4dda8aa4a20840f9bdbff9750bb04a68a | |
| parent | 0acbbc0913a3a7069984c8e52f64e302d7f52df4 (diff) | |
fusefrontend: sharedstorage: introduce UnlockSharedStorage helper
| -rw-r--r-- | internal/fusefrontend/file.go | 2 | ||||
| -rw-r--r-- | internal/fusefrontend/file_allocate_truncate.go | 2 | ||||
| -rw-r--r-- | internal/fusefrontend/file_lock.go | 5 |
3 files changed, 7 insertions, 2 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go index b7ff032..a9171aa 100644 --- a/internal/fusefrontend/file.go +++ b/internal/fusefrontend/file.go @@ -327,7 +327,7 @@ func (f *File) doWrite(data []byte, off int64) (uint32, syscall.Errno) { tlog.Warn.Printf("ino%d: LockSharedStorage(F_WRLCK, %d, %d) failed: %v", f.qIno.Ino, cOff, int64(lkLen), err) return 0, fs.ToErrno(err) } - defer f.LockSharedStorage(unix.F_UNLCK, int64(cOff), int64(lkLen)) + defer f.UnlockSharedStorage(int64(cOff), int64(lkLen)) for i, b := range blocks { blockData := dataBuf.Next(int(b.Length)) diff --git a/internal/fusefrontend/file_allocate_truncate.go b/internal/fusefrontend/file_allocate_truncate.go index 7f1371c..ecef0f1 100644 --- a/internal/fusefrontend/file_allocate_truncate.go +++ b/internal/fusefrontend/file_allocate_truncate.go @@ -115,7 +115,7 @@ func (f *File) truncate(newSize uint64) (errno syscall.Errno) { // racy on tmpfs and ext4 ( https://lore.kernel.org/all/18e9fa0f-ec31-9107-459c-ae1694503f87@gmail.com/t/ ) // as evident by TestOpenTruncate test failures. f.LockSharedStorage(unix.F_WRLCK, 0, 0) - defer f.LockSharedStorage(unix.F_UNLCK, 0, 0) + defer f.UnlockSharedStorage(0, 0) // With -sharedstorage, we keep the on-disk file header. // Other mounts may have the file ID cached so we cannot mess with it. diff --git a/internal/fusefrontend/file_lock.go b/internal/fusefrontend/file_lock.go index bb72c52..f440754 100644 --- a/internal/fusefrontend/file_lock.go +++ b/internal/fusefrontend/file_lock.go @@ -29,3 +29,8 @@ func (f *File) LockSharedStorage(lkType int16, lkStart int64, lkLen int64) error } return unix.FcntlFlock(uintptr(f.intFd()), syscallcompat.F_OFD_SETLKW, &lk) } + +// UnlockSharedStorage calls LockSharedStorage with unix.F_UNLCK. +func (f *File) UnlockSharedStorage(lkStart int64, lkLen int64) error { + return f.LockSharedStorage(unix.F_UNLCK, lkStart, lkLen) +} |
