[PATCH v2 3/5] fuse: don't wait for a sync-init mount in fuse_uring_cmd()

From: Yun Wang

Date: Sun Nov 22 2026 - 10:26:56 EST


From: Yun Wang <arsenova@xxxxxxxxx>

fuse_uring_cmd() gets the device with _fuse_get_dev(), which waits for
the mount of a device in sync-init mode. io_uring normally issues the
command from the task that called io_uring_enter(2), so an
IORING_OP_URING_CMD on such a device before the mount puts that task
to sleep until the mount or a signal, with the ring's uring_lock held:
any other thread that submits to the same ring waits for it in D state
meanwhile. This happens before the enable_uring check, so also when
fuse-over-io-uring is disabled.

Once the mount has woken it up, the command can still get past the
initialized check: FUSE_INIT may have been answered by then, or else
io_uring retries it from io-wq after the -EAGAIN, which may be late
enough. So a REGISTER sent before the mount sometimes went through,
but only by timing. A server has to handle -EAGAIN here anyway, as it
does for a REGISTER sent before FUSE_INIT has been answered on an
async-init connection, and libfuse only sends REGISTER once the
connection is initialized.

Return -EAGAIN at once when the device is not mounted yet either, using
fuse_get_dev_nowait() from the previous patch, as fuse_uring_cmd()
already does until FUSE_INIT has completed, and don't log "No fuse
device found" for it.

Fixes: dfb84c330794 ("fuse: allow synchronous FUSE_INIT")
Signed-off-by: Yun Wang <arsenova@xxxxxxxxx>
---
fs/fuse/dev_uring.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
index 92240ab76e45..0f725172ae6e 100644
--- a/fs/fuse/dev_uring.c
+++ b/fs/fuse/dev_uring.c
@@ -1664,9 +1664,15 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
if (!(issue_flags & IO_URING_F_SQE128))
return -EINVAL;

- fud = _fuse_get_dev(cmd->file);
+ /*
+ * Don't wait for the mount of a sync-init device: this may run in
+ * the task that called io_uring_enter(), and the ring can't be
+ * registered before FUSE_INIT anyway, see the -EAGAIN below.
+ */
+ fud = fuse_get_dev_nowait(cmd->file);
if (IS_ERR(fud)) {
- pr_info_ratelimited("No fuse device found\n");
+ if (PTR_ERR(fud) != -EAGAIN)
+ pr_info_ratelimited("No fuse device found\n");
return PTR_ERR(fud);
}
fch = fud->chan;
--
2.56.1