blk-mq: re-check for available tags after running the hardware queue
authorJens Axboe <axboe@fb.com>
Mon, 8 Dec 2014 15:49:06 +0000 (08:49 -0700)
committerJens Axboe <axboe@fb.com>
Mon, 8 Dec 2014 15:49:06 +0000 (08:49 -0700)
If we run out of tags and have to sleep, we run the hardware queue
to kick pending IO into gear. During that run, we may have completed
requests, so re-check if we have free tags before going to sleep.

Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq-tag.c

index eb55492e6875771f4723c92113bed70f7b8aec51..bab4bff15f42817ad507a613d2d7f7a9d6dcd513 100644 (file)
@@ -261,6 +261,14 @@ static int bt_get(struct blk_mq_alloc_data *data,
                 */
                blk_mq_run_hw_queue(hctx, false);
 
+               /*
+                * Retry tag allocation after running the hardware queue,
+                * as running the queue may also have found completions.
+                */
+               tag = __bt_get(hctx, bt, last_tag);
+               if (tag != -1)
+                       break;
+
                blk_mq_put_ctx(data->ctx);
 
                io_schedule();