diff options
author | Jakob Unterwurzacher | 2021-06-25 11:33:18 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2021-06-25 13:56:53 +0200 |
commit | 84e702126ac4f017e12150532bfaed675dee2927 (patch) | |
tree | f2062bd585cb10bba1c7fa2204e1829b0d08bb64 /internal/fusefrontend/dircache.go | |
parent | 05b813f2026ebe6bff33cb600775823ee8a7df6e (diff) |
fusefrontend: implement recursive diriv caching
The new contrib/maxlen.bash showed that we have exponential
runtime with respect to directory depth.
The new recursive diriv caching is a lot smarter as it caches
intermediate lookups. maxlen.bash now completes in a few seconds.
xfstests results same as
https://github.com/rfjakob/fuse-xfstests/blob/2d158e4c82be85c15269af77498e353f928f4fab/screenlog.0 :
Failures: generic/035 generic/062 generic/080 generic/093 generic/099 generic/215 generic/285 generic/319 generic/426 generic/444 generic/467 generic/477 generic/523
Failed 13 of 580 tests
benchmark.bash results are identical:
$ ./benchmark.bash
Testing gocryptfs at /tmp/benchmark.bash.BdQ: gocryptfs v2.0.1-17-g6b09bc0; go-fuse v2.1.1-0.20210611132105-24a1dfe6b4f8; 2021-06-25 go1.16.5 linux/amd64
/tmp/benchmark.bash.BdQ.mnt is a mountpoint
WRITE: 262144000 bytes (262 MB, 250 MiB) copied, 0,4821 s, 544 MB/s
READ: 262144000 bytes (262 MB, 250 MiB) copied, 0,266061 s, 985 MB/s
UNTAR: 8,280
MD5: 4,564
LS: 1,745
RM: 2,244
Diffstat (limited to 'internal/fusefrontend/dircache.go')
-rw-r--r-- | internal/fusefrontend/dircache.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/internal/fusefrontend/dircache.go b/internal/fusefrontend/dircache.go index 6732de1..8c285fa 100644 --- a/internal/fusefrontend/dircache.go +++ b/internal/fusefrontend/dircache.go @@ -7,7 +7,6 @@ import ( "syscall" "time" - "github.com/rfjakob/gocryptfs/internal/nametransform" "github.com/rfjakob/gocryptfs/internal/tlog" ) @@ -50,6 +49,9 @@ func (e *dirCacheEntry) Clear() { type dirCache struct { sync.Mutex + // Expected length of the stored IVs. Only used for sanity checks. + // Usually set to 16, but 0 in plaintextnames mode. + ivLen int // Cache entries entries [dirCacheSize]dirCacheEntry // Where to store the next entry (index into entries) @@ -77,7 +79,7 @@ func (d *dirCache) Clear() { func (d *dirCache) Store(node *Node, fd int, iv []byte) { // Note: package ensurefds012, imported from main, guarantees that dirCache // can never get fds 0,1,2. - if fd <= 0 || len(iv) != nametransform.DirIVLen { + if fd <= 0 || len(iv) != d.ivLen { log.Panicf("Store sanity check failed: fd=%d len=%d", fd, len(iv)) } d.Lock() @@ -139,7 +141,7 @@ func (d *dirCache) Lookup(node *Node) (fd int, iv []byte) { if enableStats { d.hits++ } - if fd <= 0 || len(iv) != nametransform.DirIVLen { + if fd <= 0 || len(iv) != d.ivLen { log.Panicf("Lookup sanity check failed: fd=%d len=%d", fd, len(iv)) } d.dbg("dirCache.Lookup %p hit fd=%d dup=%d iv=%x\n", node, e.fd, fd, iv) |