aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiao Ni <[email protected]>2023-02-09 11:19:30 +0800
committerJens Axboe <[email protected]>2023-02-09 08:11:25 -0700
commit23f3e3272e7a4d9fb870485cd6df1e4f9539282c (patch)
tree4db43c1367b06fd524083a2a7539d0397ed44fac
parentdcb52201435197c56154ff7c8cb139284d254bda (diff)
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]>
-rw-r--r--block/blk-mq.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 89b4dd81ae17..08093d4348dd 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2879,15 +2879,16 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
if (!plug)
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)) {
*bio = 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);
hctx_type = rq->mq_hctx->type;
if (type != hctx_type &&