-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As go-fuse doesn't set this flag right now, we end up using the write-through cache mode. This means that every call to write() also translates to an operation against the FUSE server. This pessimizes workloads that perform many tiny writes. We know that this change is safe, because only between Linux 5.4-5.10 they made some changes to fully respect write-through mode. Furthermore, OSXFUSE on macOS doesn't even support write-through mode. It was using writeback mode to begin with.
- Loading branch information
1 parent
5f90704
commit a8ab442
Showing
3 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
diff --git fuse/api.go fuse/api.go | ||
index a0ec84f..5b7a8ab 100644 | ||
--- fuse/api.go | ||
+++ fuse/api.go | ||
@@ -249,6 +249,13 @@ type MountOptions struct { | ||
// for more details. | ||
SyncRead bool | ||
|
||
+ // Let the kernel use the writeback cache mode, as opposed to | ||
+ // write-through mode. | ||
+ // | ||
+ // See the following page for more details: | ||
+ // https://www.kernel.org/doc/Documentation/filesystems/fuse-io.txt | ||
+ EnableWritebackCache bool | ||
+ | ||
// If set, fuse will first attempt to use syscall.Mount instead of | ||
// fusermount to mount the filesystem. This will not update /etc/mtab | ||
// but might be needed if fusermount is not available. | ||
diff --git fuse/opcode.go fuse/opcode.go | ||
index 7b72cb6..e1ff6f2 100644 | ||
--- fuse/opcode.go | ||
+++ fuse/opcode.go | ||
@@ -115,6 +115,9 @@ func doInit(server *Server, req *request) { | ||
// Clear CAP_READDIRPLUS | ||
server.kernelSettings.Flags &= ^uint32(CAP_READDIRPLUS) | ||
} | ||
+ if server.opts.EnableWritebackCache { | ||
+ server.kernelSettings.Flags |= CAP_WRITEBACK_CACHE | ||
+ } | ||
|
||
dataCacheMode := input.Flags & CAP_AUTO_INVAL_DATA | ||
if server.opts.ExplicitDataCacheControl { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters