* FAILED: patch "[PATCH] xen-blkfront: Fix IO race during unplug" failed to apply to 6.1-stable tree
@ 2026-11-07 10:46 Sasha Levin
2026-11-11 0:57 ` [PATCH 6.1.y 1/2] block: set the disk capacity to 0 in blk_mark_disk_dead Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2026-11-07 10:46 UTC (permalink / raw)
To: ross.lagerwall, roger, jgross; +Cc: stable
The 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 <stable@vger.kernel.org>.
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 '<stable@vger.kernel.org>' --in-reply-to '20261107054611-failed-6.1-61b6d1df1d62@kernel.org' --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 <ross.lagerwall@citrix.com>
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.
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Acked-by: Roger Pau Monné <roger@xenproject.org>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20261006163411.2583538-1-ross.lagerwall@citrix.com>
---
drivers/block/xen-blkfront.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 86f5dd3aced13..ad0cb42c10197 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -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. */
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 6.1.y 1/2] block: set the disk capacity to 0 in blk_mark_disk_dead
2026-11-07 10:46 FAILED: patch "[PATCH] xen-blkfront: Fix IO race during unplug" failed to apply to 6.1-stable tree Sasha Levin
@ 2026-11-11 0:57 ` Sasha Levin
2026-11-11 0:57 ` [PATCH 6.1.y 2/2] xen-blkfront: Fix IO race during unplug Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2026-11-11 0:57 UTC (permalink / raw)
To: stable
Cc: Christoph Hellwig, Keith Busch, Sagi Grimberg, Ming Lei,
Chao Leng, Chaitanya Kulkarni, Jens Axboe, Sasha Levin
From: Christoph Hellwig <hch@lst.de>
[ 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.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Chao Leng <lengchao@huawei.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20221101150050.3510-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: 61b6d1df1d62 ("xen-blkfront: Fix IO race during unplug")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
block/genhd.c | 5 +++++
drivers/block/xen-blkfront.c | 1 -
drivers/nvme/host/core.c | 7 +------
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index ee6dc7feccc6f..f06195e53571c 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -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);
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index df0eaf15a4ddd..7ad03bcd9f274 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -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) {
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 26233e6a50da9..ecaba784e593d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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);
}
/**
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 6.1.y 2/2] xen-blkfront: Fix IO race during unplug
2026-11-11 0:57 ` [PATCH 6.1.y 1/2] block: set the disk capacity to 0 in blk_mark_disk_dead Sasha Levin
@ 2026-11-11 0:57 ` Sasha Levin
0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2026-11-11 0:57 UTC (permalink / raw)
To: stable; +Cc: Ross Lagerwall, Roger Pau Monné, Juergen Gross, Sasha Levin
From: Ross Lagerwall <ross.lagerwall@citrix.com>
[ 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.
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Acked-by: Roger Pau Monné <roger@xenproject.org>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20261006163411.2583538-1-ross.lagerwall@citrix.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/block/xen-blkfront.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 7ad03bcd9f274..207a2ec844849 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -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. */
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-11 0:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-07 10:46 FAILED: patch "[PATCH] xen-blkfront: Fix IO race during unplug" failed to apply to 6.1-stable tree Sasha Levin
2026-11-11 0:57 ` [PATCH 6.1.y 1/2] block: set the disk capacity to 0 in blk_mark_disk_dead Sasha Levin
2026-11-11 0:57 ` [PATCH 6.1.y 2/2] xen-blkfront: Fix IO race during unplug Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox