Commit ed44832d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

blk-mq: initialize request on allocation

If we want to share tag and request allocation between queues we cannot
initialize the request at init/free time, but need to initialize it
at allocation time as it might get used for different queues over its
lifetime.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent e9b267d9
...@@ -82,6 +82,7 @@ static struct request *__blk_mq_alloc_request(struct blk_mq_hw_ctx *hctx, ...@@ -82,6 +82,7 @@ static struct request *__blk_mq_alloc_request(struct blk_mq_hw_ctx *hctx,
tag = blk_mq_get_tag(hctx->tags, gfp, reserved); tag = blk_mq_get_tag(hctx->tags, gfp, reserved);
if (tag != BLK_MQ_TAG_FAIL) { if (tag != BLK_MQ_TAG_FAIL) {
rq = hctx->rqs[tag]; rq = hctx->rqs[tag];
blk_rq_init(hctx->queue, rq);
rq->tag = tag; rq->tag = tag;
return rq; return rq;
...@@ -257,9 +258,7 @@ static void __blk_mq_free_request(struct blk_mq_hw_ctx *hctx, ...@@ -257,9 +258,7 @@ static void __blk_mq_free_request(struct blk_mq_hw_ctx *hctx,
const int tag = rq->tag; const int tag = rq->tag;
struct request_queue *q = rq->q; struct request_queue *q = rq->q;
blk_rq_init(hctx->queue, rq);
blk_mq_put_tag(hctx->tags, tag); blk_mq_put_tag(hctx->tags, tag);
blk_mq_queue_exit(q); blk_mq_queue_exit(q);
} }
...@@ -1122,7 +1121,6 @@ static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx, ...@@ -1122,7 +1121,6 @@ static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx,
left -= to_do * rq_size; left -= to_do * rq_size;
for (j = 0; j < to_do; j++) { for (j = 0; j < to_do; j++) {
hctx->rqs[i] = p; hctx->rqs[i] = p;
blk_rq_init(hctx->queue, hctx->rqs[i]);
if (reg->ops->init_request) { if (reg->ops->init_request) {
error = reg->ops->init_request(driver_data, error = reg->ops->init_request(driver_data,
hctx, hctx->rqs[i], i); hctx, hctx->rqs[i], i);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment