Skip to content

Commit

Permalink
Make ReadDirPlus configurable
Browse files Browse the repository at this point in the history
When ReadDirPlus is enabled, the FUSE fs has to gather a lot of additional data for every file even if it won't be used (for example when the user is doing and 'ls' or a large glob). This can cause performance problems, so it should be possible to switch to the simple ReadDir behavior for file systems where this is a bottleneck.

Change-Id: I7f2e58fe6e728a408044ce789633423f6e527554
  • Loading branch information
esp32wrangler authored and hanwen committed Nov 17, 2022
1 parent 9905e99 commit 915cf54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fuse/api.go
Expand Up @@ -229,6 +229,11 @@ type MountOptions struct {
// in https://github.com/libfuse/libfuse/blob/master/include/fuse_common.h
// for details.
EnableAcl bool

// Disable ReadDirPlus capability so ReadDir is used instead. Simple
// directory queries (i.e. 'ls' without '-l') can be faster with
// ReadDir, as no per-file stat calls are needed
DisableReadDirPlus bool
}

// RawFileSystem is an interface close to the FUSE wire protocol.
Expand Down
4 changes: 4 additions & 0 deletions fuse/opcode.go
Expand Up @@ -103,6 +103,10 @@ func doInit(server *Server, req *request) {
// Clear CAP_ASYNC_READ
server.kernelSettings.Flags &= ^uint32(CAP_ASYNC_READ)
}
if server.opts.DisableReadDirPlus {
// Clear CAP_READDIRPLUS
server.kernelSettings.Flags &= ^uint32(CAP_READDIRPLUS)
}

dataCacheMode := input.Flags & CAP_AUTO_INVAL_DATA
if server.opts.ExplicitDataCacheControl {
Expand Down

0 comments on commit 915cf54

Please sign in to comment.