summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2012-06-29 16:21:34 -0600
committerJens Axboe <axboe@kernel.dk>2012-10-04 11:04:35 +0200
commitddb91de906c845bb359f3e93eedad8d413201cdf (patch)
treee3af8807ae2e1665a44da6f1b27962d770af093e
parent390fc6f8da0c6995810522ab6928df974b108242 (diff)
multiqueue: support alloc and insert of request on mq
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-core.c7
-rw-r--r--block/blk-mq.c32
-rw-r--r--include/linux/blk-mq.h3
3 files changed, 37 insertions, 5 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 51fb5e8feffd..f272074416bd 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1138,7 +1138,12 @@ EXPORT_SYMBOL(blk_get_request);
struct request *blk_make_request(struct request_queue *q, struct bio *bio,
gfp_t gfp_mask)
{
- struct request *rq = blk_get_request(q, bio_data_dir(bio), gfp_mask);
+ struct request *rq;
+
+ if (q->mq_ops)
+ rq = blk_mq_alloc_request(q, bio_data_dir(bio), gfp_mask);
+ else
+ rq = blk_get_request(q, bio_data_dir(bio), gfp_mask);
if (unlikely(!rq))
return ERR_PTR(-ENOMEM);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 033cba6939cd..d9d56b8ddd4f 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -40,9 +40,9 @@ static void blk_mq_hctx_mark_pending(struct blk_mq_hw_ctx *hctx,
set_bit(ctx->index, hctx->ctx_map);
}
-static struct request *blk_mq_alloc_request(struct request_queue *q,
- struct blk_mq_ctx *ctx,
- unsigned int rw_flags)
+static struct request *__blk_mq_alloc_request(struct request_queue *q,
+ struct blk_mq_ctx *ctx,
+ unsigned int rw_flags)
{
struct request *rq;
@@ -55,6 +55,17 @@ static struct request *blk_mq_alloc_request(struct request_queue *q,
return rq;
}
+struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp)
+{
+ struct blk_mq_ctx *ctx;
+ struct request *rq;
+
+ ctx = per_cpu_ptr(q->queue_ctx, get_cpu());
+ rq = __blk_mq_alloc_request(q, ctx, rw);
+ put_cpu();
+ return rq;
+}
+
static void blk_mq_free_request(struct request *rq)
{
struct blk_mq_ctx *ctx = rq->mq_ctx;
@@ -356,6 +367,19 @@ static void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx,
blk_mq_add_timer(rq);
}
+void blk_mq_insert_request(struct request_queue *q, struct request *rq)
+{
+ struct blk_mq_hw_ctx *hctx;
+ struct blk_mq_ctx *ctx;
+
+ ctx = rq->mq_ctx;
+ hctx = q->mq_ops->map_queue(q, ctx);
+
+ spin_lock(&ctx->lock);
+ __blk_mq_insert_request(hctx, ctx, rq);
+ spin_unlock(&ctx->lock);
+}
+
void blk_mq_insert_requests(struct request_queue *q, struct list_head *list)
{
struct blk_mq_hw_ctx *hctx;
@@ -400,7 +424,7 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
if (is_sync)
rw_flags |= REQ_SYNC;
- rq = blk_mq_alloc_request(q, ctx, rw_flags);
+ rq = __blk_mq_alloc_request(q, ctx, rw_flags);
init_request_from_bio(rq, bio);
__blk_mq_insert_request(hctx, ctx, rq);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index fad1adb135c4..b1ae8444f136 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -81,7 +81,10 @@ int blk_mq_register_disk(struct gendisk *);
void blk_mq_unregister_disk(struct gendisk *);
void blk_mq_flush_plug(struct request_queue *, bool);
+void blk_mq_insert_request(struct request_queue *, struct request *);
void blk_mq_insert_requests(struct request_queue *, struct list_head *);
+void blk_mq_run_queues(struct request_queue *q, bool async);
+struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp);
struct blk_mq_hw_ctx *blk_mq_map_single_queue(struct request_queue *q, struct blk_mq_ctx *);