From: chengming.zhou@linux.dev
To: axboe@kernel.dk, ming.lei@redhat.com, bvanassche@acm.org, hch@lst.de
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
zhouchengming@bytedance.com
Subject: [PATCH v3 2/6] blk-mq-tag: introduce __blk_mq_tagset_busy_iter()
Date: Wed, 23 Aug 2023 23:17:59 +0800 [thread overview]
Message-ID: <20230823151803.926382-3-chengming.zhou@linux.dev> (raw)
In-Reply-To: <20230823151803.926382-1-chengming.zhou@linux.dev>
From: Chengming Zhou <zhouchengming@bytedance.com>
For support of specified queue filter when iterating over a tagset,
we introduce __blk_mq_tagset_busy_iter() here and all current users
just set queue as NULL which means have no queue filter.
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
---
block/blk-mq-tag.c | 41 ++++++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 3cf3cf72cd54..dc4edde3c80a 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -381,15 +381,18 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)
* to continue iterating tags, false to stop.
* @data: Will be passed as second argument to @fn.
* @flags: BT_TAG_ITER_*
+ * @q: Only iterate over requests of this queue.
*/
static void bt_tags_for_each(struct blk_mq_tags *tags, struct sbitmap_queue *bt,
- busy_tag_iter_fn *fn, void *data, unsigned int flags)
+ busy_tag_iter_fn *fn, void *data, unsigned int flags,
+ struct request_queue *q)
{
struct bt_tags_iter_data iter_data = {
.tags = tags,
.fn = fn,
.data = data,
.flags = flags,
+ .q = q,
};
if (tags->rqs)
@@ -397,14 +400,15 @@ static void bt_tags_for_each(struct blk_mq_tags *tags, struct sbitmap_queue *bt,
}
static void __blk_mq_all_tag_iter(struct blk_mq_tags *tags,
- busy_tag_iter_fn *fn, void *priv, unsigned int flags)
+ busy_tag_iter_fn *fn, void *priv, unsigned int flags,
+ struct request_queue *q)
{
WARN_ON_ONCE(flags & BT_TAG_ITER_RESERVED);
if (tags->nr_reserved_tags)
bt_tags_for_each(tags, &tags->breserved_tags, fn, priv,
- flags | BT_TAG_ITER_RESERVED);
- bt_tags_for_each(tags, &tags->bitmap_tags, fn, priv, flags);
+ flags | BT_TAG_ITER_RESERVED, q);
+ bt_tags_for_each(tags, &tags->bitmap_tags, fn, priv, flags, q);
}
/**
@@ -422,7 +426,23 @@ static void __blk_mq_all_tag_iter(struct blk_mq_tags *tags,
void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
void *priv)
{
- __blk_mq_all_tag_iter(tags, fn, priv, BT_TAG_ITER_STATIC_RQS);
+ __blk_mq_all_tag_iter(tags, fn, priv, BT_TAG_ITER_STATIC_RQS, NULL);
+}
+
+static void __blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
+ busy_tag_iter_fn *fn, void *priv,
+ struct request_queue *q)
+{
+ unsigned int flags = tagset->flags;
+ int i, nr_tags;
+
+ nr_tags = blk_mq_is_shared_tags(flags) ? 1 : tagset->nr_hw_queues;
+
+ for (i = 0; i < nr_tags; i++) {
+ if (tagset->tags && tagset->tags[i])
+ __blk_mq_all_tag_iter(tagset->tags[i], fn, priv,
+ BT_TAG_ITER_STARTED, q);
+ }
}
/**
@@ -441,16 +461,7 @@ void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
busy_tag_iter_fn *fn, void *priv)
{
- unsigned int flags = tagset->flags;
- int i, nr_tags;
-
- nr_tags = blk_mq_is_shared_tags(flags) ? 1 : tagset->nr_hw_queues;
-
- for (i = 0; i < nr_tags; i++) {
- if (tagset->tags && tagset->tags[i])
- __blk_mq_all_tag_iter(tagset->tags[i], fn, priv,
- BT_TAG_ITER_STARTED);
- }
+ __blk_mq_tagset_busy_iter(tagset, fn, priv, NULL);
}
EXPORT_SYMBOL(blk_mq_tagset_busy_iter);
--
2.41.0
next prev parent reply other threads:[~2023-08-23 15:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 15:17 [PATCH v3 0/6] blk-mq-tag: remove bt_for_each() chengming.zhou
2023-08-23 15:17 ` [PATCH v3 1/6] blk-mq-tag: support queue filter in bt_tags_iter() chengming.zhou
2023-08-23 15:17 ` chengming.zhou [this message]
2023-08-23 15:18 ` [PATCH v3 3/6] blk-mq-tag: remove bt_for_each() chengming.zhou
2023-08-23 15:18 ` [PATCH v3 4/6] blk-mq: delete superfluous check in iterate callback chengming.zhou
2023-08-23 15:18 ` [PATCH v3 5/6] blk-mq-tag: fix functions documentation chengming.zhou
2023-08-23 15:18 ` [PATCH v3 6/6] blk-mq-tag: fix blk_mq_queue_tag_busy_iter() documentation chengming.zhou
2023-08-23 15:26 ` Bart Van Assche
2023-09-02 14:58 ` [PATCH v3 0/6] blk-mq-tag: remove bt_for_each() Chengming Zhou
2023-09-03 23:51 ` Bart Van Assche
2023-09-04 2:25 ` Chengming Zhou
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=20230823151803.926382-3-chengming.zhou@linux.dev \
--to=chengming.zhou@linux.dev \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=zhouchengming@bytedance.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