Linux virtualization list
 help / color / mirror / Atom feed
From: Li Wang <liwang@kylinos.cn>
To: Miklos Szeredi <miklos@szeredi.hu>,
	German Maglione <gmaglione@redhat.com>,
	Vivek Goyal <vgoyal@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Cc: "Eugenio Pérez" <eperezma@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	fuse-devel@lists.linux.dev, virtualization@lists.linux.dev,
	linux-fsdevel@vger.kernel.org, virtio-fs@lists.linux.dev,
	"Li Wang" <liwang@kylinos.cn>,
	stable@vger.kernel.org
Subject: [PATCH] virtiofs: fix potential unmount or device removal hang due to stuck FORGETs
Date: Mon, 23 Nov 2026 17:54:55 +0800	[thread overview]
Message-ID: <20261123095455.88622-1-liwang@kylinos.cn> (raw)

virtqueue_add_outbuf() returns -ENOSPC when the virtqueue is full.  On
this path it can also return -ENOMEM, when a split-ring DMA mapping
fails, or -EIO, when the virtqueue is broken or a packed-ring mapping
fails.  send_forget_request() turns only -ENOSPC into 1, so
virtio_fs_hiprio_dispatch_work() stops and waits for a completion.  Any
other error frees that FORGET and drops its in_flight count, then
returns the negative errno.  The worker treats every non-zero return as
a reason to stop, so the rest of queued_reqs is left unexamined.

hiprio dispatch_work is scheduled only from
virtio_fs_hiprio_done_work(), which runs from that virtqueue interrupt.
Once no descriptor is outstanding, the device raises no interrupt and
nothing walks the list.  virtio_fs_send_forget() submits a new FORGET
directly and does not schedule the worker.  The queued entries are
reached again only if that new FORGET is placed on the virtqueue and
the device completes it.  A new FORGET that itself gets -ENOSPC,
-ENOMEM or -EIO does not schedule dispatch_work.

-EIO stays -EIO for every later add.  New FORGETs never enter the ring,
so they never produce the completion that would run the worker.
Entries already queued still hold in_flight.  virtio_fs_drain_queue()
waits for in_flight to reach zero before it flushes dispatch_work, and
unmount or device removal hangs.  -ENOMEM can succeed on a later
attempt, but with an empty ring the same entries wait until some later
FORGET both enters the ring and completes.  Each such completion
retries only the head of the list and stops again when that head fails.

After the FORGET is dropped, return 0 so this same worker invocation
continues with the rest of queued_reqs.  A full queue still returns 1.

Fixes: a62a8ef9d97d ("virtio-fs: add virtiofs filesystem")
Cc: stable@vger.kernel.org
Signed-off-by: Li Wang <liwang@kylinos.cn>
---
 fs/fuse/virtio_fs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index d247a02cdca9..d2d1e8fe3a91 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -655,6 +655,8 @@ static int send_forget_request(struct virtio_fs_vq *fsvq,
 			kfree(forget);
 			if (in_flight)
 				dec_in_flight_req(fsvq);
+			/* Dropped.  Let the worker keep going. */
+			ret = 0;
 		}
 		goto out;
 	}
-- 
2.34.1


             reply	other threads:[~2026-11-23  9:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  9:54 Li Wang [this message]
2026-11-23 10:00 ` [PATCH] virtiofs: fix potential unmount or device removal hang due to stuck FORGETs sashiko-bot
2026-11-24 11:13 ` Miklos Szeredi

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=20261123095455.88622-1-liwang@kylinos.cn \
    --to=liwang@kylinos.cn \
    --cc=eperezma@redhat.com \
    --cc=fuse-devel@lists.linux.dev \
    --cc=gmaglione@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=mst@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=stefanha@redhat.com \
    --cc=vgoyal@redhat.com \
    --cc=virtio-fs@lists.linux.dev \
    --cc=virtualization@lists.linux.dev \
    /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