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

From: Yun Wang

Date: Thu Nov 19 2026 - 08:15:47 EST


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