Add FUSE_DEV_IOC_CLONE support for multi-threaded reading#421
Add FUSE_DEV_IOC_CLONE support for multi-threaded reading#421ejc3 wants to merge 3 commits intocberner:masterfrom
Conversation
|
Please add a test for this functionality. Also, I don't really like the idea of making |
|
@stepancheg I think you're working on a similar feature. Want to take a look and lemme know how they overlap, if at all? |
|
I left a comment in the other thread. |
Hi @stepancheg, can you point me there? I might not be on that issue / pull request. Thanks! |
|
It's this one: #572 |
I rebased onto main, so those changes are incorporated now. |
|
The approach @stepancheg described seems better to me, because it provides a simpler interface to users. Can you take a look at that and let me know if your use case requires additional functionality or lower level access? |
ffe3ad3 to
984aaff
Compare
|
I rebased again. #627 won’t work as is (as mentioned) because it doesn’t support the clone fd ioctl. Otherwise, if that was added, it should work. |
multiple event loops can work with and without ioctl. This is how libfuse works — single thread, multiple threads shared fd, or multiple threads clone fd with ioctl. I started without ioctl, because I presume we should make version without ioctl work first, and then add ioctl on top. |
|
Yeah, that makes.
I was saying that there isn’t a perf improvement if we don’t do the clone though. I will submit pull request on top of 627 that does the clone.
Sent from Yahoo Mail for iPhone
On Sunday, February 1, 2026, 6:06 PM, Stepan Koltsov ***@***.***> wrote:
stepancheg left a comment (cberner/fuser#421)
#627 won’t work as is (as mentioned) because it doesn’t support the clone fd ioctl
multiple event loops can work with and without ioctl. This is how libfuse works — single thread, multiple threads shared fd, or multiple threads clone fd with ioctl.
I started without ioctl, because I presume we should make version without ioctl work first, and then add ioctl on top.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
It is perf improvement if filesystem implementation does something non-trivial. But not as big as with ioctl. |
For now just add an option to spawn multiple threads. No `fuse_dev_ioc_clone` yet. Before adding that ioctl, we need to write automated tests for multithreading, e.g. that different threads actually process messages. Some refactoring is desirable for that. For now I tested by running with debug logs, which contain different thread names: ``` [2026-02-01T22:09:00.875147750Z DEBUG fuser::request] FUSE(7998) ino 0x000000000000044e RELEASE fh FileHandle(4611686018427388903), flags 0x8801, flush false, lock owner None thread=fuser-8 ``` Note libfuse can run in multiple threads too in similar way, without ioctl clone fd.
Replace ch.clone() (which just clones the Arc, sharing one fd) with actual FUSE_DEV_IOC_CLONE ioctl that creates independent fds. Without clone_fd: all threads serialize on one fd With clone_fd: kernel distributes requests across fds (true parallelism) - Add Channel::clone_fd() using FUSE_DEV_IOC_CLONE ioctl - Update run() to use clone_fd() on Linux - Fall back to ch.clone() on non-Linux (no true parallelism)
- Use existing fuse_dev_ioc_clone from ll/ioctl.rs instead of defining the ioctl inline - Make clone_fd opt-in via Config.clone_fd (default false) - Remove tests/clone_fd_test.rs (tests live in fuser-tests, examples/hello.rs already demonstrates the feature)
Summary
Add support for multi-threaded FUSE request processing using FUSE_DEV_IOC_CLONE ioctl.
This enables multiple threads to read FUSE requests in parallel from cloned file descriptors, improving throughput for high-concurrency workloads.
API
// Primary session handles INIT and runs in main thread
let session = Session::new(fs, mountpoint, &Config::default())?;
// Clone fd for additional reader threads
let cloned_fd = session.clone_fd()?;
let reader_session = Session::from_fd_initialized(fs_clone, cloned_fd, SessionACL::All);
std::thread::spawn(move || reader_session.run());
session.run()?;
Changes
Tests
Added two integration tests:
Platform Support
clone_fd() is only available on Linux (#[cfg(target_os = "linux")]).