OSDN Git Service

block: move blk_crypto_bio_prep() out of blk-mq.c
authorMing Lei <ming.lei@redhat.com>
Wed, 16 Feb 2022 04:45:08 +0000 (12:45 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 17 Feb 2022 02:42:27 +0000 (19:42 -0700)
blk_crypto_bio_prep() is called for both bio based and blk-mq drivers,
so move it out of blk-mq.c, then we can unify this kind of handling.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220216044514.2903784-3-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-core.c
block/blk-mq.c

index d4a0236..f03fff1 100644 (file)
@@ -783,24 +783,19 @@ end_io:
        return false;
 }
 
-static void __submit_bio_fops(struct gendisk *disk, struct bio *bio)
-{
-       if (blk_crypto_bio_prep(&bio)) {
-               if (likely(bio_queue_enter(bio) == 0)) {
-                       disk->fops->submit_bio(bio);
-                       blk_queue_exit(disk->queue);
-               }
-       }
-}
-
 static void __submit_bio(struct bio *bio)
 {
        struct gendisk *disk = bio->bi_bdev->bd_disk;
 
-       if (!disk->fops->submit_bio)
+       if (unlikely(!blk_crypto_bio_prep(&bio)))
+               return;
+
+       if (!disk->fops->submit_bio) {
                blk_mq_submit_bio(bio);
-       else
-               __submit_bio_fops(disk, bio);
+       } else if (likely(bio_queue_enter(bio) == 0)) {
+               disk->fops->submit_bio(bio);
+               blk_queue_exit(disk->queue);
+       }
 }
 
 /*
index 886836a..7ca0b47 100644 (file)
@@ -2788,9 +2788,6 @@ void blk_mq_submit_bio(struct bio *bio)
        unsigned int nr_segs = 1;
        blk_status_t ret;
 
-       if (unlikely(!blk_crypto_bio_prep(&bio)))
-               return;
-
        blk_queue_bounce(q, &bio);
        if (blk_may_split(q, bio))
                __blk_queue_split(q, &bio, &nr_segs);