From 514f515dd7196e26ca8df6886ac4a34e928e50dd Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 1 May 2017 17:26:50 +0200 Subject: 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. --- internal/fusefrontend/file_allocate_truncate.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'internal/fusefrontend/file_allocate_truncate.go') 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()) -- cgit v1.2.3