diff --git a/fuse.go b/fuse.go index b774a25c..4422d649 100644 --- a/fuse.go +++ b/fuse.go @@ -232,9 +232,17 @@ func initMount(c *Conn, conf *mountConfig) error { } c.proto = proto + maxReadahead := conf.maxReadahead + if maxReadahead == 0 { + maxReadahead = defaultReadahead + } + if maxReadahead > r.MaxReadahead { + maxReadahead = r.MaxReadahead + } + s := &InitResponse{ Library: proto, - MaxReadahead: conf.maxReadahead, + MaxReadahead: maxReadahead, MaxWrite: maxWrite, Flags: InitBigWrites | conf.initFlags, } diff --git a/fuse_darwin.go b/fuse_darwin.go index b58dca97..1a974716 100644 --- a/fuse_darwin.go +++ b/fuse_darwin.go @@ -7,3 +7,6 @@ package fuse // 16MB value. See TestSetxattr16MB and // https://github.com/bazil/fuse/issues/42 const maxWrite = 16 * 1024 * 1024 + +// Default kernel readahead. +const defaultReadahead = 128 * 1024 diff --git a/fuse_freebsd.go b/fuse_freebsd.go index 4aa83a0d..2ec8bf59 100644 --- a/fuse_freebsd.go +++ b/fuse_freebsd.go @@ -4,3 +4,6 @@ package fuse // // This number is just a guess. const maxWrite = 128 * 1024 + +// Default kernel readahead. +const defaultReadahead = 128 * 1024 diff --git a/fuse_linux.go b/fuse_linux.go index 5fb96f9a..c0ae567f 100644 --- a/fuse_linux.go +++ b/fuse_linux.go @@ -5,3 +5,6 @@ package fuse // Linux 4.2.0 has been observed to cap this value at 128kB // (FUSE_MAX_PAGES_PER_REQ=32, 4kB pages). const maxWrite = 128 * 1024 + +// Default kernel readahead. +const defaultReadahead = 128 * 1024