From: Bernd Schubert <bernd@bsbernd.com>
To: Yun Wang <arsenova@a7snv.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
Joanne Koong <joannelkoong@gmail.com>,
fuse-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] fuse: don't wait for a sync-init mount in fuse_uring_cmd()
Date: Thu, 19 Nov 2026 15:36:39 +0100 [thread overview]
Message-ID: <7b2d361d-86f1-4064-a905-954a2dfe4ccf@bsbernd.com> (raw)
In-Reply-To: <179509410286.1113694.13152766226405003077@a7snv.com>
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
prev parent reply other threads:[~2026-11-19 14:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b2d361d-86f1-4064-a905-954a2dfe4ccf@bsbernd.com \
--to=bernd@bsbernd.com \
--cc=arsenova@a7snv.com \
--cc=fuse-devel@lists.linux.dev \
--cc=joannelkoong@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®