Skip to content

Commit 179ae84

Browse files
isilenceaxboe
authored andcommitted
block: clean up blk_mq_submit_bio() merging
Combine blk_mq_sched_bio_merge() and blk_attempt_plug_merge() under a common if, so we don't check it twice. Signed-off-by: Pavel Begunkov <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/daedc90d4029a5d1d73344771632b1faca3aaf81.1634755800.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 6450fe1 commit 179ae84

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

block/blk-mq-sched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx)
361361
}
362362
}
363363

364-
bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
364+
bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
365365
unsigned int nr_segs)
366366
{
367367
struct elevator_queue *e = q->elevator;

block/blk-mq-sched.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void blk_mq_sched_assign_ioc(struct request *rq);
1212

1313
bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio,
1414
unsigned int nr_segs, struct request **merged_request);
15-
bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
15+
bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
1616
unsigned int nr_segs);
1717
bool blk_mq_sched_try_insert_merge(struct request_queue *q, struct request *rq,
1818
struct list_head *free);
@@ -42,16 +42,6 @@ static inline bool bio_mergeable(struct bio *bio)
4242
return !(bio->bi_opf & REQ_NOMERGE_FLAGS);
4343
}
4444

45-
static inline bool
46-
blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
47-
unsigned int nr_segs)
48-
{
49-
if (blk_queue_nomerges(q) || !bio_mergeable(bio))
50-
return false;
51-
52-
return __blk_mq_sched_bio_merge(q, bio, nr_segs);
53-
}
54-
5545
static inline bool
5646
blk_mq_sched_allow_merge(struct request_queue *q, struct request *rq,
5747
struct bio *bio)

block/blk-mq.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,7 +2481,6 @@ void blk_mq_submit_bio(struct bio *bio)
24812481
{
24822482
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
24832483
const int is_sync = op_is_sync(bio->bi_opf);
2484-
const int is_flush_fua = op_is_flush(bio->bi_opf);
24852484
struct request *rq;
24862485
struct blk_plug *plug;
24872486
bool same_queue_rq = false;
@@ -2495,12 +2494,12 @@ void blk_mq_submit_bio(struct bio *bio)
24952494
if (!bio_integrity_prep(bio))
24962495
goto queue_exit;
24972496

2498-
if (!is_flush_fua && !blk_queue_nomerges(q) &&
2499-
blk_attempt_plug_merge(q, bio, nr_segs, &same_queue_rq))
2500-
goto queue_exit;
2501-
2502-
if (blk_mq_sched_bio_merge(q, bio, nr_segs))
2503-
goto queue_exit;
2497+
if (!blk_queue_nomerges(q) && bio_mergeable(bio)) {
2498+
if (blk_attempt_plug_merge(q, bio, nr_segs, &same_queue_rq))
2499+
goto queue_exit;
2500+
if (blk_mq_sched_bio_merge(q, bio, nr_segs))
2501+
goto queue_exit;
2502+
}
25042503

25052504
rq_qos_throttle(q, bio);
25062505

@@ -2543,7 +2542,7 @@ void blk_mq_submit_bio(struct bio *bio)
25432542
return;
25442543
}
25452544

2546-
if (is_flush_fua && blk_insert_flush(rq))
2545+
if (op_is_flush(bio->bi_opf) && blk_insert_flush(rq))
25472546
return;
25482547

25492548
if (plug && (q->nr_hw_queues == 1 ||

0 commit comments

Comments
 (0)