fusefrontend: doRead: skip decryption for an empty read

Previously we ran through the decryption steps even for an empty
ciphertext slice. The functions handle it correctly, but returning
early skips all the extra calls.

Speeds up the tar extract benchmark by about 4%.
This commit is contained in:
Jakob Unterwurzacher 2017-07-02 15:59:38 +02:00
parent ab787e18f0
commit 52ab0462a4
1 changed files with 5 additions and 0 deletions

View File

@ -181,6 +181,11 @@ func (f *file) doRead(dst []byte, off uint64, length uint64) ([]byte, fuse.Statu
tlog.Warn.Printf("read: ReadAt: %s", err.Error())
return nil, fuse.ToStatus(err)
}
// The ReadAt came back empty. We can skip all the decryption and return early.
if n == 0 {
f.fs.contentEnc.CReqPool.Put(ciphertext)
return dst, fuse.OK
}
// Truncate ciphertext buffer down to actually read bytes
ciphertext = ciphertext[0:n]