All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: 胡连勤 <hulianqin@vivo.com>, "Christoph Hellwig" <hch@lst.de>,
	"Jens Axboe" <axboe@kernel.dk>, "Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 6.1.y 4/4] block: set QUEUE_FLAG_DYING unconditionally in blk_mark_disk_dead()
Date: Tue,  8 Sep 2026 09:32:59 -0400	[thread overview]
Message-ID: <20260908133259.2325197-4-sashal@kernel.org> (raw)
In-Reply-To: <20260908133259.2325197-1-sashal@kernel.org>

From: 胡连勤 <hulianqin@vivo.com>

[ Upstream commit 7e9a46004b471eaf69b082c473d865316a4158e0 ]

Disks created via blk_mq_alloc_disk_for_queue() (e.g. SCSI SD disks)
do not have GD_OWNS_QUEUE set.  Currently __blk_mark_disk_dead() only
sets QUEUE_FLAG_DYING when GD_OWNS_QUEUE is set, so for such disks
blk_queue_enter() and __bio_queue_enter() cannot detect the dying
state via blk_queue_dying() and remain blocked waiting for I/O that
will never complete after surprise removal.

blk_mark_disk_dead() is the explicit "surprise removal" API -- the
caller has already decided the disk is dead.  Setting QUEUE_FLAG_DYING
unconditionally here is appropriate: any in-flight I/O from other
threads should get -ENODEV immediately from blk_queue_enter()
regardless of GD_OWNS_QUEUE ownership.

For disks that already have GD_OWNS_QUEUE set, __blk_mark_disk_dead()
will set the flag again which is harmless.

Fixes: 6f8191fdf41d ("block: simplify disk shutdown")
Cc: stable@vger.kernel.org
Signed-off-by: Lianqin Hu <hulianqin@vivo.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/PUZPR06MB62247E82E66A3ED46CC3E6C7D2DC2@PUZPR06MB6224.apcprd06.prod.outlook.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[ adapted the newer helper-based implementation to the existing 6.1 function body. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 block/genhd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block/genhd.c b/block/genhd.c
index c058a01c1b3a1..753dfa846e3ea 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -585,6 +585,7 @@ EXPORT_SYMBOL(device_add_disk);
  */
 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);
 }
-- 
2.53.0


      parent reply	other threads:[~2026-09-08 13:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 13:46 FAILED: patch "[PATCH] block: set QUEUE_FLAG_DYING unconditionally in" failed to apply to 6.1-stable tree gregkh
2026-09-08 13:32 ` [PATCH 6.1.y 1/4] block: simplify the disk_force_media_change interface Sasha Levin
2026-09-08 13:32   ` [PATCH 6.1.y 2/4] dasd: also call __invalidate_device when setting the device offline Sasha Levin
2026-09-08 13:32   ` [PATCH 6.1.y 3/4] block: drop the "busy inodes on changed media" log message Sasha Levin
2026-09-08 13:32   ` Sasha Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260908133259.2325197-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=hulianqin@vivo.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.