FAILED: patch "[PATCH] xen-blkfront: Fix IO race during unplug" failed to apply to 6.1-stable tree
Subsystems (4)
Sasha Levin
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 61b6d1df1d6234c38a6ea7e4f58e7da035ef6ab4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 61b6d1df1d6234c38a6ea7e4f58e7da035ef6ab4 Mon Sep 17 00:00:00 2001
From: Ross Lagerwall <[email protected]>
Date: Tue, 6 Oct 2026 17:34:07 +0100
Subject: [PATCH] xen-blkfront: Fix IO race during unplug
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
During unplug, blkfront stops the hw queues and marks the disk as dead, then later during removal calls del_gendisk(). However, IO issued after the hw queues are stopped but before the call to del_gendisk() will be queued but never handled. This causes del_gendisk() to hang forever waiting for the queue refcount to drop to zero.
This can be reproduced by issuing IO during an artificial delay after stopping the hw queues.
Fix this by simply not stopping the hw queues directly. Marking the disk as dead already freezes the queue which prevents new requests being added and it synchronously runs the hw queues to clear anything pending. If the hw queues are stopped when calling blk_mark_disk_dead(), running the hw queues is a no-op and can leave queued requests unprocessed.
Message-ID: <[email protected]>
--- drivers/block/xen-blkfront.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/block/xen-blkfront.c +1 -3
@@ -2142,10 +2142,8 @@ static void blkfront_closing(struct blkfront_info *info)return ;/* No more blkif_request(). */ -if (info->rq && info->gd) { -blk_mq_stop_hw_queues (info->rq); +if (info->gd)blk_mark_disk_dead (info->gd); - }for_each_rinfo (info, rinfo, i) {/* No more gnttab callback work. */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/2 block: set the disk capacity to 0 in blk_mark_disk_dead
From: Christoph Hellwig <[email protected]>
[ Upstream commit 71b26083d59cd4ab22489829ffe7d4ead93f5546 ]
nvme and xen-blkfront are already doing this to stop buffered writes from creating dirty pages that can't be written out later. Move it to the common code.
This also removes the comment about the ordering from nvme, as bd_mutex not only is gone entirely, but also hasn't been used for locking updates to the disk size long before that, and thus the ordering requirement documented there doesn't apply any more.
Stable-dep-of: 61b6d1df1d62 ("xen-blkfront: Fix IO race during unplug")
--- block/genhd.c | 5 +++++ drivers/block/xen-blkfront.c | 1 - drivers/nvme/host/core.c | 7 +------ 3 files changed, 6 insertions(+), 7 deletions(-)
block/genhd.c +5 -0
@@ -595,6 +595,11 @@ void blk_mark_disk_dead(struct gendisk *disk)blk_queue_flag_set (QUEUE_FLAG_DYING , disk->queue);set_bit (GD_DEAD , &disk->state);blk_queue_start_drain (disk->queue); + +/* +* Stop buffered writers from dirtying pages that can't be written out. +*/ +set_capacity_and_notify (disk,0 ); }EXPORT_SYMBOL_GPL (blk_mark_disk_dead);
drivers/block/xen-blkfront.c +0 -1
@@ -2134,7 +2134,6 @@ static void blkfront_closing(struct blkfront_info *info)if (info->rq && info->gd) {blk_mq_stop_hw_queues (info->rq);blk_mark_disk_dead (info->gd); -set_capacity (info->gd,0 ); }for_each_rinfo (info, rinfo, i) {
drivers/nvme/host/core.c +1 -6
@@ -5339,10 +5339,7 @@ static void nvme_stop_ns_queue(struct nvme_ns *ns)/* * Prepare a queue for teardown. * -* This must forcibly unquiesce queues to avoid blocking dispatch, and only set -* the capacity to 0 after that to avoid blocking dispatchers that may be -* holding bd_butex. This will end buffered writers dirtying pages that can't -* be synced. +* This must forcibly unquiesce queues to avoid blocking dispatch. */ static void nvme_set_queue_dying (struct nvme_ns *ns) {
@@ -5351,8 +5348,6 @@ static void nvme_set_queue_dying(struct nvme_ns *ns)blk_mark_disk_dead (ns->disk);nvme_start_ns_queue (ns); - -set_capacity_and_notify (ns->disk,0 ); }/**
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 xen-blkfront: Fix IO race during unplug
From: Ross Lagerwall <[email protected]>
[ Upstream commit 61b6d1df1d6234c38a6ea7e4f58e7da035ef6ab4 ]
During unplug, blkfront stops the hw queues and marks the disk as dead, then later during removal calls del_gendisk(). However, IO issued after the hw queues are stopped but before the call to del_gendisk() will be queued but never handled. This causes del_gendisk() to hang forever waiting for the queue refcount to drop to zero.
This can be reproduced by issuing IO during an artificial delay after stopping the hw queues.
Fix this by simply not stopping the hw queues directly. Marking the disk as dead already freezes the queue which prevents new requests being added and it synchronously runs the hw queues to clear anything pending. If the hw queues are stopped when calling blk_mark_disk_dead(), running the hw queues is a no-op and can leave queued requests unprocessed.
Message-ID: <[email protected]>
--- drivers/block/xen-blkfront.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/block/xen-blkfront.c +1 -3
@@ -2131,10 +2131,8 @@ static void blkfront_closing(struct blkfront_info *info)return ;/* No more blkif_request(). */ -if (info->rq && info->gd) { -blk_mq_stop_hw_queues (info->rq); +if (info->gd)blk_mark_disk_dead (info->gd); - }for_each_rinfo (info, rinfo, i) {/* No more gnttab callback work. */
Signature · 1 line
2.53.0