Skip to content

Commit 7678abe

Browse files
Ming Leiaxboe
authored andcommitted
virtio-blk: don't keep queue frozen during system suspend
Commit 4ce6e2d ("virtio-blk: Ensure no requests in virtqueues before deleting vqs.") replaces queue quiesce with queue freeze in virtio-blk's PM callbacks. And the motivation is to drain inflight IOs before suspending. block layer's queue freeze looks very handy, but it is also easy to cause deadlock, such as, any attempt to call into bio_queue_enter() may run into deadlock if the queue is frozen in current context. There are all kinds of ->suspend() called in suspend context, so keeping queue frozen in the whole suspend context isn't one good idea. And Marek reported lockdep warning[1] caused by virtio-blk's freeze queue in virtblk_freeze(). [1] https://lore.kernel.org/linux-block/[email protected]/ Given the motivation is to drain in-flight IOs, it can be done by calling freeze & unfreeze, meantime restore to previous behavior by keeping queue quiesced during suspend. Cc: Yi Sun <[email protected]> Cc: Michael S. Tsirkin <[email protected]> Cc: Jason Wang <[email protected]> Cc: Stefan Hajnoczi <[email protected]> Cc: [email protected] Reported-by: Marek Szyprowski <[email protected]> Signed-off-by: Ming Lei <[email protected]> Acked-by: Stefan Hajnoczi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent b2e382a commit 7678abe

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/block/virtio_blk.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,9 +1586,12 @@ static void virtblk_remove(struct virtio_device *vdev)
15861586
static int virtblk_freeze(struct virtio_device *vdev)
15871587
{
15881588
struct virtio_blk *vblk = vdev->priv;
1589+
struct request_queue *q = vblk->disk->queue;
15891590

15901591
/* Ensure no requests in virtqueues before deleting vqs. */
1591-
blk_mq_freeze_queue(vblk->disk->queue);
1592+
blk_mq_freeze_queue(q);
1593+
blk_mq_quiesce_queue_nowait(q);
1594+
blk_mq_unfreeze_queue(q);
15921595

15931596
/* Ensure we don't receive any more interrupts */
15941597
virtio_reset_device(vdev);
@@ -1612,8 +1615,8 @@ static int virtblk_restore(struct virtio_device *vdev)
16121615
return ret;
16131616

16141617
virtio_device_ready(vdev);
1618+
blk_mq_unquiesce_queue(vblk->disk->queue);
16151619

1616-
blk_mq_unfreeze_queue(vblk->disk->queue);
16171620
return 0;
16181621
}
16191622
#endif

0 commit comments

Comments
 (0)