summaryrefslogtreecommitdiff
path: root/internal/fusefrontend
diff options
context:
space:
mode:
authorgmd202020-12-08 15:27:23 +0800
committerJakob Unterwurzacher2020-12-20 09:55:04 +0100
commitc20c7992a06434dd4a9624a57aee608acfc33c12 (patch)
treea7680a03fcc0f66a3b6bd468090c7e2d8c3cc7ca /internal/fusefrontend
parent14dac373c27aca96e341ac74ca750cbf7a6ae5eb (diff)
main: add "-kernel_cache" flag
This option is similar to fuse(8) kernel_cache Verified using vmtouch. Without -kernel_cache: $ dd if=/dev/zero of=foo bs=1M count=10 ; vmtouch -t foo ; vmtouch foo 10+0 records in 10+0 records out 10485760 bytes (10 MB, 10 MiB) copied, 0,0242321 s, 433 MB/s Files: 1 Directories: 0 Touched Pages: 2560 (10M) Elapsed: 0.011159 seconds Files: 1 Directories: 0 Resident Pages: 0/2560 0/10M 0% Elapsed: 0.000993 seconds With -kernel_cache: $ dd if=/dev/zero of=foo bs=1M count=10 ; vmtouch -t foo ; vmtouch foo 10+0 records in 10+0 records out 10485760 bytes (10 MB, 10 MiB) copied, 0,0244015 s, 430 MB/s Files: 1 Directories: 0 Touched Pages: 2560 (10M) Elapsed: 0.011564 seconds Files: 1 Directories: 0 Resident Pages: 2560/2560 10M/10M 100% Elapsed: 0.000369 seconds
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r--internal/fusefrontend/args.go2
-rw-r--r--internal/fusefrontend/node.go4
2 files changed, 6 insertions, 0 deletions
diff --git a/internal/fusefrontend/args.go b/internal/fusefrontend/args.go
index f822650..5eb6bff 100644
--- a/internal/fusefrontend/args.go
+++ b/internal/fusefrontend/args.go
@@ -44,4 +44,6 @@ type Args struct {
// which are a performance problem for writes. See
// https://github.com/rfjakob/gocryptfs/issues/515 for details.
Suid bool
+ // Enable the FUSE kernel_cache option
+ KernelCache bool
}
diff --git a/internal/fusefrontend/node.go b/internal/fusefrontend/node.go
index bc4eb3b..80d642c 100644
--- a/internal/fusefrontend/node.go
+++ b/internal/fusefrontend/node.go
@@ -190,6 +190,10 @@ func (n *Node) Open(ctx context.Context, flags uint32) (fh fs.FileHandle, fuseFl
rn.openWriteOnlyLock.RLock()
defer rn.openWriteOnlyLock.RUnlock()
+ if rn.args.KernelCache {
+ fuseFlags = fuse.FOPEN_KEEP_CACHE
+ }
+
// Open backing file
fd, err := syscallcompat.Openat(dirfd, cName, newFlags, 0)
// Handle a few specific errors