* Re: [PATCH 2/2] fuse: don't wait for a sync-init mount in fuse_uring_cmd()
2026-11-19 11:36 ` [PATCH 2/2] fuse: don't wait for a sync-init mount in fuse_uring_cmd() Yun Wang
@ 2026-11-17 21:47 ` Bernd Schubert
2026-11-19 13:15 ` Yun Wang
0 siblings, 1 reply; 7+ messages in thread
From: Bernd Schubert @ 2026-11-17 21:47 UTC (permalink / raw)
To: Yun Wang, Miklos Szeredi; +Cc: Joanne Koong, fuse-devel, linux-kernel
On 11/17/26 00:58, Yun Wang wrote:
> 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. This happens before the
> enable_uring check, so also when fuse-over-io-uring is disabled.
>
> Until FUSE_INIT has completed, fuse_uring_cmd() returns -EAGAIN anyway
> and the server has to send the command again later. Return -EAGAIN
> at once when the device is not mounted yet either, using
> fuse_get_dev_nowait() from the previous patch, and don't log "No fuse
> device found" for it.
And what is if io-uring is enabled? Userspace busy loop until the device
is available? I don't think that is nice.
Thanks,
Bernd
>
> Fixes: dfb84c330794 ("fuse: allow synchronous FUSE_INIT")
> Signed-off-by: Yun Wang <arsenova@a7snv.com>
> ---
> 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 460776cd69..0f725172ae 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;
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 0/2] fuse: don't wait for a sync-init mount in non-blocking reads and uring_cmd
@ 2026-11-19 11:35 Yun Wang
2026-11-19 11:36 ` [PATCH 1/2] fuse: don't wait for a sync-init mount in non-blocking reads Yun Wang
2026-11-19 11:36 ` [PATCH 2/2] fuse: don't wait for a sync-init mount in fuse_uring_cmd() Yun Wang
0 siblings, 2 replies; 7+ messages in thread
From: Yun Wang @ 2026-11-19 11:35 UTC (permalink / raw)
Cc: Bernd Schubert, Joanne Koong, fuse-devel, linux-kernel
Since commit dfb84c330794 ("fuse: allow synchronous FUSE_INIT"), a
/dev/fuse fd with FUSE_DEV_IOC_SYNC_INIT waits in fuse_get_dev() until
the mount installs the channel. That suits a blocking read, but
fuse_get_dev() is also called from O_NONBLOCK reads and from
fuse_uring_cmd(), so these sleep before the mount as well, until the
mount or a signal:
- read(2) and splice(2) with O_NONBLOCK.
- IORING_OP_URING_CMD, from the task that called io_uring_enter(2),
also with fuse-over-io-uring disabled. Other submissions on the
same ring wait as well.
It happens on every kernel I tried since v6.18: v6.18 to v7.3 in QEMU,
7.2 and 7.4-rc2 on bare metal. v6.17 has no FUSE_DEV_IOC_SYNC_INIT.
The same wait has caused trouble before. a8dd5f1b73bc ("fuse: create
fuse_dev on /dev/fuse open instead of mount") made fds without sync
init wait there as well, and LTP's read_all, which reads every file
under /dev with O_NONBLOCK, then hung on /dev/fuse [1]. 9f6f44aa5a58
("fuse: don't block in fuse_get_dev() for non-sync_init case") fixed
that by returning -EPERM again for those fds. A sync-init fd still
waits, as dfb84c330794 intends for a blocking read; these two patches
take the wait out of the non-blocking read paths and fuse_uring_cmd()
and keep it for the others.
Patch 1 makes O_NONBLOCK reads before the mount return -EAGAIN, the
same as after the mount while no request is queued. Patch 2 makes
fuse_uring_cmd() return at once the -EAGAIN it returns before FUSE_INIT
anyway. fuse_get_dev() itself is unchanged.
->poll has the same problem: poll(2), epoll_ctl(2) and io_uring reads
of a sync-init fd sleep before the mount too, which is what libfuse's
sync-init worker ran into [2]. That fix is bigger, since a poller that
registers before the mount has no fiq->waitq to wait on, so I will
send it separately, together with a selftest for all of these paths.
Tested in QEMU (virtme-ng) on 7.4-rc2 (067c5c24cef2): with both patches,
O_NONBLOCK read(2) and splice(2) and IORING_OP_URING_CMD on a sync-init
fd that is never mounted return -EAGAIN at once, a blocking read still
waits until a signal, and an fd without sync init still gets -EPERM.
The poll, epoll and mount tests still wait, as expected without the
->poll fix.
The patches are against 7.4-rc2 (067c5c24cef2) and also apply to
fuse.git for-next (ab9787d7e66a). The Fixes tags point at
dfb84c330794 because the wait goes back to v6.18, but the patches only
apply from v7.2 on; older trees would need their own version.
[1] https://lore.kernel.org/all/3c9f8396-41f4-4c88-b883-34bede72b427@sirena.org.uk/
[2] https://github.com/libfuse/libfuse/pull/1633
Yun Wang (2):
fuse: don't wait for a sync-init mount in non-blocking reads
fuse: don't wait for a sync-init mount in fuse_uring_cmd()
fs/fuse/dev.c | 12 ++++++++++--
fs/fuse/dev_uring.c | 10 ++++++++--
fs/fuse/fuse_dev_i.h | 14 ++++++++++++++
3 files changed, 32 insertions(+), 4 deletions(-)
base-commit: 067c5c24cef23d913b67eaaf71ae67e7169a6620
--
2.56.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] fuse: don't wait for a sync-init mount in non-blocking reads
2026-11-19 11:35 [PATCH 0/2] fuse: don't wait for a sync-init mount in non-blocking reads and uring_cmd Yun Wang
@ 2026-11-19 11:36 ` Yun Wang
2026-11-19 11:57 ` Bernd Schubert
2026-11-19 11:36 ` [PATCH 2/2] fuse: don't wait for a sync-init mount in fuse_uring_cmd() Yun Wang
1 sibling, 1 reply; 7+ messages in thread
From: Yun Wang @ 2026-11-19 11:36 UTC (permalink / raw)
Cc: Bernd Schubert, Joanne Koong, fuse-devel, linux-kernel
Since commit dfb84c330794 ("fuse: allow synchronous FUSE_INIT"),
fuse_get_dev() waits until the mount has installed the channel when
FUSE_DEV_IOC_SYNC_INIT was used on the device. fuse_dev_read() and
fuse_dev_splice_read() call it before fuse_dev_do_read() looks at
O_NONBLOCK, so read(2) or splice(2) on an O_NONBLOCK sync-init device
that is not mounted yet sleeps until the mount or a signal, instead of
returning -EAGAIN. Commit 9f6f44aa5a58 ("fuse: don't block in
fuse_get_dev() for non-sync_init case") fixed the same hang for
devices without sync init, which LTP's read_all hit with O_NONBLOCK
reads of /dev/fuse.
Add fuse_get_dev_nowait(), which returns -EAGAIN instead of waiting for
the mount, and fuse_get_dev_read(), which uses it for O_NONBLOCK files,
and call the latter from fuse_dev_read() and fuse_dev_splice_read().
fuse_get_dev() is unchanged and keeps waiting for its other callers.
A non-blocking read before the mount now gets -EAGAIN, the same as
after the mount while no request is queued. Blocking reads still wait
for the mount.
Fixes: dfb84c330794 ("fuse: allow synchronous FUSE_INIT")
Signed-off-by: Yun Wang <arsenova@a7snv.com>
---
fs/fuse/dev.c | 12 ++++++++++--
fs/fuse/fuse_dev_i.h | 14 ++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 3641abb90d..23ba4f432d 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1705,11 +1705,19 @@ struct fuse_dev *fuse_get_dev(struct file *file)
return fud;
}
+/* read(2) and splice(2) of an O_NONBLOCK device don't wait for the mount */
+static struct fuse_dev *fuse_get_dev_read(struct file *file)
+{
+ if (file->f_flags & O_NONBLOCK)
+ return fuse_get_dev_nowait(file);
+ return fuse_get_dev(file);
+}
+
static ssize_t fuse_dev_read(struct kiocb *iocb, struct iov_iter *to)
{
struct fuse_copy_state cs;
struct file *file = iocb->ki_filp;
- struct fuse_dev *fud = fuse_get_dev(file);
+ struct fuse_dev *fud = fuse_get_dev_read(file);
if (IS_ERR(fud))
return PTR_ERR(fud);
@@ -1730,7 +1738,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
int page_nr = 0;
struct pipe_buffer *bufs;
struct fuse_copy_state cs;
- struct fuse_dev *fud = fuse_get_dev(in);
+ struct fuse_dev *fud = fuse_get_dev_read(in);
if (IS_ERR(fud))
return PTR_ERR(fud);
diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h
index 4b412a7622..bb7e10656a 100644
--- a/fs/fuse/fuse_dev_i.h
+++ b/fs/fuse/fuse_dev_i.h
@@ -367,6 +367,20 @@ static inline struct fuse_dev *__fuse_get_dev(struct file *file)
return fud;
}
+/*
+ * Like fuse_get_dev(), but don't wait for the mount of a sync-init device:
+ * return -EAGAIN instead.
+ */
+static inline struct fuse_dev *fuse_get_dev_nowait(struct file *file)
+{
+ struct fuse_dev *fud = fuse_file_to_fud(file);
+
+ if (unlikely(!fuse_dev_chan_get(fud)))
+ return ERR_PTR(fud->sync_init ? -EAGAIN : -EPERM);
+
+ return fud;
+}
+
void fuse_iqueue_init(struct fuse_iqueue *fiq, const struct fuse_iqueue_ops *ops, void *priv);
struct fuse_dev *fuse_get_dev(struct file *file);
--
2.56.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] fuse: don't wait for a sync-init mount in fuse_uring_cmd()
2026-11-19 11:35 [PATCH 0/2] fuse: don't wait for a sync-init mount in non-blocking reads and uring_cmd Yun Wang
2026-11-19 11:36 ` [PATCH 1/2] fuse: don't wait for a sync-init mount in non-blocking reads Yun Wang
@ 2026-11-19 11:36 ` Yun Wang
2026-11-17 21:47 ` Bernd Schubert
1 sibling, 1 reply; 7+ messages in thread
From: Yun Wang @ 2026-11-19 11:36 UTC (permalink / raw)
Cc: Bernd Schubert, Joanne Koong, fuse-devel, linux-kernel
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. This happens before the
enable_uring check, so also when fuse-over-io-uring is disabled.
Until FUSE_INIT has completed, fuse_uring_cmd() returns -EAGAIN anyway
and the server has to send the command again later. Return -EAGAIN
at once when the device is not mounted yet either, using
fuse_get_dev_nowait() from the previous patch, and don't log "No fuse
device found" for it.
Fixes: dfb84c330794 ("fuse: allow synchronous FUSE_INIT")
Signed-off-by: Yun Wang <arsenova@a7snv.com>
---
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 460776cd69..0f725172ae 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] fuse: don't wait for a sync-init mount in non-blocking reads
2026-11-19 11:36 ` [PATCH 1/2] fuse: don't wait for a sync-init mount in non-blocking reads Yun Wang
@ 2026-11-19 11:57 ` Bernd Schubert
0 siblings, 0 replies; 7+ messages in thread
From: Bernd Schubert @ 2026-11-19 11:57 UTC (permalink / raw)
To: Yun Wang; +Cc: Joanne Koong, fuse-devel, linux-kernel
On 11/19/26 12:36, Yun Wang wrote:
> Since commit dfb84c330794 ("fuse: allow synchronous FUSE_INIT"),
> fuse_get_dev() waits until the mount has installed the channel when
> FUSE_DEV_IOC_SYNC_INIT was used on the device. fuse_dev_read() and
> fuse_dev_splice_read() call it before fuse_dev_do_read() looks at
> O_NONBLOCK, so read(2) or splice(2) on an O_NONBLOCK sync-init device
> that is not mounted yet sleeps until the mount or a signal, instead of
> returning -EAGAIN. Commit 9f6f44aa5a58 ("fuse: don't block in
> fuse_get_dev() for non-sync_init case") fixed the same hang for
> devices without sync init, which LTP's read_all hit with O_NONBLOCK
> reads of /dev/fuse.
>
> Add fuse_get_dev_nowait(), which returns -EAGAIN instead of waiting for
> the mount, and fuse_get_dev_read(), which uses it for O_NONBLOCK files,
> and call the latter from fuse_dev_read() and fuse_dev_splice_read().
> fuse_get_dev() is unchanged and keeps waiting for its other callers.
>
> A non-blocking read before the mount now gets -EAGAIN, the same as
> after the mount while no request is queued. Blocking reads still wait
> for the mount.
>
> Fixes: dfb84c330794 ("fuse: allow synchronous FUSE_INIT")
> Signed-off-by: Yun Wang <arsenova@a7snv.com>
> ---
> fs/fuse/dev.c | 12 ++++++++++--
> fs/fuse/fuse_dev_i.h | 14 ++++++++++++++
> 2 files changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index 3641abb90d..23ba4f432d 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -1705,11 +1705,19 @@ struct fuse_dev *fuse_get_dev(struct file *file)
> return fud;
> }
>
> +/* read(2) and splice(2) of an O_NONBLOCK device don't wait for the mount */
> +static struct fuse_dev *fuse_get_dev_read(struct file *file)
> +{
> + if (file->f_flags & O_NONBLOCK)
> + return fuse_get_dev_nowait(file);
> + return fuse_get_dev(file);
> +}
> +
This is just a style comment, for me "fuse_get_dev_read" sounds weird.
Maybe call this fuse_get_dev() and rename the other to _fuse_get_dev()?
And both could be in the header file?
> static ssize_t fuse_dev_read(struct kiocb *iocb, struct iov_iter *to)
> {
> struct fuse_copy_state cs;
> struct file *file = iocb->ki_filp;
> - struct fuse_dev *fud = fuse_get_dev(file);
> + struct fuse_dev *fud = fuse_get_dev_read(file);
>
> if (IS_ERR(fud))
> return PTR_ERR(fud);
> @@ -1730,7 +1738,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
> int page_nr = 0;
> struct pipe_buffer *bufs;
> struct fuse_copy_state cs;
> - struct fuse_dev *fud = fuse_get_dev(in);
> + struct fuse_dev *fud = fuse_get_dev_read(in);
>
> if (IS_ERR(fud))
> return PTR_ERR(fud);
> diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h
> index 4b412a7622..bb7e10656a 100644
> --- a/fs/fuse/fuse_dev_i.h
> +++ b/fs/fuse/fuse_dev_i.h
> @@ -367,6 +367,20 @@ static inline struct fuse_dev *__fuse_get_dev(struct file *file)
> return fud;
> }
>
> +/*
> + * Like fuse_get_dev(), but don't wait for the mount of a sync-init device:
> + * return -EAGAIN instead.
> + */
> +static inline struct fuse_dev *fuse_get_dev_nowait(struct file *file)
> +{
> + struct fuse_dev *fud = fuse_file_to_fud(file);
> +
> + if (unlikely(!fuse_dev_chan_get(fud)))
> + return ERR_PTR(fud->sync_init ? -EAGAIN : -EPERM);
> +
> + return fud;
> +}
> +
> void fuse_iqueue_init(struct fuse_iqueue *fiq, const struct fuse_iqueue_ops *ops, void *priv);
>
> struct fuse_dev *fuse_get_dev(struct file *file);
Besides of pure style comment (and Miklos might have a different
preference), looks good to me.
Reviewed-by: Bernd Schubert <bernd@bsbernd.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] fuse: don't wait for a sync-init mount in fuse_uring_cmd()
2026-11-17 21:47 ` Bernd Schubert
@ 2026-11-19 13:15 ` Yun Wang
2026-11-19 14:36 ` Bernd Schubert
0 siblings, 1 reply; 7+ messages in thread
From: Yun Wang @ 2026-11-19 13:15 UTC (permalink / raw)
To: Bernd Schubert; +Cc: Miklos Szeredi, Joanne Koong, fuse-devel, linux-kernel
On 11/17/26 22:47, Bernd Schubert wrote:
> On 11/17/26 00:58, Yun Wang wrote:
>> Until FUSE_INIT has completed, fuse_uring_cmd() returns -EAGAIN anyway
>> and the server has to send the command again later. Return -EAGAIN
>> at once when the device is not mounted yet either, using
>> fuse_get_dev_nowait() from the previous patch, and don't log "No fuse
>> device found" for it.
>
> And what is if io-uring is enabled? Userspace busy loop until the device
> is available? I don't think that is nice.
I understand the concern: -EAGAIN doesn't tell userspace when to try
again, so a server can only retry blindly.
But that isn't new with this patch. On an async-init connection,
mainline already returns -EAGAIN for a REGISTER sent after mount(2)
has returned but before FUSE_INIT has been answered. On 7.4-rc2, with
a test server that answers FUSE_INIT 300 ms late and resubmits on every
-EAGAIN right away, as libfuse's fuse_uring_resubmit() does, the
REGISTER was resubmitted about 50000 times in those 300 ms. The patch
applies the same rule to a sync-init device before the mount.
It does change one thing that the changelog leaves out. It says the
command gets -EAGAIN anyway until FUSE_INIT has completed, which
suggests the wait gained nothing. But after the mount wakes it up, it
can still get past the initialized check: FUSE_INIT may have been
answered by the time the woken task gets there, and if not, io_uring
retries the command from io-wq after the -EAGAIN, which may be late
enough. On a sync-init device without the patch, 12 of 20 REGISTERs
sent before the mount got past the check (6 in the woken task, 6 in
the io-wq retry). With the patch it is -EAGAIN every time and nothing
sleeps, so the old behavior was timing-dependent rather than a
reliable wait. I'll fix the changelog in v2.
libfuse isn't affected either way: it sends REGISTER only after the
connection is initialized, with both sync and async init. I ran
passthrough_ll -o io_uring on 7.4-rc2 with and without the patches and
counted what fuse_uring_cmd() returned: never -EAGAIN. What the patch
fixes is the submitting task sleeping in io_uring_enter(2) until the
mount or a signal, which also holds up everything else that task
submits in the meantime.
The retry could wait in io-wq instead (I have that working), but
uring_cmd work runs on bounded io-wq workers, and each early REGISTER
would hold one until FUSE_INIT. A server registers a whole queue's
entries at once, so that can use up the submitting task's bounded
workers and hold up its other punted work. With 4 CPUs (a default
limit of 16), 16 early REGISTERs were enough to hold a NOP sent with
IOSQE_ASYNC by the same task until the mount; with 15 it completed at
once. I don't think that is a good design. Queueing early REGISTERs
and handling them once the connection is initialized might avoid this,
but that is only an idea, I haven't tried it, and it would be a bigger
change.
Would you prefer to keep -EAGAIN as in this patch, or should we look
for a different approach that covers both the sync and the async init
case?
Thanks,
Yun
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] fuse: don't wait for a sync-init mount in fuse_uring_cmd()
2026-11-19 13:15 ` Yun Wang
@ 2026-11-19 14:36 ` Bernd Schubert
0 siblings, 0 replies; 7+ messages in thread
From: Bernd Schubert @ 2026-11-19 14:36 UTC (permalink / raw)
To: Yun Wang; +Cc: Miklos Szeredi, Joanne Koong, fuse-devel, linux-kernel
On 11/19/26 14:15, Yun Wang wrote:
> On 11/17/26 22:47, Bernd Schubert wrote:
>> On 11/17/26 00:58, Yun Wang wrote:
>>> Until FUSE_INIT has completed, fuse_uring_cmd() returns -EAGAIN anyway
>>> and the server has to send the command again later. Return -EAGAIN
>>> at once when the device is not mounted yet either, using
>>> fuse_get_dev_nowait() from the previous patch, and don't log "No fuse
>>> device found" for it.
>>
>> And what is if io-uring is enabled? Userspace busy loop until the device
>> is available? I don't think that is nice.
>
> I understand the concern: -EAGAIN doesn't tell userspace when to try
> again, so a server can only retry blindly.
>
> But that isn't new with this patch. On an async-init connection,
> mainline already returns -EAGAIN for a REGISTER sent after mount(2)
> has returned but before FUSE_INIT has been answered. On 7.4-rc2, with
> a test server that answers FUSE_INIT 300 ms late and resubmits on every
> -EAGAIN right away, as libfuse's fuse_uring_resubmit() does, the
> REGISTER was resubmitted about 50000 times in those 300 ms. The patch
> applies the same rule to a sync-init device before the mount.
I think only with an old version of libfuse that was sending REGISTER
before FUSE_INIT was processed. That was the reason I had added the
-EAGAIN handler into libfuse.
At about the same time I had also ensured that REGISTER is only send
after FUSE_INIT reply. FUSE_INIT reply is submitted via write() to
/dev/fuse, i.e. it is a blocking process.
In _do_init() in libfuse
```
/* XXX: Add an option to make non-available io-uring fatal */
if (enable_io_uring) {
ring_rc = fuse_uring_start(se);
...
/*
* 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.
*/
WRITE_ONCE(se->got_init, 1);
fuse_daemonize_set_got_init();
send_reply_ok(req, &outarg, outargsize);
/*
* With async init, send_reply_ok() has already marked the connection
* initialized (that happens in the reply write()), so the ring threads
* can send REGISTER now. With sync init, _do_init() runs on the
* sync-init worker thread while the mount is still in progress. The
* connection is not initialized until the mount completes, which is
* after _do_init() returns. Waking the ring threads here would let
* REGISTER race ahead of initialization and get -EAGAIN, so defer the
* wake to fuse_session_mount_new_api() after the mount returns.
*/
if (enable_io_uring && !se->is_sync_init)
fuse_uring_wake_ring_threads(se);
```
I.e. it does fuse_uring_start() before FUSE_INIT reply, but that just
creates the ring threads and let's them sleep in a semaphone.
FUSE_IO_URING_CMD_REGISTER is send after fuse_init(), once
fuse_uring_wake_ring_threads() let's the ring thread move forward.
> > It does change one thing that the changelog leaves out. It says the
> command gets -EAGAIN anyway until FUSE_INIT has completed, which
> suggests the wait gained nothing. But after the mount wakes it up, it
> can still get past the initialized check: FUSE_INIT may have been
> answered by the time the woken task gets there, and if not, io_uring
> retries the command from io-wq after the -EAGAIN, which may be late
> enough. On a sync-init device without the patch, 12 of 20 REGISTERs
> sent before the mount got past the check (6 in the woken task, 6 in
> the io-wq retry). With the patch it is -EAGAIN every time and nothing
> sleeps, so the old behavior was timing-dependent rather than a
> reliable wait. I'll fix the changelog in v2.
>
> libfuse isn't affected either way: it sends REGISTER only after the
> connection is initialized, with both sync and async init. I ran
> passthrough_ll -o io_uring on 7.4-rc2 with and without the patches and
> counted what fuse_uring_cmd() returned: never -EAGAIN. What the patch
> fixes is the submitting task sleeping in io_uring_enter(2) until the
> mount or a signal, which also holds up everything else that task
> submits in the meantime.
Well, if libfuse isn't affect, why is this patch needed? If you have
another fuse server, fix your fuse server? (And it confirms my personal
opinion that we should aim for one userspace library.)
>
> The retry could wait in io-wq instead (I have that working), but
> uring_cmd work runs on bounded io-wq workers, and each early REGISTER
> would hold one until FUSE_INIT. A server registers a whole queue's
> entries at once, so that can use up the submitting task's bounded
> workers and hold up its other punted work. With 4 CPUs (a default
> limit of 16), 16 early REGISTERs were enough to hold a NOP sent with
> IOSQE_ASYNC by the same task until the mount; with 15 it completed at
> once. I don't think that is a good design. Queueing early REGISTERs
> and handling them once the connection is initialized might avoid this,
> but that is only an idea, I haven't tried it, and it would be a bigger
> change.
>
> Would you prefer to keep -EAGAIN as in this patch, or should we look
> for a different approach that covers both the sync and the async init
> case?
See above about my question about libfuse not being affected.
Thanks,
Bernd
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-19 14:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 11:35 [PATCH 0/2] fuse: don't wait for a sync-init mount in non-blocking reads and uring_cmd Yun Wang
2026-11-19 11:36 ` [PATCH 1/2] fuse: don't wait for a sync-init mount in non-blocking reads Yun Wang
2026-11-19 11:57 ` Bernd Schubert
2026-11-19 11:36 ` [PATCH 2/2] fuse: don't wait for a sync-init mount in fuse_uring_cmd() Yun Wang
2026-11-17 21:47 ` Bernd Schubert
2026-11-19 13:15 ` Yun Wang
2026-11-19 14:36 ` Bernd Schubert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®