aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blk-mq.c12
-rw-r--r--include/linux/blkdev.h3
2 files changed, 11 insertions, 4 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 862f458d4760..32593dba4684 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -171,9 +171,12 @@ bool blk_mq_can_queue(struct blk_mq_hw_ctx *hctx)
171} 171}
172EXPORT_SYMBOL(blk_mq_can_queue); 172EXPORT_SYMBOL(blk_mq_can_queue);
173 173
174static void blk_mq_rq_ctx_init(struct blk_mq_ctx *ctx, struct request *rq, 174static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
175 unsigned int rw_flags) 175 struct request *rq, unsigned int rw_flags)
176{ 176{
177 if (blk_queue_io_stat(q))
178 rw_flags |= REQ_IO_STAT;
179
177 rq->mq_ctx = ctx; 180 rq->mq_ctx = ctx;
178 rq->cmd_flags = rw_flags; 181 rq->cmd_flags = rw_flags;
179 ctx->rq_dispatched[rw_is_sync(rw_flags)]++; 182 ctx->rq_dispatched[rw_is_sync(rw_flags)]++;
@@ -197,7 +200,7 @@ static struct request *blk_mq_alloc_request_pinned(struct request_queue *q,
197 200
198 rq = __blk_mq_alloc_request(hctx, gfp & ~__GFP_WAIT, reserved); 201 rq = __blk_mq_alloc_request(hctx, gfp & ~__GFP_WAIT, reserved);
199 if (rq) { 202 if (rq) {
200 blk_mq_rq_ctx_init(ctx, rq, rw); 203 blk_mq_rq_ctx_init(q, ctx, rq, rw);
201 break; 204 break;
202 } else if (!(gfp & __GFP_WAIT)) 205 } else if (!(gfp & __GFP_WAIT))
203 break; 206 break;
@@ -921,7 +924,7 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
921 trace_block_getrq(q, bio, rw); 924 trace_block_getrq(q, bio, rw);
922 rq = __blk_mq_alloc_request(hctx, GFP_ATOMIC, false); 925 rq = __blk_mq_alloc_request(hctx, GFP_ATOMIC, false);
923 if (likely(rq)) 926 if (likely(rq))
924 blk_mq_rq_ctx_init(ctx, rq, rw); 927 blk_mq_rq_ctx_init(q, ctx, rq, rw);
925 else { 928 else {
926 blk_mq_put_ctx(ctx); 929 blk_mq_put_ctx(ctx);
927 trace_block_sleeprq(q, bio, rw); 930 trace_block_sleeprq(q, bio, rw);
@@ -1377,6 +1380,7 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_reg *reg,
1377 q->queue_hw_ctx = hctxs; 1380 q->queue_hw_ctx = hctxs;
1378 1381
1379 q->mq_ops = reg->ops; 1382 q->mq_ops = reg->ops;
1383 q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT;
1380 1384
1381 blk_queue_make_request(q, blk_mq_make_request); 1385 blk_queue_make_request(q, blk_mq_make_request);
1382 blk_queue_rq_timed_out(q, reg->ops->timeout); 1386 blk_queue_rq_timed_out(q, reg->ops->timeout);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f26ec20f6354..1b135d49b279 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -505,6 +505,9 @@ struct request_queue {
505 (1 << QUEUE_FLAG_SAME_COMP) | \ 505 (1 << QUEUE_FLAG_SAME_COMP) | \
506 (1 << QUEUE_FLAG_ADD_RANDOM)) 506 (1 << QUEUE_FLAG_ADD_RANDOM))
507 507
508#define QUEUE_FLAG_MQ_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
509 (1 << QUEUE_FLAG_SAME_COMP))
510
508static inline void queue_lockdep_assert_held(struct request_queue *q) 511static inline void queue_lockdep_assert_held(struct request_queue *q)
509{ 512{
510 if (q->queue_lock) 513 if (q->queue_lock)