Re: [PATCH 1/3] block: Export blk_mq_all_tag_iter()

Bart Van Assche
2025-09-11T16:50:09Z

On 9/11/25 1:32 AM, Ming Lei wrote:
> On Thu, Sep 11, 2025 at 5:33 AM Bart Van Assche <bvanassche@acm.org> wrote:
>>
>> Prepare for using blk_mq_all_tag_iter() in the SCSI core.
>>
>> Cc: Jens Axboe <axboe@kernel.dk>
>> Cc: Christoph Hellwig <hch@infradead.org>
>> Cc: Ming Lei <ming.lei@redhat.com>
>> Cc: John Garry <john.g.garry@oracle.com>
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>> ---
>> block/blk-mq-tag.c | 1 +
>> block/blk-mq.h | 2 --
>> include/linux/blk-mq.h | 2 ++
>> 3 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
>> index d880c50629d6..1d56ee8722c5 100644
>> --- a/block/blk-mq-tag.c
>> +++ b/block/blk-mq-tag.c
>> @@ -419,6 +419,7 @@ void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
>> {
>> __blk_mq_all_tag_iter(tags, fn, priv, BT_TAG_ITER_STATIC_RQS);
>> }
>> +EXPORT_SYMBOL(blk_mq_all_tag_iter);
>
> IMO, it isn't correct to export an API for iterating over static
> requests for drivers.

Hi Ming,

A possible alternative is to add a new function that is similar to
blk_mq_tagset_busy_iter() except that it passes 0 as fourth argument to
__blk_mq_all_tag_iter() instead of BT_TAG_ITER_STARTED. Something like
this:

void blk_mq_tagset_iter(struct blk_mq_tag_set *tagset,
blk_mq_tag_iter_fn *fn, void *priv)
{
unsigned int flags = tagset->flags;
int i, nr_tags, srcu_idx;

srcu_idx = srcu_read_lock(&tagset->tags_srcu);

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, 0);
}
srcu_read_unlock(&tagset->tags_srcu, srcu_idx);
}
EXPORT_SYMBOL(blk_mq_tagset_busy_iter);

Thanks,

Bart.