From 52ab0462a42c22ccf07d0cc110590fc7db957182 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 2 Jul 2017 15:59:38 +0200 Subject: 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%. --- internal/fusefrontend/file.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'internal/fusefrontend') 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] -- cgit v1.2.3