aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-mq-tag.c
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2015-06-01 11:29:53 -0400
committerJens Axboe <axboe@fb.com>2015-06-01 16:35:56 -0400
commitf26cdc8536ad50fb802a0445f836b4f94ca09ae7 (patch)
tree8863e8e297fd10241d7ff1e24cdef4ab0b7c625e /block/blk-mq-tag.c
parente548ca4ee4595f65b262661d166310ad8a149bec (diff)
blk-mq: Shared tag enhancements
Storage controllers may expose multiple block devices that share hardware resources managed by blk-mq. This patch enhances the shared tags so a low-level driver can access the shared resources not tied to the unshared h/w contexts. This way the LLD can dynamically add and delete disks and request queues without having to track all the request_queue hctx's to iterate outstanding tags. Signed-off-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-mq-tag.c')
-rw-r--r--block/blk-mq-tag.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index be3290cc0644..9b6e28830b82 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -438,6 +438,39 @@ static void bt_for_each(struct blk_mq_hw_ctx *hctx,
438 } 438 }
439} 439}
440 440
441static void bt_tags_for_each(struct blk_mq_tags *tags,
442 struct blk_mq_bitmap_tags *bt, unsigned int off,
443 busy_tag_iter_fn *fn, void *data, bool reserved)
444{
445 struct request *rq;
446 int bit, i;
447
448 if (!tags->rqs)
449 return;
450 for (i = 0; i < bt->map_nr; i++) {
451 struct blk_align_bitmap *bm = &bt->map[i];
452
453 for (bit = find_first_bit(&bm->word, bm->depth);
454 bit < bm->depth;
455 bit = find_next_bit(&bm->word, bm->depth, bit + 1)) {
456 rq = blk_mq_tag_to_rq(tags, off + bit);
457 fn(rq, data, reserved);
458 }
459
460 off += (1 << bt->bits_per_word);
461 }
462}
463
464void blk_mq_all_tag_busy_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
465 void *priv)
466{
467 if (tags->nr_reserved_tags)
468 bt_tags_for_each(tags, &tags->breserved_tags, 0, fn, priv, true);
469 bt_tags_for_each(tags, &tags->bitmap_tags, tags->nr_reserved_tags, fn, priv,
470 false);
471}
472EXPORT_SYMBOL(blk_mq_all_tag_busy_iter);
473
441void blk_mq_tag_busy_iter(struct blk_mq_hw_ctx *hctx, busy_iter_fn *fn, 474void blk_mq_tag_busy_iter(struct blk_mq_hw_ctx *hctx, busy_iter_fn *fn,
442 void *priv) 475 void *priv)
443{ 476{
@@ -580,6 +613,11 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,
580 if (!tags) 613 if (!tags)
581 return NULL; 614 return NULL;
582 615
616 if (!zalloc_cpumask_var(&tags->cpumask, GFP_KERNEL)) {
617 kfree(tags);
618 return NULL;
619 }
620
583 tags->nr_tags = total_tags; 621 tags->nr_tags = total_tags;
584 tags->nr_reserved_tags = reserved_tags; 622 tags->nr_reserved_tags = reserved_tags;
585 623