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 E0112145A03; Mon, 6 Jan 2025 15:52:41 +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=1736178762; cv=none; b=nlfdxaYdWhkhc8asQp9+XVHWD4ywhuDITgojjT2zwaNdtlOHICVyR90dPTnJSHL4Y1mLVEiPaeaAL0Cu1cShha8Nm0FWQGXsAv9Ln/fVTHMbqP0RY/FacNnbRnzItEZSIyLgq36ICFLzwY/a84zGyPCysyfHcDb/bae7rAgqzMg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736178762; c=relaxed/simple; bh=TiXxgUaFckb5egeaqCd8OizG2jG+JQGWUxXb6RUpqpU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tCpRlr1B4FwzRCNFhGDrmq8TsCAtA7JRrYijPQkx4zeL+mSRSw5YjtyQ6ImhmRSREla26TJIqJ1WgZdA3LjUyrvp7MieUIDkJHbTuzB+YAmifa5OK0LplCEVwuZArJUf5m3U9QPHUol4IajiesFM2NxLR/kOAq6IknKjanQmkrw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0a62vSsW; 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="0a62vSsW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61DEAC4CED2; Mon, 6 Jan 2025 15:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1736178761; bh=TiXxgUaFckb5egeaqCd8OizG2jG+JQGWUxXb6RUpqpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0a62vSsW2NWetnXlMg7CcFvjatutdjEelsPN4jNdtmhg7Lw+fQCML5znp4aOIkmWN oqvDxtjY/T0wgfsIWiNZjDPtU77f64sJCNZIALUwt/g1xaD84+ojgMlnYFt/bI5eva NJcCluszWMWEPP5LCM3VlPykaPdOEdiE8Phg+T6E= 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 5.15 084/168] virtio-blk: dont keep queue frozen during system suspend Date: Mon, 6 Jan 2025 16:16:32 +0100 Message-ID: <20250106151141.636375230@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106151138.451846855@linuxfoundation.org> References: <20250106151138.451846855@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 5.15-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 7f73e7447ecb..c1087dfa332e 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -988,9 +988,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 */ vdev->config->reset(vdev); @@ -1014,8 +1017,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