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 75FFA13B29B; Tue, 27 Feb 2024 13:52:03 +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=1709041923; cv=none; b=KpeKkJ4epYXAm2QvBcl7lbH9zIJhY8gf42zsp9z/0fDK7RXQixaRzaSPCh6OiKQbY9VQPaFIa1tvfUxwIFBjoul3f0EOMnFJE+2ffol3YwNgZmNVPmkSReaXu3WCv01b689TQUyM+DwhXgTS6kiux9Sqq6Gly6Oau+OMyHTLnmo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709041923; c=relaxed/simple; bh=WuZgNhYEutUfzvM+sm6RXj51q03hUbuF8hja8zgA6qw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UBgrXu2f6x+3HaZVQDLtgXBISXNLQQ07Tb0LRa/8p1ojp7hxfhcQ1DAgV6o3sKYlhkKQLYbyyS71Yh9vz9jFLrkoolQCD+m/LXNRwyJzTgpM8XwjNaLJm9GV3jDvzkMTBnR3+B8jw2T9iVMQ36USf6ywfV8vKs8TNH3lh/uHHMU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=y76NP9cK; 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="y76NP9cK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06B8AC43390; Tue, 27 Feb 2024 13:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709041923; bh=WuZgNhYEutUfzvM+sm6RXj51q03hUbuF8hja8zgA6qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y76NP9cKLRKgEZyhXIBrWsixeJKNwatjc93GrglIXL2JXToP2QGQ0tFRyyoqdf/Or Tpl453/g3c0rkGLlojjMVqYT6wOJ/daoAT8T6VPiEFq8nYbJlxjmTLVWzkajnpSPwy dLMzbs3Nx/RSe1cXWhokOWXLJ9StfQ2YE33sExvI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yi Sun , Stefan Hajnoczi , Jens Axboe , Sasha Levin Subject: [PATCH 6.6 116/299] virtio-blk: Ensure no requests in virtqueues before deleting vqs. Date: Tue, 27 Feb 2024 14:23:47 +0100 Message-ID: <20240227131629.599588545@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227131625.847743063@linuxfoundation.org> References: <20240227131625.847743063@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yi Sun [ Upstream commit 4ce6e2db00de8103a0687fb0f65fd17124a51aaa ] 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 Reviewed-by: Stefan Hajnoczi Link: https://lore.kernel.org/r/20240129085250.1550594-1-yi.sun@unisoc.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/virtio_blk.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 225c86c74d4e9..41b2fd7e1b9e5 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -1629,14 +1629,15 @@ static int virtblk_freeze(struct virtio_device *vdev) { struct virtio_blk *vblk = vdev->priv; + /* Ensure no requests in virtqueues before deleting vqs. */ + blk_mq_freeze_queue(vblk->disk->queue); + /* Ensure we don't receive any more interrupts */ virtio_reset_device(vdev); /* Make sure no work handler is accessing the device. */ flush_work(&vblk->config_work); - blk_mq_quiesce_queue(vblk->disk->queue); - vdev->config->del_vqs(vdev); kfree(vblk->vqs); @@ -1654,7 +1655,7 @@ static int virtblk_restore(struct virtio_device *vdev) virtio_device_ready(vdev); - blk_mq_unquiesce_queue(vblk->disk->queue); + blk_mq_unfreeze_queue(vblk->disk->queue); return 0; } #endif -- 2.43.0