> virtio_fs_enqueue_req() drops fsvq->lock when virtqueue_add_sgs() fails
> with -ENOSPC, and the caller requeues the request in a second critical
> section. Completion processing can run in between: it reaps a
> completion, finds queued_reqs empty, and does not schedule dispatch. If
> the queue then goes idle, the request can remain on queued_reqs and keep
> in_flight above zero. A subsequent virtio_fs_drain_queue() can wait
> indefinitely.
>
> On -ENOSPC, add the request to queued_reqs before releasing fsvq->lock,
> as send_forget_request() does. This prevents
> virtio_fs_requests_done_work() from checking queued_reqs between the
> failed submission and the insertion. Both callers can then return
> immediately on -ENOSPC.
>
> Free req->argbuf before adding the request to queued_reqs. Once
> fsvq->lock is released, the dispatch worker may already have taken the
> request, so the -ENOSPC return path must skip any further access to req.
>
> Count the request in in_flight on its first submission. A retry keeps
> the existing count.
>
> Fixes: 106e4df1206b ("virtio-fs: improved request latencies when Virtio queue
> is full")
> Cc: [email protected] # 6.11+
> Link: https://lore.kernel.org/all/[email protected]/
> Signed-off-by: Qihang <[email protected]>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review ยท
https://sashiko.dev/#/patchset/[email protected]?part=1