Skip to content

Commit

Permalink
fusefrontend: doRead: use CReqPool for ciphertext buffer
Browse files Browse the repository at this point in the history
Easily saves lots of allocations.
  • Loading branch information
rfjakob committed Jun 30, 2017
1 parent 06398e8 commit b2a23e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/fusefrontend/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
Expand Down

0 comments on commit b2a23e9

Please sign in to comment.