New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for setting max-pages via config #347
Conversation
Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
This needs a tests. Have a look at fs/directio_test.go for some inspiration. You can do a large write by calling syscall.Write on 1 MB slice. On the FUSE side, the test should check that the requests are coming in as 1 MB in the Write call. |
With this PR plus the change below against loopback I was able to get 1 MiB writes [1] but not 1 MiB reads [2]. @darthShadow did you manage to get large reads (how?)? diff --git a/example/loopback/main.go b/example/loopback/main.go
index 4204c54..b2d5abe 100644
--- a/example/loopback/main.go
+++ b/example/loopback/main.go
@@ -104,6 +104,8 @@ func main() {
opts.MountOptions.Options = append(opts.MountOptions.Options, "fsname="+orig)
// Second column in "df -T" will be shown as "fuse." + Name
opts.MountOptions.Name = "loopback"
+ opts.MountOptions.MaxWrite = 1024 * 1024
+ opts.MountOptions.MaxPages = 256
// Leave file permissions on "000" files as-is
opts.NullPermissions = true
// Enable diagnostics logging [1]:
[2]:
|
PS: As for the public API, I think we should do what libfuse does: calculate MaxPages from MaxWrite ( libfuse/libfuse@027d0d1 ) and don't expose MaxPages to the user at all |
I went down the rabbit hole about the read sizes a little bit: A normal (=not direct i/o) read ends up in filemap_read(), and, quoting from the function comment:
So it will use readahead to get the data. Following some indirections, the size of readahead requests for FUSE filesystems is ultimately limited by the default readahead size: #define VM_READAHEAD_PAGES (SZ_128K / PAGE_SIZE) For normal disks, you can change the readahead size via Now because O_DIRECT bypasses readahead, the limit does not apply, so 1 MiB reads work with O_DIRECT:
|
Pushed my attempt: https://review.gerrithub.io/c/hanwen/go-fuse/+/530724 |
May I ask if there are any possibilities to reconsider or continue on this issue? Since Linux now supports 1Mib i/o for up to 256 pages, but for this library it seems there is no way to configure up to 1Mib i/o. I am implementing a FUSE system that each read request will need to do some pre-processing, so enlarging the max page per read could significantly shorten the latency adds up from each read request. |
Oh, looks like this got stuck on me. Maybe I'll find time to pick this up again. |
Thank you for the response and I appreciate your contributions to this library! It has helped me a lot and I would like to quickly follow up on this opened issue. Sorry for keeping asking and I would love to pick up to see if there is anything I can do if you have no bandwidth recently. |
Yeah you can update the patch to address Han-Wen's comments at https://review.gerrithub.io/c/hanwen/go-fuse/+/530724 |
Really interested in this change - It seems very close to the finish line. |
It looks like the patch has been updated and as far as I can tell all the issues are resolved - though the gerrit interface is somewhat confusing to me. |
No this is still unresolved: https://review.gerrithub.io/c/hanwen/go-fuse/+/530724/comments/15afc10b_ce660eff Note that this went on the backburner for me because it did not significantly improve performance for gocryptfs. |
@rfjakob doesn't this check test resolve the problem?
afaik macos wouldn't set this flag and the tests will be skipped. |
Yes. |
What do you mean? The check is not in the test...? |
Oh I'm looking at an old version of the patchset. |
Let me test this on an old kernel and I will ping Han-Wen if things pass. |
Kernel 4.20 allows writes & reads up to 1 MiB (before: 128 kiB) via CAP_MAX_PAGES & MaxPages. Instead of exposing MaxPages in the API, we follow what libfuse does, and calculate MaxPages from MaxWrite (rounding up). Contrary to what libfuse does, we also set max_read to the same value as MaxWrite. This prevents reads getting larger than writes due to the rounding-up for MaxPages, which is unexpected. This also changes the default behavoir of go-fuse, which was 64 kiB writes, but 128 kiB for reads. Now it is 128 kiB for both. The tests are implemented in the fs package because it's easier there. They also test MaxReadAhead. Tested on Linux 4.19.0 and Linux 6.1.7 via all.bash, and on 6.1.7 also via the gocryptfs test suite. Supersedes #347 Change-Id: I5a1d4ee91945155c367888da7a90814a24a9ee6e
see 265a392 |
Kernel 4.20 allows writes & reads up to 1 MiB (before: 128 kiB) via CAP_MAX_PAGES & MaxPages. Instead of exposing MaxPages in the API, we follow what libfuse does, and calculate MaxPages from MaxWrite (rounding up). Contrary to what libfuse does, we also set max_read to the same value as MaxWrite. This prevents reads getting larger than writes due to the rounding-up for MaxPages, which is unexpected. This also changes the default behavoir of go-fuse, which was 64 kiB writes, but 128 kiB for reads. Now it is 128 kiB for both. The tests are implemented in the fs package because it's easier there. They also test MaxReadAhead. Tested on Linux 4.19.0 and Linux 6.1.7 via all.bash, and on 6.1.7 also via the gocryptfs test suite. Supersedes hanwen#347 Change-Id: I5a1d4ee91945155c367888da7a90814a24a9ee6e
Kernel 4.20 allows writes & reads up to 1 MiB (before: 128 kiB) via CAP_MAX_PAGES & MaxPages. Instead of exposing MaxPages in the API, we follow what libfuse does, and calculate MaxPages from MaxWrite (rounding up). Contrary to what libfuse does, we also set max_read to the same value as MaxWrite. This prevents reads getting larger than writes due to the rounding-up for MaxPages, which is unexpected. This also changes the default behavoir of go-fuse, which was 64 kiB writes, but 128 kiB for reads. Now it is 128 kiB for both. The tests are implemented in the fs package because it's easier there. They also test MaxReadAhead. Tested on Linux 4.19.0 and Linux 6.1.7 via all.bash, and on 6.1.7 also via the gocryptfs test suite. Supersedes hanwen#347 Change-Id: I5a1d4ee91945155c367888da7a90814a24a9ee6e
Kernel 4.20 allows writes & reads up to 1 MiB (before: 128 kiB) via CAP_MAX_PAGES & MaxPages. Instead of exposing MaxPages in the API, we follow what libfuse does, and calculate MaxPages from MaxWrite (rounding up). Contrary to what libfuse does, we also set max_read to the same value as MaxWrite. This prevents reads getting larger than writes due to the rounding-up for MaxPages, which is unexpected. This also changes the default behavoir of go-fuse, which was 64 kiB writes, but 128 kiB for reads. Now it is 128 kiB for both. The tests are implemented in the fs package because it's easier there. They also test MaxReadAhead. Tested on Linux 4.19.0 and Linux 6.1.7 via all.bash, and on 6.1.7 also via the gocryptfs test suite. Supersedes hanwen#347 Change-Id: I5a1d4ee91945155c367888da7a90814a24a9ee6e
Kernel 4.20 allows writes & reads up to 1 MiB (before: 128 kiB) via CAP_MAX_PAGES & MaxPages. Instead of exposing MaxPages in the API, we follow what libfuse does, and calculate MaxPages from MaxWrite (rounding up). Contrary to what libfuse does, we also set max_read to the same value as MaxWrite. This prevents reads getting larger than writes due to the rounding-up for MaxPages, which is unexpected. This also changes the default behavoir of go-fuse, which was 64 kiB writes, but 128 kiB for reads. Now it is 128 kiB for both. The tests are implemented in the fs package because it's easier there. They also test MaxReadAhead. Tested on Linux 4.19.0 and Linux 6.1.7 via all.bash, and on 6.1.7 also via the gocryptfs test suite. Supersedes hanwen#347 Change-Id: I5a1d4ee91945155c367888da7a90814a24a9ee6e
Kernel 4.20 allows writes & reads up to 1 MiB (before: 128 kiB) via CAP_MAX_PAGES & MaxPages. Instead of exposing MaxPages in the API, we follow what libfuse does, and calculate MaxPages from MaxWrite (rounding up). Contrary to what libfuse does, we also set max_read to the same value as MaxWrite. This prevents reads getting larger than writes due to the rounding-up for MaxPages, which is unexpected. This also changes the default behavoir of go-fuse, which was 64 kiB writes, but 128 kiB for reads. Now it is 128 kiB for both. The tests are implemented in the fs package because it's easier there. They also test MaxReadAhead. Tested on Linux 4.19.0 and Linux 6.1.7 via all.bash, and on 6.1.7 also via the gocryptfs test suite. Supersedes hanwen#347 Change-Id: I5a1d4ee91945155c367888da7a90814a24a9ee6e
Added support for setting max-pages via config. Also increased the max write from 128k to 1M.
Signed-off-by: Anagh Kumar Baranwal 6824881+darthShadow@users.noreply.github.com