Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

virtio-blk: Ensure no requests in virtqueues before deleting vqs.

Ensure no remaining requests in virtqueues before resetting vdev and
deleting virtqueues. Otherwise these requests will never be completed.
It may cause the system to become unresponsive.

Function blk_mq_quiesce_queue() can ensure that requests have become
in_flight status, but it cannot guarantee that requests have been
processed by the device. Virtqueues should never be deleted before
all requests become complete status.

Function blk_mq_freeze_queue() ensure that all requests in virtqueues
become complete status. And no requests can enter in virtqueues.

Signed-off-by: Yi Sun <yi.sun@unisoc.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Link: https://lore.kernel.org/r/20240129085250.1550594-1-yi.sun@unisoc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Yi Sun and committed by
Jens Axboe
4ce6e2db 2a427b49

+4 -3
+4 -3
drivers/block/virtio_blk.c
··· 1593 1593 { 1594 1594 struct virtio_blk *vblk = vdev->priv; 1595 1595 1596 + /* Ensure no requests in virtqueues before deleting vqs. */ 1597 + blk_mq_freeze_queue(vblk->disk->queue); 1598 + 1596 1599 /* Ensure we don't receive any more interrupts */ 1597 1600 virtio_reset_device(vdev); 1598 1601 1599 1602 /* Make sure no work handler is accessing the device. */ 1600 1603 flush_work(&vblk->config_work); 1601 - 1602 - blk_mq_quiesce_queue(vblk->disk->queue); 1603 1604 1604 1605 vdev->config->del_vqs(vdev); 1605 1606 kfree(vblk->vqs); ··· 1619 1618 1620 1619 virtio_device_ready(vdev); 1621 1620 1622 - blk_mq_unquiesce_queue(vblk->disk->queue); 1621 + blk_mq_unfreeze_queue(vblk->disk->queue); 1623 1622 return 0; 1624 1623 } 1625 1624 #endif