aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend/file_allocate_truncate.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-05-01 17:26:50 +0200
committerJakob Unterwurzacher2017-05-01 17:26:50 +0200
commit514f515dd7196e26ca8df6886ac4a34e928e50dd (patch)
tree42a2098cb61464a1d93cc97f76b2d19362b46700 /internal/fusefrontend/file_allocate_truncate.go
parent01aeace9511ef958b9accfd935fb056ea6d06707 (diff)
fusefronted, openfiletable: move the open file table to its own package
The open file table code needs some room to grow for the upcoming FD multiplexing implementation.
Diffstat (limited to 'internal/fusefrontend/file_allocate_truncate.go')
-rw-r--r--internal/fusefrontend/file_allocate_truncate.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/internal/fusefrontend/file_allocate_truncate.go b/internal/fusefrontend/file_allocate_truncate.go
index ae3dd41..acde76f 100644
--- a/internal/fusefrontend/file_allocate_truncate.go
+++ b/internal/fusefrontend/file_allocate_truncate.go
@@ -50,8 +50,8 @@ func (f *file) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
if f.released {
return fuse.EBADF
}
- f.fileTableEntry.writeLock.Lock()
- defer f.fileTableEntry.writeLock.Unlock()
+ f.fileTableEntry.WriteLock.Lock()
+ defer f.fileTableEntry.WriteLock.Unlock()
blocks := f.contentEnc.ExplodePlainRange(off, sz)
firstBlock := blocks[0]
@@ -97,17 +97,17 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
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.devIno.ino, f.intFd())
+ tlog.Warn.Printf("ino%d fh%d: Truncate on released file", f.qIno.Ino, f.intFd())
return fuse.EBADF
}
- f.fileTableEntry.writeLock.Lock()
- defer f.fileTableEntry.writeLock.Unlock()
+ f.fileTableEntry.WriteLock.Lock()
+ defer f.fileTableEntry.WriteLock.Unlock()
var err error
// Common case first: Truncate to zero
if newSize == 0 {
err = syscall.Ftruncate(int(f.fd.Fd()), 0)
if err != nil {
- tlog.Warn.Printf("ino%d fh%d: Ftruncate(fd, 0) returned error: %v", f.devIno.ino, f.intFd(), err)
+ tlog.Warn.Printf("ino%d fh%d: Ftruncate(fd, 0) returned error: %v", f.qIno.Ino, f.intFd(), err)
return fuse.ToStatus(err)
}
// Truncate to zero kills the file header
@@ -125,7 +125,7 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
oldB := float32(oldSize) / float32(f.contentEnc.PlainBS())
newB := float32(newSize) / float32(f.contentEnc.PlainBS())
- tlog.Debug.Printf("ino%d: FUSE Truncate from %.2f to %.2f blocks (%d to %d bytes)", f.devIno.ino, oldB, newB, oldSize, newSize)
+ tlog.Debug.Printf("ino%d: FUSE Truncate from %.2f to %.2f blocks (%d to %d bytes)", f.qIno.Ino, oldB, newB, oldSize, newSize)
// File size stays the same - nothing to do
if newSize == oldSize {
@@ -168,7 +168,7 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
func (f *file) statPlainSize() (uint64, error) {
fi, err := f.fd.Stat()
if err != nil {
- tlog.Warn.Printf("ino%d fh%d: statPlainSize: %v", f.devIno.ino, f.intFd(), err)
+ tlog.Warn.Printf("ino%d fh%d: statPlainSize: %v", f.qIno.Ino, f.intFd(), err)
return 0, err
}
cipherSz := uint64(fi.Size())