From: Chengming Zhou <[email protected]>
Changes in v4:
- Add Reviewed-by tag from Bart Van Assche. Thanks for review!
- Rebased on the newest block/for-next branch.
Changes in v3:
- Document the argument 'q' in the patch which add it.
- Add Fixes tag and Reviewed-by tags.
Changes in v2:
- Split by one change per patch and add Fixes tag.
- Improve commit messages, suggested by Bart Van Assche.
There are two almost identical mechanisms in blk-mq-tag to iterate over
requests of one tags: bt_for_each() and the newer bt_tags_for_each().
This series aim to add support of queue filter in bt_tags_for_each()
then remove bt_for_each(). Fix and update documentation as we're here.
Thanks for review!
Chengming Zhou (6):
blk-mq-tag: support queue filter in bt_tags_iter()
blk-mq-tag: introduce __blk_mq_tagset_busy_iter()
blk-mq-tag: remove bt_for_each()
blk-mq: delete superfluous check in iterate callback
blk-mq-tag: fix functions documentation
blk-mq-tag: fix blk_mq_queue_tag_busy_iter() documentation
block/blk-mq-tag.c | 176 ++++++++++++---------------------------------
block/blk-mq.c | 12 ++--
2 files changed, 49 insertions(+), 139 deletions(-)
--
2.40.1
From: Chengming Zhou <[email protected]>
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 <[email protected]>
Signed-off-by: Chengming Zhou <[email protected]>
---
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.40.1