aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-06-30 23:15:31 +0200
committerJakob Unterwurzacher2017-06-30 23:15:31 +0200
commitb2a23e94d10a7e3f7e25db50211b167f6fb280da (patch)
treeb45e1863148d1a20b02a622dc8eded1c629cad6d
parent06398e82d91c81c618bfa6a481c0e9070847c909 (diff)
fusefrontend: doRead: use CReqPool for ciphertext buffer
Easily saves lots of allocations.
-rw-r--r--internal/fusefrontend/file.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go
index 6f963e7..70c8d83 100644
--- a/internal/fusefrontend/file.go
+++ b/internal/fusefrontend/file.go
@@ -172,7 +172,8 @@ func (f *file) doRead(dst []byte, off uint64, length uint64) ([]byte, fuse.Statu
skip := blocks[0].Skip
tlog.Debug.Printf("JointCiphertextRange(%d, %d) -> %d, %d, %d", off, length, alignedOffset, alignedLength, skip)
- ciphertext := make([]byte, int(alignedLength))
+ ciphertext := f.fs.contentEnc.CReqPool.Get()
+ ciphertext = ciphertext[:int(alignedLength)]
n, err := f.fd.ReadAt(ciphertext, int64(alignedOffset))
// We don't care if the file ID changes after we have read the data. Drop the lock.
f.fileTableEntry.HeaderLock.RUnlock()
@@ -188,6 +189,7 @@ func (f *file) doRead(dst []byte, off uint64, length uint64) ([]byte, fuse.Statu
// Decrypt it
plaintext, err := f.contentEnc.DecryptBlocks(ciphertext, firstBlockNo, fileID)
+ f.fs.contentEnc.CReqPool.Put(ciphertext)
if err != nil {
if f.fs.args.ForceDecode && err == stupidgcm.ErrAuth {
// We do not have the information which block was corrupt here anymore,