Skip to content
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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions fuse/api.go
Expand Up @@ -167,6 +167,10 @@ type MountOptions struct {
// Options passed to syscall.Mount, the default value used by fusermount
// is syscall.MS_NOSUID|syscall.MS_NODEV
DirectMountFlags uintptr

// Number of pages to request. If less than 32, use default (i.e. 32). This number is
// capped at the kernel maximum i.e. 256.
MaxPages uint16
}

// RawFileSystem is an interface close to the FUSE wire protocol.
Expand Down
11 changes: 11 additions & 0 deletions fuse/opcode.go
Expand Up @@ -130,6 +130,17 @@ func doInit(server *Server, req *request) {
out.Minor = input.Minor
}

if (input.Flags & CAP_MAX_PAGES) == CAP_MAX_PAGES {
out.Flags |= CAP_MAX_PAGES
if server.opts.MaxPages < 32 {
out.MaxPages = 32 // The minimum allowed by the kernel
} else if server.opts.MaxPages > 256 {
out.MaxPages = 256 // The maximum allowed by the kernel
} else {
out.MaxPages = server.opts.MaxPages
}
}

if out.Minor <= 22 {
tweaked := *req.handler

Expand Down
4 changes: 2 additions & 2 deletions fuse/server.go
Expand Up @@ -19,8 +19,8 @@ import (
)

const (
// The kernel caps writes at 128k.
MAX_KERNEL_WRITE = 128 * 1024
// The kernel caps writes at 1 MiB (from 4.20+).
MAX_KERNEL_WRITE = 1 * 1024 * 1024
)

// Server contains the logic for reading from the FUSE device and
Expand Down