mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yun Wang <arsenova@a7snv.com>
Cc: Bernd Schubert <bernd@bsbernd.com>,
	Joanne Koong <joannelkoong@gmail.com>,
	fuse-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] fuse: don't wait for a sync-init mount in non-blocking reads and uring_cmd
Date: Thu, 19 Nov 2026 11:35:50 +0000	[thread overview]
Message-ID: <20261117075632.59959.p12-0-arsenova@a7snv.com> (raw)

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





             reply	other threads:[~2026-11-19 11:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 11:35 Yun Wang [this message]
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 23:07     ` 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
2026-11-17 21:47   ` Bernd Schubert
2026-11-19 13:15     ` Yun Wang
2026-11-19 14:36       ` Bernd Schubert
2026-11-19 23:03         ` Yun Wang

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=20261117075632.59959.p12-0-arsenova@a7snv.com \
    --to=arsenova@a7snv.com \
    --cc=bernd@bsbernd.com \
    --cc=fuse-devel@lists.linux.dev \
    --cc=joannelkoong@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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®