Add support for max_pages and increase to 256 (#96)

* Bump protocol version to min 7.28, max 7.31
* Increase read/write buffer size to 1MiB
* Add new fields to initOp
* Set FUSE_MAX_PAGES flag for init
* Lower min minor version to 19 for osxfuse
* Fix linux WriteSize test
geesefs-0-30-9
Kurt Jensen 2021-08-02 14:29:12 -07:00 committed by GitHub
parent 0630024b2b
commit d82237972e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 17 deletions

View File

@ -161,6 +161,9 @@ func (c *Connection) Init() error {
// Tell the kernel not to use pitifully small 4 KiB writes.
initOp.Flags |= fusekernel.InitBigWrites
// kernel 4.20 increases the max from 32 -> 256
initOp.Flags |= fusekernel.InitMaxPages
initOp.MaxPages = 256
// Enable writeback caching if the user hasn't asked us not to.
if !c.cfg.DisableWritebackCaching {

View File

@ -796,7 +796,12 @@ func (c *Connection) kernelResponseForOp(
out.Minor = o.Library.Minor
out.MaxReadahead = o.MaxReadahead
out.Flags = uint32(o.Flags)
// Default values
out.MaxBackground = 12
out.CongestionThreshold = 9
out.MaxWrite = o.MaxWrite
out.TimeGran = 1
out.MaxPages = o.MaxPages
default:
panic(fmt.Sprintf("Unexpected op: %#v", op))

View File

@ -16,6 +16,5 @@ package buffer
// The maximum fuse write request size that InMessage can acommodate.
//
// Experimentally, Linux appears to refuse to honor a MaxWrite setting in an
// INIT response of more than 128 KiB.
const MaxWriteSize = 1 << 17
// As of kernel 4.20 Linux accepts writes up to 256 pages or 1MiB
const MaxWriteSize = 1 << 20

View File

@ -17,5 +17,5 @@ package buffer
// The maximum read size that we expect to ever see from the kernel, used for
// calculating the size of out messages.
//
// For 4 KiB pages, this is 128 KiB (cf. https://goo.gl/HOiEYo)
const MaxReadSize = 1 << 17
// For 4 KiB pages, this is 1024 KiB (cf. https://github.com/torvalds/linux/blob/15db16837a35d8007cb8563358787412213db25e/fs/fuse/fuse_i.h#L38-L40)
const MaxReadSize = 1 << 20

View File

@ -44,9 +44,9 @@ import (
// The FUSE version implemented by the package.
const (
ProtoVersionMinMajor = 7
ProtoVersionMinMinor = 8
ProtoVersionMinMinor = 19
ProtoVersionMaxMajor = 7
ProtoVersionMaxMinor = 12
ProtoVersionMaxMinor = 31
)
const (
@ -266,6 +266,7 @@ const (
InitAsyncDIO InitFlags = 1 << 15
InitWritebackCache InitFlags = 1 << 16
InitNoOpenSupport InitFlags = 1 << 17
InitMaxPages InitFlags = 1 << 22
InitCacheSymlinks InitFlags = 1 << 23
InitNoOpendirSupport InitFlags = 1 << 24
@ -286,6 +287,7 @@ var initFlagNames = []flagName{
{uint32(InitAtomicTrunc), "InitAtomicTrunc"},
{uint32(InitExportSupport), "InitExportSupport"},
{uint32(InitBigWrites), "InitBigWrites"},
{uint32(InitMaxPages), "InitMaxPages"},
{uint32(InitDontMask), "InitDontMask"},
{uint32(InitSpliceWrite), "InitSpliceWrite"},
{uint32(InitSpliceMove), "InitSpliceMove"},
@ -714,12 +716,17 @@ type InitIn struct {
const InitInSize = int(unsafe.Sizeof(InitIn{}))
type InitOut struct {
Major uint32
Minor uint32
MaxReadahead uint32
Flags uint32
Unused uint32
MaxWrite uint32
Major uint32
Minor uint32
MaxReadahead uint32
Flags uint32
MaxBackground uint16
CongestionThreshold uint16
MaxWrite uint32
TimeGran uint32
MaxPages uint16
MapAlignment uint16
Unused [8]uint32
}
type InterruptIn struct {

8
ops.go
View File

@ -40,7 +40,9 @@ type initOp struct {
Flags fusekernel.InitFlags
// Out
Library fusekernel.Protocol
MaxReadahead uint32
MaxWrite uint32
Library fusekernel.Protocol
MaxReadahead uint32
MaxBackground uint16
MaxWrite uint32
MaxPages uint16
}

View File

@ -194,7 +194,7 @@ func (t *StatFSTest) WriteSize() {
// small chunks of data.
switch runtime.GOOS {
case "linux":
ExpectEq(1<<17, t.fs.MostRecentWriteSize())
ExpectEq(1<<20, t.fs.MostRecentWriteSize())
case "darwin":
ExpectEq(1<<20, t.fs.MostRecentWriteSize())