blk-mq: fix iteration of busy bitmap
authorJens Axboe <axboe@fb.com>
Fri, 17 Apr 2015 14:28:50 +0000 (08:28 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 17 Apr 2015 14:31:12 +0000 (08:31 -0600)
Commit 889fa31f00b2 was a bit too eager in reducing the loop count,
so we ended up missing queues in some configurations. Ensure that
our division rounds up, so that's not the case.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Fixes: 889fa31f00b2 ("blk-mq: reduce unnecessary software queue looping")
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq.c
include/linux/blk-mq.h

index c82de08f3721c9f256d9837341c42290daeeef88..ade8a2d1b0aa8600ad31413b59db37392628bffc 100644 (file)
@@ -41,7 +41,7 @@ static bool blk_mq_hctx_has_pending(struct blk_mq_hw_ctx *hctx)
 {
        unsigned int i;
 
-       for (i = 0; i < hctx->ctx_map.map_size; i++)
+       for (i = 0; i < hctx->ctx_map.size; i++)
                if (hctx->ctx_map.map[i].word)
                        return true;
 
@@ -730,7 +730,7 @@ static void flush_busy_ctxs(struct blk_mq_hw_ctx *hctx, struct list_head *list)
        struct blk_mq_ctx *ctx;
        int i;
 
-       for (i = 0; i < hctx->ctx_map.map_size; i++) {
+       for (i = 0; i < hctx->ctx_map.size; i++) {
                struct blk_align_bitmap *bm = &hctx->ctx_map.map[i];
                unsigned int off, bit;
 
@@ -1818,7 +1818,7 @@ static void blk_mq_map_swqueue(struct request_queue *q)
                 * This is more accurate and more efficient than looping
                 * over all possibly mapped software queues.
                 */
-               map->map_size = hctx->nr_ctx / map->bits_per_word;
+               map->size = DIV_ROUND_UP(hctx->nr_ctx, map->bits_per_word);
 
                /*
                 * Initialize batch roundrobin counts
index 8210e8797c123043474b39b1efc1a33c3d0a6201..2056a99b92f8c905d2cbc53ee7a2f022893da27e 100644 (file)
@@ -13,7 +13,7 @@ struct blk_mq_cpu_notifier {
 };
 
 struct blk_mq_ctxmap {
-       unsigned int map_size;
+       unsigned int size;
        unsigned int bits_per_word;
        struct blk_align_bitmap *map;
 };