Skip to content

Commit 3d973b2

Browse files
halil-pasicmstsirkin
authored andcommitted
virtio-blk: improve virtqueue error to BLK_STS
Let's change the mapping between virtqueue_add errors to BLK_STS statuses, so that -ENOSPC, which indicates virtqueue full is still mapped to BLK_STS_DEV_RESOURCE, but -ENOMEM which indicates non-device specific resource outage is mapped to BLK_STS_RESOURCE. Signed-off-by: Halil Pasic <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]>
1 parent f5f6b95 commit 3d973b2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/block/virtio_blk.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,14 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
251251
if (err == -ENOSPC)
252252
blk_mq_stop_hw_queue(hctx);
253253
spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
254-
if (err == -ENOMEM || err == -ENOSPC)
254+
switch (err) {
255+
case -ENOSPC:
255256
return BLK_STS_DEV_RESOURCE;
256-
return BLK_STS_IOERR;
257+
case -ENOMEM:
258+
return BLK_STS_RESOURCE;
259+
default:
260+
return BLK_STS_IOERR;
261+
}
257262
}
258263

259264
if (bd->last && virtqueue_kick_prepare(vblk->vqs[qid].vq))

0 commit comments

Comments
 (0)