Commit 23f3e327 authored by Xiao Ni's avatar Xiao Ni Committed by Jens Axboe

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: default avatarXiao Ni <xni@redhat.com>
Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230209031930.27354-1-xni@redhat.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent dcb52201
...@@ -2879,15 +2879,16 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q, ...@@ -2879,15 +2879,16 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
if (!plug) if (!plug)
return NULL; return NULL;
rq = rq_list_peek(&plug->cached_rq);
if (!rq || rq->q != q)
return NULL;
if (blk_mq_attempt_bio_merge(q, *bio, nsegs)) { if (blk_mq_attempt_bio_merge(q, *bio, nsegs)) {
*bio = NULL; *bio = NULL;
return NULL; return NULL;
} }
rq = rq_list_peek(&plug->cached_rq);
if (!rq || rq->q != q)
return NULL;
type = blk_mq_get_hctx_type((*bio)->bi_opf); type = blk_mq_get_hctx_type((*bio)->bi_opf);
hctx_type = rq->mq_hctx->type; hctx_type = rq->mq_hctx->type;
if (type != hctx_type && if (type != hctx_type &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment