mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-13 15:29:12 +01:00
mount: auto-enable Linux FUSE passthrough for read-only files
On a read-only open, when the kernel supports FUSE_PASSTHROUGH (Linux >= 6.9, privileged mount), materialize the file into a local backing file and register it via RegisterBackingFd so the kernel serves reads and mmap directly from the backing file, bypassing the mount process. No opt-in flag: support is probed by the first RegisterBackingFd call and latched off on failure, so unsupported mounts transparently use the normal read path. Gated to read-only opens of files up to -fusePassthroughMaxMB (default 256; 0 disables). The backing is shared per inode and torn down when the last open is released; MaxStackDepth is set so the kernel accepts registration. Tradeoff: a passthrough handle reads a point-in-time snapshot, so concurrent writes are not reflected while the file stays open - best for immutable / read-mostly data. The data path is unchanged when disabled or unsupported, and the feature is a no-op on non-Linux platforms.
This commit is contained in:
1 parent
395d2c80af
commit
c275e186c8
7 files changed
+209
-3
No files matched your search
@@ -315,6 +315,11 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||
if option.cacheSymlink != nil && *option.cacheSymlink {
|
||||
fuseMountOptions.EnableSymlinkCaching = true
|
||||
}
|
||||
if option.fusePassthroughMaxMB != nil && *option.fusePassthroughMaxMB > 0 {
|
||||
// FUSE_PASSTHROUGH requires a non-zero stacking depth advertised in
|
||||
// FUSE_INIT; without it the kernel rejects backing-file registration.
|
||||
fuseMountOptions.MaxStackDepth = 1
|
||||
}
|
||||
|
||||
// find mount point
|
||||
mountRoot := filerMountRootPath
|
||||
@@ -328,6 +333,11 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||
cacheDirForWrite = cacheDirForRead
|
||||
}
|
||||
|
||||
passthroughMaxMB := int64(0)
|
||||
if option.fusePassthroughMaxMB != nil {
|
||||
passthroughMaxMB = *option.fusePassthroughMaxMB
|
||||
}
|
||||
|
||||
seaweedFileSystem := mount.NewSeaweedFileSystem(&mount.Option{
|
||||
MountDirectory: dir,
|
||||
FilerAddresses: filerAddresses,
|
||||
@@ -373,6 +383,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||
EnableDistributedLock: option.distributedLock != nil && *option.distributedLock,
|
||||
WritebackCache: option.writebackCache != nil && *option.writebackCache,
|
||||
PosixDirNlink: option.posixDirNlink != nil && *option.posixDirNlink,
|
||||
FusePassthroughMaxMB: passthroughMaxMB,
|
||||
// Peer chunk sharing
|
||||
PeerEnabled: option.peerEnabled != nil && *option.peerEnabled,
|
||||
PeerListen: peerStringOrEmpty(option.peerListen),
|
||||
|
||||
Reference in new issue
Block a user