aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-mq.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-05-27 14:59:50 -0400
committerJens Axboe <axboe@fb.com>2014-05-28 11:49:27 -0400
commitd852564f8c88b0604490234fdeeb6fb47e4bcc7a (patch)
treef22de3dc4e779b047f83e67ca93983c7101e125e /block/blk-mq.c
parent793597a6a95675f4f85671cf747c1d92e7dbc295 (diff)
blk-mq: remove blk_mq_alloc_request_pinned
We now only have one caller left and can open code it there in a cleaner way. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r--block/blk-mq.c48
1 files changed, 16 insertions, 32 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 43f0c8ffa92a..ae14749b530c 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -264,46 +264,30 @@ __blk_mq_alloc_request(struct request_queue *q, struct blk_mq_hw_ctx *hctx,
264 return NULL; 264 return NULL;
265} 265}
266 266
267static struct request *blk_mq_alloc_request_pinned(struct request_queue *q,
268 int rw, gfp_t gfp,
269 bool reserved)
270{
271 bool gfp_mask = gfp & ~__GFP_WAIT;
272 struct request *rq;
273
274 do {
275 struct blk_mq_ctx *ctx = blk_mq_get_ctx(q);
276 struct blk_mq_hw_ctx *hctx = q->mq_ops->map_queue(q, ctx->cpu);
277
278 rq = __blk_mq_alloc_request(q, hctx, ctx, rw, gfp_mask,
279 reserved);
280 if (rq)
281 break;
282
283 if (!(gfp & __GFP_WAIT)) {
284 blk_mq_put_ctx(ctx);
285 break;
286 }
287
288 __blk_mq_run_hw_queue(hctx);
289 blk_mq_put_ctx(ctx);
290 gfp_mask = gfp;
291 } while (1);
292
293 return rq;
294}
295
296struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp, 267struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp,
297 bool reserved) 268 bool reserved)
298{ 269{
270 struct blk_mq_ctx *ctx;
271 struct blk_mq_hw_ctx *hctx;
299 struct request *rq; 272 struct request *rq;
300 273
301 if (blk_mq_queue_enter(q)) 274 if (blk_mq_queue_enter(q))
302 return NULL; 275 return NULL;
303 276
304 rq = blk_mq_alloc_request_pinned(q, rw, gfp, reserved); 277 ctx = blk_mq_get_ctx(q);
305 if (rq) 278 hctx = q->mq_ops->map_queue(q, ctx->cpu);
306 blk_mq_put_ctx(rq->mq_ctx); 279
280 rq = __blk_mq_alloc_request(q, hctx, ctx, rw, gfp & ~__GFP_WAIT,
281 reserved);
282 if (!rq && (gfp & __GFP_WAIT)) {
283 __blk_mq_run_hw_queue(hctx);
284 blk_mq_put_ctx(ctx);
285
286 ctx = blk_mq_get_ctx(q);
287 hctx = q->mq_ops->map_queue(q, ctx->cpu);
288 rq = __blk_mq_alloc_request(q, hctx, ctx, rw, gfp, reserved);
289 }
290 blk_mq_put_ctx(ctx);
307 return rq; 291 return rq;
308} 292}
309EXPORT_SYMBOL(blk_mq_alloc_request); 293EXPORT_SYMBOL(blk_mq_alloc_request);