aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-07-02 15:59:38 +0200
committerJakob Unterwurzacher2017-07-02 16:02:13 +0200
commit52ab0462a42c22ccf07d0cc110590fc7db957182 (patch)
tree61d8424ad71a2685519e60ad1f2aa8353936c7dc
parentab787e18f0283392f5a42c31a29446d71f215c6a (diff)
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%.
-rw-r--r--internal/fusefrontend/file.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go
index a1f4f15..30e6e3d 100644
--- a/internal/fusefrontend/file.go
+++ b/internal/fusefrontend/file.go
@@ -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]