Skip to content

Comments

&mut -> & of session in event loop#572

Merged
cberner merged 1 commit intocberner:masterfrom
stepancheg:session-event-loop
Jan 26, 2026
Merged

&mut -> & of session in event loop#572
cberner merged 1 commit intocberner:masterfrom
stepancheg:session-event-loop

Conversation

@stepancheg
Copy link
Contributor

To process session from multiple threads, we need to use the session as &session instead of &mut session, so the session can be put into Arc or something.

This PR extracts event_loop function to handle all requests except init and destroy, and handles FUSE_DESTROY outside of event loop.

To process session from multiple threads, we need to use the session as
`&session` instead of `&mut session`, so the session can be put into
`Arc` or something.

This PR extracts `event_loop` function to handle all requests except
init and destroy, and handles `FUSE_DESTROY` outside of event loop.
@stepancheg stepancheg marked this pull request as ready for review January 26, 2026 00:22
@cberner
Copy link
Owner

cberner commented Jan 26, 2026

Can you say more about how you're planning to implement the multi-threading? I haven't looked into it very much, but this PR: #421 adds an op to clone the /dev/fuse fd and then create multiple sessions.

@stepancheg
Copy link
Contributor Author

stepancheg commented Jan 26, 2026

My idea was this: you pass a parameter to session creation, number of threads.

Then run function is modified like this, pseudocode:

fn run(self) {
  handshake();

  let this = Arc::new(self);

  let threads = Vec::new();
  for thread in 0..n_threads {
    let fd = clone_fd();
    let this = this.clone();
    threads.push(thread::spawn(|| this.event_loop());
  }

  join_threads();

  destroy();
}

So that fuser library manages threads.

That PR exposes low level operation Session::from_fd_initialized instead, which is less convenient, but also creates other problems, for example, Session::from_fd_initialized does not now know what features were negotiated. In particular, that PR incorrectly initializes Session.proto_version field. And it does call from_fd_initialized before initialization even happens (comment "Skip INIT - caller guarantees mount is initialized" is false when using provided test as reference). Also that PR contains changes unrelated to the problem. It defines FUSE_DEV_IOC_CLONE constant twice instead of using ioctl macro from nix. Comments in that PR are excessive, e.g. no need to have a comment "open a new /dev/fuse" literally before the call open("/dev/fuse"). Tests are written with sleeps so they will be flaky instead of proper synchronization. Overall, I don't like quality of that PR.

That said, exposing low level parts of working with FUSE may have its use.

@cberner cberner merged commit 05c824c into cberner:master Jan 26, 2026
9 checks passed
@cberner
Copy link
Owner

cberner commented Jan 26, 2026

Cool, thanks. Ya, that outline looks good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants