Revert "block: Merge bio before checking ->cached_rq" block-6.3 block-6.3-2023-04-21
authorMing Lei <ming.lei@redhat.com>
Thu, 20 Apr 2023 11:20:18 +0000 (19:20 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 20 Apr 2023 12:54:17 +0000 (06:54 -0600)
This reverts commit 23f3e3272e7a4d9fb870485cd6df1e4f9539282c.

blk-mq sched bio merge still needs request to grab queue usage counter,
so we can't simply call blk_mq_attempt_bio_merge() when queue usage
counter isn't held.

Fixes: 23f3e3272e7a ("block: Merge bio before checking ->cached_rq")
Cc: Xiao Ni <xni@redhat.com>
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230420112018.1108058-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c

index f0ea9dcfb966272e410fbe6e431b560268d0b30d..2831f78f86a033dbd0131a5da659741728d6a2c6 100644 (file)
@@ -2878,16 +2878,15 @@ 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 &&