From 59cf26a2d778b88819db528c67141b788a8b48a1 Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Mon, 22 Sep 2025 10:46:46 +0200 Subject: FUSE_INIT handler: Set got_init only shortly before send_reply_ok A previous commit added single thread behavior as long as se->got_init is not set, especially as buffer allocation should be done after got_init only. Technically it should not make a difference in current libfuse design, as more worker threads are only allocated after the FUSE_INIT handler is completely done. That might at some point change, though. In general it is cleaner to set se->got_init, when the init handler is done. Done as separate commit, as this introduces a slight risk to break something - backport to older version should be done carefully. Signed-off-by: Bernd Schubert --- lib/fuse_lowlevel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index cacab94..a1a1427 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -2799,7 +2799,6 @@ _do_init(fuse_req_t req, const fuse_ino_t nodeid, const void *op_in, se->conn.time_gran = 1; - se->got_init = 1; if (se->op.init) { // Apply the first 32 bits of capable_ext to capable se->conn.capable = fuse_lower_32_bits(se->conn.capable_ext); @@ -2970,6 +2969,13 @@ _do_init(fuse_req_t req, const fuse_ino_t nodeid, const void *op_in, } } + /* + * Has to be set before replying, as new kernel requests might + * immediately arrive and got_init is used for op-code sanity. + * Especially with external handlers, where we have no control + * over the thread scheduling. + */ + se->got_init = 1; send_reply_ok(req, &outarg, outargsize); if (enable_io_uring) fuse_uring_wake_ring_threads(se); -- cgit v1.2.3