Skip to content

Commit b2a23e9

Browse files
committed
fusefrontend: doRead: use CReqPool for ciphertext buffer
Easily saves lots of allocations.
1 parent 06398e8 commit b2a23e9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/fusefrontend/file.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ func (f *file) doRead(dst []byte, off uint64, length uint64) ([]byte, fuse.Statu
172172
skip := blocks[0].Skip
173173
tlog.Debug.Printf("JointCiphertextRange(%d, %d) -> %d, %d, %d", off, length, alignedOffset, alignedLength, skip)
174174

175-
ciphertext := make([]byte, int(alignedLength))
175+
ciphertext := f.fs.contentEnc.CReqPool.Get()
176+
ciphertext = ciphertext[:int(alignedLength)]
176177
n, err := f.fd.ReadAt(ciphertext, int64(alignedOffset))
177178
// We don't care if the file ID changes after we have read the data. Drop the lock.
178179
f.fileTableEntry.HeaderLock.RUnlock()
@@ -188,6 +189,7 @@ func (f *file) doRead(dst []byte, off uint64, length uint64) ([]byte, fuse.Statu
188189

189190
// Decrypt it
190191
plaintext, err := f.contentEnc.DecryptBlocks(ciphertext, firstBlockNo, fileID)
192+
f.fs.contentEnc.CReqPool.Put(ciphertext)
191193
if err != nil {
192194
if f.fs.args.ForceDecode && err == stupidgcm.ErrAuth {
193195
// We do not have the information which block was corrupt here anymore,

0 commit comments

Comments
 (0)