Skip to content

Commit 5b20507

Browse files
committed
block: ensure plug merging checks the correct queue at least once
Song reports that a RAID rebuild workload runs much slower recently, and it is seeing a lot less merging than it did previously. The reason is that a previous commit reduced the amount of work we do for plug merging. RAID rebuild interleaves requests between disks, so a last-entry check in plug merging always misses a merge opportunity since we always find a different disk than what we are looking for. Modify the logic such that it's still a one-hit cache, but ensure that we check enough to find the right target before giving up. Fixes: d38a9c0 ("block: only check previous entry for plug merge attempt") Reported-and-tested-by: Song Liu <song@kernel.org> Reviewed-by: Song Liu <songliubraving@fb.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 5ca7546 commit 5b20507

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

block/blk-merge.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,12 +1087,20 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
10871087
if (!plug || rq_list_empty(plug->mq_list))
10881088
return false;
10891089

1090-
/* check the previously added entry for a quick merge attempt */
1091-
rq = rq_list_peek(&plug->mq_list);
1092-
if (rq->q == q) {
1093-
if (blk_attempt_bio_merge(q, rq, bio, nr_segs, false) ==
1094-
BIO_MERGE_OK)
1095-
return true;
1090+
rq_list_for_each(&plug->mq_list, rq) {
1091+
if (rq->q == q) {
1092+
if (blk_attempt_bio_merge(q, rq, bio, nr_segs, false) ==
1093+
BIO_MERGE_OK)
1094+
return true;
1095+
break;
1096+
}
1097+
1098+
/*
1099+
* Only keep iterating plug list for merges if we have multiple
1100+
* queues
1101+
*/
1102+
if (!plug->multiple_queues)
1103+
break;
10961104
}
10971105
return false;
10981106
}

0 commit comments

Comments
 (0)