From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 538E82AE68; Mon, 30 Dec 2024 15:57:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735574233; cv=none; b=J9f0VebktPRbHzBHROmIom0KFk2/8mGsP1u+LTmZ8aIDWuGNZ56CLsMGRnc/DypJkS7ugE+c3tJhUmIlCkfJQM80TP+CpSecuWHNSqdmN8TuA+BkSmKkXU0UioAgtyuLELDOmhvsdai/aBwNGp4b63WbjPnP7hHMypwCjmqoWe4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735574233; c=relaxed/simple; bh=WIuqn3hKiia+3FQQRFC4h6nBs6kLoNQ63mFbJEC76eY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EN2mV3sikJxo85z+QfYawwt6qRc/YS7XwFwBFlHsWLDQKEGxEVu5n3vHbd4o2iEIfvSkMycVjtghDcydCnxpJIL2Y6SwoWzeCep5Pnr4ugTeE7uqDWBw6U/0bs637IDxiKdjZEVUqQh8Wf1HCU2aUK3Er6hEk+YxnSAZb2bYPoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TQwjTLnW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TQwjTLnW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6213AC4CED0; Mon, 30 Dec 2024 15:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1735574232; bh=WIuqn3hKiia+3FQQRFC4h6nBs6kLoNQ63mFbJEC76eY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TQwjTLnWbY+RQUrvqaHnOAj7MzgdyNWu3GdmphMahp6jdmur2uX3JVuK7uj3kO9tP JDRwXBHNJXyFzKzLyi1tcuf/+ReX56LFIRjNXXGKdtE+q+0B3NTtLHrDixezmuvW3d I+5eZDZzeYZogle6WBnrskeT2xIlzM+bVDtZoBpo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yi Sun , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , virtualization@lists.linux.dev, Marek Szyprowski , Ming Lei , Jens Axboe , Sasha Levin Subject: [PATCH 6.12 075/114] virtio-blk: dont keep queue frozen during system suspend Date: Mon, 30 Dec 2024 16:43:12 +0100 Message-ID: <20241230154220.983328908@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241230154218.044787220@linuxfoundation.org> References: <20241230154218.044787220@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ming Lei [ Upstream commit 7678abee0867e6b7fb89aa40f6e9f575f755fb37 ] Commit 4ce6e2db00de ("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/ca16370e-d646-4eee-b9cc-87277c89c43c@samsung.com/ 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 Cc: Michael S. Tsirkin Cc: Jason Wang Cc: Stefan Hajnoczi Cc: virtualization@lists.linux.dev Reported-by: Marek Szyprowski Signed-off-by: Ming Lei Acked-by: Stefan Hajnoczi Link: https://lore.kernel.org/r/20241112125821.1475793-1-ming.lei@redhat.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/virtio_blk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 43c96b73a711..0e50b65e1dbf 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -1587,9 +1587,12 @@ static void virtblk_remove(struct virtio_device *vdev) static int virtblk_freeze(struct virtio_device *vdev) { struct virtio_blk *vblk = vdev->priv; + struct request_queue *q = vblk->disk->queue; /* Ensure no requests in virtqueues before deleting vqs. */ - blk_mq_freeze_queue(vblk->disk->queue); + blk_mq_freeze_queue(q); + blk_mq_quiesce_queue_nowait(q); + blk_mq_unfreeze_queue(q); /* Ensure we don't receive any more interrupts */ virtio_reset_device(vdev); @@ -1613,8 +1616,8 @@ static int virtblk_restore(struct virtio_device *vdev) return ret; virtio_device_ready(vdev); + blk_mq_unquiesce_queue(vblk->disk->queue); - blk_mq_unfreeze_queue(vblk->disk->queue); return 0; } #endif -- 2.39.5