v2api: fix double-lock in truncate
This commit is contained in:
parent
6196a5b5fe
commit
b1d631d432
@ -84,15 +84,6 @@ func (f *File2) Allocate(ctx context.Context, off uint64, sz uint64, mode uint32
|
||||
|
||||
// truncate - called from Setattr.
|
||||
func (f *File2) truncate(newSize uint64) (errno syscall.Errno) {
|
||||
f.fdLock.RLock()
|
||||
defer f.fdLock.RUnlock()
|
||||
if f.released {
|
||||
// The file descriptor has been closed concurrently.
|
||||
tlog.Warn.Printf("ino%d fh%d: Truncate on released file", f.qIno.Ino, f.intFd())
|
||||
return syscall.EBADF
|
||||
}
|
||||
f.fileTableEntry.ContentLock.Lock()
|
||||
defer f.fileTableEntry.ContentLock.Unlock()
|
||||
var err error
|
||||
// Common case first: Truncate to zero
|
||||
if newSize == 0 {
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/hanwen/go-fuse/v2/fuse"
|
||||
|
||||
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
|
||||
"github.com/rfjakob/gocryptfs/internal/tlog"
|
||||
)
|
||||
|
||||
func (f *File2) Setattr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) (errno syscall.Errno) {
|
||||
@ -22,6 +23,7 @@ func (f *File2) setAttr(ctx context.Context, in *fuse.SetAttrIn) (errno syscall.
|
||||
f.fdLock.RLock()
|
||||
defer f.fdLock.RUnlock()
|
||||
if f.released {
|
||||
tlog.Warn.Printf("ino%d fh%d: Truncate on released file", f.qIno.Ino, f.intFd())
|
||||
return syscall.EBADF
|
||||
}
|
||||
f.fileTableEntry.ContentLock.Lock()
|
||||
|
Loading…
Reference in New Issue
Block a user