From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Ming Lei <ming.lei@redhat.com>, linux-block@vger.kernel.org
Subject: [PATCH 3/6] block: remove QUEUE_FLAG_DEAD
Date: Sun, 19 Jun 2022 08:05:49 +0200 [thread overview]
Message-ID: <20220619060552.1850436-4-hch@lst.de> (raw)
In-Reply-To: <20220619060552.1850436-1-hch@lst.de>
Disallow setting the blk-mq state on any queue that is already dying as
setting the state even then is a bad idea, and remove the now unused
QUEUE_FLAG_DEAD flag.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-core.c | 3 ---
block/blk-mq-debugfs.c | 8 +++-----
include/linux/blkdev.h | 2 --
3 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 27fb1357ad4b8..088332984cd1b 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -313,9 +313,6 @@ void blk_cleanup_queue(struct request_queue *q)
* after draining finished.
*/
blk_freeze_queue(q);
-
- blk_queue_flag_set(QUEUE_FLAG_DEAD, q);
-
blk_sync_queue(q);
if (queue_is_mq(q)) {
blk_mq_cancel_work_sync(q);
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 4d1ce9ef43187..b80fae7ab1d95 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -116,7 +116,6 @@ static const char *const blk_queue_flag_name[] = {
QUEUE_FLAG_NAME(NOXMERGES),
QUEUE_FLAG_NAME(ADD_RANDOM),
QUEUE_FLAG_NAME(SAME_FORCE),
- QUEUE_FLAG_NAME(DEAD),
QUEUE_FLAG_NAME(INIT_DONE),
QUEUE_FLAG_NAME(STABLE_WRITES),
QUEUE_FLAG_NAME(POLL),
@@ -151,11 +150,10 @@ static ssize_t queue_state_write(void *data, const char __user *buf,
char opbuf[16] = { }, *op;
/*
- * The "state" attribute is removed after blk_cleanup_queue() has called
- * blk_mq_free_queue(). Return if QUEUE_FLAG_DEAD has been set to avoid
- * triggering a use-after-free.
+ * The "state" attribute is removed when the queue is removed. Don't
+ * allow setting the state on a dying queue to avoid a use-after-free.
*/
- if (blk_queue_dead(q))
+ if (blk_queue_dying(q))
return -ENOENT;
if (count >= sizeof(opbuf)) {
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 73c886eba8e19..c77ed4dcf561b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -560,7 +560,6 @@ struct request_queue {
#define QUEUE_FLAG_NOXMERGES 9 /* No extended merges */
#define QUEUE_FLAG_ADD_RANDOM 10 /* Contributes to random pool */
#define QUEUE_FLAG_SAME_FORCE 12 /* force complete on same CPU */
-#define QUEUE_FLAG_DEAD 13 /* queue tear-down finished */
#define QUEUE_FLAG_INIT_DONE 14 /* queue is initialized */
#define QUEUE_FLAG_STABLE_WRITES 15 /* don't modify blks until WB is done */
#define QUEUE_FLAG_POLL 16 /* IO polling enabled if set */
@@ -588,7 +587,6 @@ bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q);
#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)
#define blk_queue_dying(q) test_bit(QUEUE_FLAG_DYING, &(q)->queue_flags)
#define blk_queue_has_srcu(q) test_bit(QUEUE_FLAG_HAS_SRCU, &(q)->queue_flags)
-#define blk_queue_dead(q) test_bit(QUEUE_FLAG_DEAD, &(q)->queue_flags)
#define blk_queue_init_done(q) test_bit(QUEUE_FLAG_INIT_DONE, &(q)->queue_flags)
#define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags)
#define blk_queue_noxmerges(q) \
--
2.30.2
next prev parent reply other threads:[~2022-06-19 6:06 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-19 6:05 fully tear down the queue in del_gendisk Christoph Hellwig
2022-06-19 6:05 ` [PATCH 1/6] mtip32xx: remove the device_status debugfs file Christoph Hellwig
2022-06-20 8:37 ` Hannes Reinecke
2022-06-19 6:05 ` [PATCH 2/6] mtip32xx: fix device removal Christoph Hellwig
2022-06-20 8:38 ` Hannes Reinecke
2022-06-19 6:05 ` Christoph Hellwig [this message]
2022-06-19 14:07 ` [PATCH 3/6] block: remove QUEUE_FLAG_DEAD Bart Van Assche
2022-06-20 6:20 ` Christoph Hellwig
2022-06-20 8:39 ` Hannes Reinecke
2022-06-19 6:05 ` [PATCH 4/6] block: stop setting the nomerges flags in blk_cleanup_queue Christoph Hellwig
2022-06-20 8:40 ` Hannes Reinecke
2022-06-19 6:05 ` [PATCH 5/6] block: simplify disk shutdown Christoph Hellwig
2022-06-20 8:47 ` Hannes Reinecke
2022-06-19 6:05 ` [PATCH 6/6] block: remove blk_cleanup_disk Christoph Hellwig
2022-06-20 8:49 ` Hannes Reinecke
2022-06-20 8:56 ` Christoph Hellwig
2022-06-20 9:00 ` Hannes Reinecke
2022-06-28 14:42 ` Sagi Grimberg
2022-06-19 22:21 ` fully tear down the queue in del_gendisk Jens Axboe
2022-06-20 6:09 ` Christoph Hellwig
2022-06-20 11:16 ` Jens Axboe
2022-06-28 5:11 ` Christoph Hellwig
2022-06-28 12:29 ` Jens Axboe
2022-06-28 12:35 ` Jens Axboe
2022-06-28 12:33 ` Jens Axboe
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=20220619060552.1850436-4-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox