* [PATCH] virtiofs: fix potential unmount or device removal hang due to stuck FORGETs
@ 2026-11-23 9:54 Li Wang
2026-11-23 10:00 ` sashiko-bot
2026-11-24 11:13 ` Miklos Szeredi
0 siblings, 2 replies; 3+ messages in thread
From: Li Wang @ 2026-11-23 9:54 UTC (permalink / raw)
To: Miklos Szeredi, German Maglione, Vivek Goyal, Stefan Hajnoczi
Cc: Eugenio Pérez, Michael S . Tsirkin, fuse-devel,
virtualization, linux-fsdevel, virtio-fs, Li Wang, stable
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] virtiofs: fix potential unmount or device removal hang due to stuck FORGETs
2026-11-23 9:54 [PATCH] virtiofs: fix potential unmount or device removal hang due to stuck FORGETs Li Wang
@ 2026-11-23 10:00 ` sashiko-bot
2026-11-24 11:13 ` Miklos Szeredi
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-23 10:00 UTC (permalink / raw)
To: Li Wang; +Cc: virtualization, Michael S. Tsirkin, Eugenio Perez
> 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
> [ ... ]
> 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>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123095455.88622-1-liwang@kylinos.cn?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] virtiofs: fix potential unmount or device removal hang due to stuck FORGETs
2026-11-23 9:54 [PATCH] virtiofs: fix potential unmount or device removal hang due to stuck FORGETs Li Wang
2026-11-23 10:00 ` sashiko-bot
@ 2026-11-24 11:13 ` Miklos Szeredi
1 sibling, 0 replies; 3+ messages in thread
From: Miklos Szeredi @ 2026-11-24 11:13 UTC (permalink / raw)
To: Li Wang
Cc: German Maglione, Vivek Goyal, Stefan Hajnoczi, Eugenio Pérez,
Michael S . Tsirkin, fuse-devel, virtualization, linux-fsdevel,
virtio-fs, stable
On Mon, 23 Nov 2026 at 10:55, Li Wang <liwang@kylinos.cn> wrote:
> 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.
Applied, thanks.
Miklos
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-24 11:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 9:54 [PATCH] virtiofs: fix potential unmount or device removal hang due to stuck FORGETs Li Wang
2026-11-23 10:00 ` sashiko-bot
2026-11-24 11:13 ` Miklos Szeredi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox