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 --- 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