Skip to content

Commit 23f3e32

Browse files
XiaoNi87axboe
authored andcommitted
block: Merge bio before checking ->cached_rq
It checks if plug->cached_rq is empty before merging bio. But the merge action doesn't have relationship with plug->cached_rq, it trys to merge bio with requests within plug->mq_list. Now it checks if ->cached_rq is empty before merging bio. If it's empty, it will miss the merge chances. So move the merge function before checking ->cached_rq. Signed-off-by: Xiao Ni <[email protected]> Reviewed-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent dcb5220 commit 23f3e32

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

block/blk-mq.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -2879,15 +2879,16 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
28792879

28802880
if (!plug)
28812881
return NULL;
2882-
rq = rq_list_peek(&plug->cached_rq);
2883-
if (!rq || rq->q != q)
2884-
return NULL;
28852882

28862883
if (blk_mq_attempt_bio_merge(q, *bio, nsegs)) {
28872884
*bio = NULL;
28882885
return NULL;
28892886
}
28902887

2888+
rq = rq_list_peek(&plug->cached_rq);
2889+
if (!rq || rq->q != q)
2890+
return NULL;
2891+
28912892
type = blk_mq_get_hctx_type((*bio)->bi_opf);
28922893
hctx_type = rq->mq_hctx->type;
28932894
if (type != hctx_type &&

0 commit comments

Comments
 (0)