Merge tag 'drm-next-2021-11-12' of git://anongit.freedesktop.org/drm/drm
[linux-2.6-microblaze.git] / block / blk-mq-sched.c
index c62b966..4be652f 100644 (file)
@@ -370,15 +370,20 @@ bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
        bool ret = false;
        enum hctx_type type;
 
-       if (e && e->type->ops.bio_merge)
-               return e->type->ops.bio_merge(q, bio, nr_segs);
+       if (bio_queue_enter(bio))
+               return false;
+
+       if (e && e->type->ops.bio_merge) {
+               ret = e->type->ops.bio_merge(q, bio, nr_segs);
+               goto out_put;
+       }
 
        ctx = blk_mq_get_ctx(q);
        hctx = blk_mq_map_queue(q, bio->bi_opf, ctx);
        type = hctx->type;
        if (!(hctx->flags & BLK_MQ_F_SHOULD_MERGE) ||
            list_empty_careful(&ctx->rq_lists[type]))
-               return false;
+               goto out_put;
 
        /* default per sw-queue merge */
        spin_lock(&ctx->lock);
@@ -391,6 +396,8 @@ bool blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,
                ret = true;
 
        spin_unlock(&ctx->lock);
+out_put:
+       blk_queue_exit(q);
        return ret;
 }
 
@@ -497,7 +504,7 @@ void blk_mq_sched_insert_requests(struct blk_mq_hw_ctx *hctx,
                 * busy in case of 'none' scheduler, and this way may save
                 * us one extra enqueue & dequeue to sw queue.
                 */
-               if (!hctx->dispatch_busy && !e && !run_queue_async) {
+               if (!hctx->dispatch_busy && !run_queue_async) {
                        blk_mq_try_issue_list_directly(hctx, list);
                        if (list_empty(list))
                                goto out;