From a3bd77567cae6af700dcd245148befc73fc89a50 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 27 May 2014 20:59:48 +0200 Subject: blk-mq: remove blk_mq_wait_for_tags The current logic for blocking tag allocation is rather confusing, as we first allocated and then free again a tag in blk_mq_wait_for_tags, just to attempt a non-blocking allocation and then repeat if someone else managed to grab the tag before us. Instead change blk_mq_alloc_request_pinned to simply do a blocking tag allocation itself and use the request we get back from it. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-mq.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'block/blk-mq.c') diff --git a/block/blk-mq.c b/block/blk-mq.c index 04ef7ecb3c7f..3224888d329a 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -264,31 +264,30 @@ __blk_mq_alloc_request(struct request_queue *q, struct blk_mq_hw_ctx *hctx, return NULL; } - static struct request *blk_mq_alloc_request_pinned(struct request_queue *q, int rw, gfp_t gfp, bool reserved) { + bool gfp_mask = gfp & ~__GFP_WAIT; struct request *rq; do { struct blk_mq_ctx *ctx = blk_mq_get_ctx(q); struct blk_mq_hw_ctx *hctx = q->mq_ops->map_queue(q, ctx->cpu); - rq = __blk_mq_alloc_request(q, hctx, ctx, rw, gfp & ~__GFP_WAIT, + rq = __blk_mq_alloc_request(q, hctx, ctx, rw, gfp_mask, reserved); if (rq) break; - if (gfp & __GFP_WAIT) { - __blk_mq_run_hw_queue(hctx); - blk_mq_put_ctx(ctx); - } else { + if (!(gfp & __GFP_WAIT)) { blk_mq_put_ctx(ctx); break; } - blk_mq_wait_for_tags(hctx, reserved); + __blk_mq_run_hw_queue(hctx); + blk_mq_put_ctx(ctx); + gfp_mask = gfp; } while (1); return rq; -- cgit v1.2.3