aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blk-mq.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index ac8a0413664e..c9e89a8792e3 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1068,13 +1068,17 @@ static void blk_mq_bio_to_request(struct request *rq, struct bio *bio)
1068 blk_account_io_start(rq, 1); 1068 blk_account_io_start(rq, 1);
1069} 1069}
1070 1070
1071static inline bool hctx_allow_merges(struct blk_mq_hw_ctx *hctx)
1072{
1073 return (hctx->flags & BLK_MQ_F_SHOULD_MERGE) &&
1074 !blk_queue_nomerges(hctx->queue);
1075}
1076
1071static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx, 1077static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx,
1072 struct blk_mq_ctx *ctx, 1078 struct blk_mq_ctx *ctx,
1073 struct request *rq, struct bio *bio) 1079 struct request *rq, struct bio *bio)
1074{ 1080{
1075 struct request_queue *q = hctx->queue; 1081 if (!hctx_allow_merges(hctx)) {
1076
1077 if (!(hctx->flags & BLK_MQ_F_SHOULD_MERGE)) {
1078 blk_mq_bio_to_request(rq, bio); 1082 blk_mq_bio_to_request(rq, bio);
1079 spin_lock(&ctx->lock); 1083 spin_lock(&ctx->lock);
1080insert_rq: 1084insert_rq:
@@ -1082,6 +1086,8 @@ insert_rq:
1082 spin_unlock(&ctx->lock); 1086 spin_unlock(&ctx->lock);
1083 return false; 1087 return false;
1084 } else { 1088 } else {
1089 struct request_queue *q = hctx->queue;
1090
1085 spin_lock(&ctx->lock); 1091 spin_lock(&ctx->lock);
1086 if (!blk_mq_attempt_merge(q, ctx, bio)) { 1092 if (!blk_mq_attempt_merge(q, ctx, bio)) {
1087 blk_mq_bio_to_request(rq, bio); 1093 blk_mq_bio_to_request(rq, bio);