From 9072e1d38ac7f49e91e0570cc80000c48784ebc3 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 31 Dec 2025 00:30:12 -0800 Subject: [PATCH] mount: add -asyncDio flag for async direct I/O (#7922) * mount: add -asyncDio flag for async direct I/O This adds support for async direct I/O via the -asyncDio flag. Async DIO enables the FUSE_CAP_ASYNC_DIO capability, allowing the kernel to perform direct I/O operations asynchronously. This improves concurrency for applications that use O_DIRECT flag. Benefits: - Better concurrency for direct I/O operations - Improved performance for applications using O_DIRECT - Reduced blocking on I/O operations Use cases: - Database workloads that use direct I/O - Applications that bypass page cache intentionally - High-performance I/O scenarios Implementation inspired by JuiceFS which enables this capability for improved I/O performance. Usage: weed mount -filer=localhost:8888 -dir=/mnt/seaweedfs -asyncDio * mount: add all remaining FUSE options (asyncDio, cacheSymlink, novncache) This combines the remaining three FUSE mount options on top of the merged writebackCache PR: 1. asyncDio: Enable async direct I/O for better concurrency 2. cacheSymlink: Enable symlink caching to reduce metadata lookups 3. novncache: (macOS only) Disable vnode name caching to avoid stale data All options use the function parameter 'option' instead of global 'mountOptions'. --- weed/command/mount.go | 10 ++++++++++ weed/command/mount_std.go | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/weed/command/mount.go b/weed/command/mount.go index 82b74f791..ddd429ccc 100644 --- a/weed/command/mount.go +++ b/weed/command/mount.go @@ -50,6 +50,11 @@ type MountOptions struct { // FUSE performance options writebackCache *bool + asyncDio *bool + cacheSymlink *bool + + // macOS-specific FUSE options + novncache *bool } var ( @@ -108,6 +113,11 @@ func init() { // FUSE performance options mountOptions.writebackCache = cmdMount.Flag.Bool("writebackCache", false, "enable FUSE writeback cache for improved write performance (at risk of data loss on crash)") + mountOptions.asyncDio = cmdMount.Flag.Bool("asyncDio", false, "enable async direct I/O for better concurrency") + mountOptions.cacheSymlink = cmdMount.Flag.Bool("cacheSymlink", false, "enable symlink caching to reduce metadata lookups") + + // macOS-specific FUSE options + mountOptions.novncache = cmdMount.Flag.Bool("sys.novncache", false, "(macOS only) disable vnode name caching to avoid stale data") } var cmdMount = &Command{ diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go index 7e688fc27..497a1eec8 100644 --- a/weed/command/mount_std.go +++ b/weed/command/mount_std.go @@ -208,7 +208,9 @@ func RunMount(option *MountOptions, umask os.FileMode) bool { if runtime.GOARCH == "amd64" { fuseMountOptions.Options = append(fuseMountOptions.Options, "noapplexattr") } - // fuseMountOptions.Options = append(fuseMountOptions.Options, "novncache") // need to test effectiveness + if *option.novncache { + fuseMountOptions.Options = append(fuseMountOptions.Options, "novncache") + } fuseMountOptions.Options = append(fuseMountOptions.Options, "slow_statfs") fuseMountOptions.Options = append(fuseMountOptions.Options, "volname="+serverFriendlyName) fuseMountOptions.Options = append(fuseMountOptions.Options, fmt.Sprintf("iosize=%d", ioSizeMB*1024*1024)) @@ -217,6 +219,12 @@ func RunMount(option *MountOptions, umask os.FileMode) bool { if *option.writebackCache { fuseMountOptions.Options = append(fuseMountOptions.Options, "writeback_cache") } + if *option.asyncDio { + fuseMountOptions.Options = append(fuseMountOptions.Options, "async_dio") + } + if *option.cacheSymlink { + fuseMountOptions.EnableSymlinkCaching = true + } // find mount point mountRoot := filerMountRootPath