Skip to content

Commit f5f6b95

Browse files
halil-pasicmstsirkin
authored andcommitted
virtio-blk: fix hw_queue stopped on arbitrary error
Since nobody else is going to restart our hw_queue for us, the blk_mq_start_stopped_hw_queues() is in virtblk_done() is not sufficient necessarily sufficient to ensure that the queue will get started again. In case of global resource outage (-ENOMEM because mapping failure, because of swiotlb full) our virtqueue may be empty and we can get stuck with a stopped hw_queue. Let us not stop the queue on arbitrary errors, but only on -EONSPC which indicates a full virtqueue, where the hw_queue is guaranteed to get started by virtblk_done() before when it makes sense to carry on submitting requests. Let us also remove a stale comment. Signed-off-by: Halil Pasic <[email protected]> Cc: Jens Axboe <[email protected]> Fixes: f772800 ("virtio_ring: fix return code on DMA mapping fails") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]>
1 parent f13f09a commit f5f6b95

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/block/virtio_blk.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,12 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
245245
err = virtblk_add_req(vblk->vqs[qid].vq, vbr, vbr->sg, num);
246246
if (err) {
247247
virtqueue_kick(vblk->vqs[qid].vq);
248-
blk_mq_stop_hw_queue(hctx);
248+
/* Don't stop the queue if -ENOMEM: we may have failed to
249+
* bounce the buffer due to global resource outage.
250+
*/
251+
if (err == -ENOSPC)
252+
blk_mq_stop_hw_queue(hctx);
249253
spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
250-
/* Out of mem doesn't actually happen, since we fall back
251-
* to direct descriptors */
252254
if (err == -ENOMEM || err == -ENOSPC)
253255
return BLK_STS_DEV_RESOURCE;
254256
return BLK_STS_IOERR;

0 commit comments

Comments
 (0)