Skip to content

Commit 22f614b

Browse files
Ming Leiaxboe
authored andcommitted
blk-mq: fix blk_mq_all_tag_iter
blk_mq_all_tag_iter() is added to iterate all requests, so we should fetch the request from ->static_rqs][] instead of ->rqs[] which is for holding in-flight request only. Fix it by adding flag of BT_TAG_ITER_STATIC_RQS. Fixes: bf0beec ("blk-mq: drain I/O when all CPUs in a hctx are offline") Signed-off-by: Ming Lei <[email protected]> Tested-by: John Garry <[email protected]> Cc: Dongli Zhang <[email protected]> Cc: Hannes Reinecke <[email protected]> Cc: Daniel Wagner <[email protected]> Cc: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent d94ecfc commit 22f614b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

block/blk-mq-tag.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ struct bt_tags_iter_data {
296296

297297
#define BT_TAG_ITER_RESERVED (1 << 0)
298298
#define BT_TAG_ITER_STARTED (1 << 1)
299+
#define BT_TAG_ITER_STATIC_RQS (1 << 2)
299300

300301
static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)
301302
{
@@ -309,9 +310,12 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)
309310

310311
/*
311312
* We can hit rq == NULL here, because the tagging functions
312-
* test and set the bit before assining ->rqs[].
313+
* test and set the bit before assigning ->rqs[].
313314
*/
314-
rq = tags->rqs[bitnr];
315+
if (iter_data->flags & BT_TAG_ITER_STATIC_RQS)
316+
rq = tags->static_rqs[bitnr];
317+
else
318+
rq = tags->rqs[bitnr];
315319
if (!rq)
316320
return true;
317321
if ((iter_data->flags & BT_TAG_ITER_STARTED) &&
@@ -366,11 +370,13 @@ static void __blk_mq_all_tag_iter(struct blk_mq_tags *tags,
366370
* indicates whether or not @rq is a reserved request. Return
367371
* true to continue iterating tags, false to stop.
368372
* @priv: Will be passed as second argument to @fn.
373+
*
374+
* Caller has to pass the tag map from which requests are allocated.
369375
*/
370376
void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
371377
void *priv)
372378
{
373-
return __blk_mq_all_tag_iter(tags, fn, priv, 0);
379+
return __blk_mq_all_tag_iter(tags, fn, priv, BT_TAG_ITER_STATIC_RQS);
374380
}
375381

376382
/**

0 commit comments

Comments
 (0)