]> git.baikalelectronics.ru Git - kernel.git/commitdiff
dm: bio_alloc can't fail if it is allowed to sleep
authorChristoph Hellwig <hch@lst.de>
Mon, 24 Jan 2022 09:10:53 +0000 (10:10 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 2 Feb 2022 14:49:59 +0000 (07:49 -0700)
Remove handling of NULL returns from sleeping bio_alloc calls given that
those can't fail.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220124091107.642561-6-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/dm-crypt.c
drivers/md/dm-log-writes.c
drivers/md/dm-thin.c
drivers/md/dm-zoned-metadata.c
drivers/md/dm.c

index d4ae31558826a4bead8f3cb6d1adc0f093de8b5a..20abe3486aba17b522232fd091a5c4c746145c52 100644 (file)
@@ -1673,9 +1673,6 @@ retry:
                mutex_lock(&cc->bio_alloc_lock);
 
        clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, &cc->bs);
-       if (!clone)
-               goto out;
-
        clone_init(io, clone);
 
        remaining_size = size;
@@ -1702,7 +1699,7 @@ retry:
                bio_put(clone);
                clone = NULL;
        }
-out:
+
        if (unlikely(gfp_mask & __GFP_DIRECT_RECLAIM))
                mutex_unlock(&cc->bio_alloc_lock);
 
index 139b09b06eda9540d7d0258caaad4f651a7115ad..25f5e8d2d417bfe38a543ae800e11f73a043100d 100644 (file)
@@ -218,10 +218,6 @@ static int write_metadata(struct log_writes_c *lc, void *entry,
        size_t ret;
 
        bio = bio_alloc(GFP_KERNEL, 1);
-       if (!bio) {
-               DMERR("Couldn't alloc log bio");
-               goto error;
-       }
        bio->bi_iter.bi_size = 0;
        bio->bi_iter.bi_sector = sector;
        bio_set_dev(bio, lc->logdev->bdev);
@@ -276,11 +272,6 @@ static int write_inline_data(struct log_writes_c *lc, void *entry,
                atomic_inc(&lc->io_blocks);
 
                bio = bio_alloc(GFP_KERNEL, bio_pages);
-               if (!bio) {
-                       DMERR("Couldn't alloc inline data bio");
-                       goto error;
-               }
-
                bio->bi_iter.bi_size = 0;
                bio->bi_iter.bi_sector = sector;
                bio_set_dev(bio, lc->logdev->bdev);
@@ -322,7 +313,6 @@ static int write_inline_data(struct log_writes_c *lc, void *entry,
 error_bio:
        bio_free_pages(bio);
        bio_put(bio);
-error:
        put_io_block(lc);
        return -1;
 }
@@ -364,10 +354,6 @@ static int log_one_block(struct log_writes_c *lc,
 
        atomic_inc(&lc->io_blocks);
        bio = bio_alloc(GFP_KERNEL, bio_max_segs(block->vec_cnt));
-       if (!bio) {
-               DMERR("Couldn't alloc log bio");
-               goto error;
-       }
        bio->bi_iter.bi_size = 0;
        bio->bi_iter.bi_sector = sector;
        bio_set_dev(bio, lc->logdev->bdev);
@@ -387,10 +373,6 @@ static int log_one_block(struct log_writes_c *lc,
                        submit_bio(bio);
                        bio = bio_alloc(GFP_KERNEL,
                                        bio_max_segs(block->vec_cnt - i));
-                       if (!bio) {
-                               DMERR("Couldn't alloc log bio");
-                               goto error;
-                       }
                        bio->bi_iter.bi_size = 0;
                        bio->bi_iter.bi_sector = sector;
                        bio_set_dev(bio, lc->logdev->bdev);
index ec119d2422d5de8eeb6f0e582c309d1bc3ab116e..76a9c2e9aeeeacc44551c7e060ccfce3b901eb2b 100644 (file)
@@ -1180,24 +1180,17 @@ static void process_prepared_discard_passdown_pt1(struct dm_thin_new_mapping *m)
        }
 
        discard_parent = bio_alloc(GFP_NOIO, 1);
-       if (!discard_parent) {
-               DMWARN("%s: unable to allocate top level discard bio for passdown. Skipping passdown.",
-                      dm_device_name(tc->pool->pool_md));
-               queue_passdown_pt2(m);
+       discard_parent->bi_end_io = passdown_endio;
+       discard_parent->bi_private = m;
 
-       } else {
-               discard_parent->bi_end_io = passdown_endio;
-               discard_parent->bi_private = m;
-
-               if (m->maybe_shared)
-                       passdown_double_checking_shared_status(m, discard_parent);
-               else {
-                       struct discard_op op;
+       if (m->maybe_shared)
+               passdown_double_checking_shared_status(m, discard_parent);
+       else {
+               struct discard_op op;
 
-                       begin_discard(&op, tc, discard_parent);
-                       r = issue_discard(&op, m->data_block, data_end);
-                       end_discard(&op, r);
-               }
+               begin_discard(&op, tc, discard_parent);
+               r = issue_discard(&op, m->data_block, data_end);
+               end_discard(&op, r);
        }
 }
 
index ee4626d085574337adec04c717fac539cb9e317b..5718b83cc7182359daf5fdb914e12be793f16d9b 100644 (file)
@@ -551,10 +551,6 @@ static struct dmz_mblock *dmz_get_mblock_slow(struct dmz_metadata *zmd,
                return ERR_PTR(-ENOMEM);
 
        bio = bio_alloc(GFP_NOIO, 1);
-       if (!bio) {
-               dmz_free_mblock(zmd, mblk);
-               return ERR_PTR(-ENOMEM);
-       }
 
        spin_lock(&zmd->mblk_lock);
 
@@ -726,10 +722,6 @@ static int dmz_write_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk,
                return -EIO;
 
        bio = bio_alloc(GFP_NOIO, 1);
-       if (!bio) {
-               set_bit(DMZ_META_ERROR, &mblk->state);
-               return -ENOMEM;
-       }
 
        set_bit(DMZ_META_WRITING, &mblk->state);
 
@@ -760,9 +752,6 @@ static int dmz_rdwr_block(struct dmz_dev *dev, int op,
                return -EIO;
 
        bio = bio_alloc(GFP_NOIO, 1);
-       if (!bio)
-               return -ENOMEM;
-
        bio->bi_iter.bi_sector = dmz_blk2sect(block);
        bio_set_dev(bio, dev->bdev);
        bio_set_op_attrs(bio, op, REQ_SYNC | REQ_META | REQ_PRIO);
index dcbd6d201619d0fd62931af3de1e073648852d1f..e431f72c10bf44cabe4db62d4d20b27495758f15 100644 (file)
@@ -520,8 +520,6 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio)
        struct bio *clone;
 
        clone = bio_alloc_bioset(GFP_NOIO, 0, &md->io_bs);
-       if (!clone)
-               return NULL;
 
        tio = container_of(clone, struct dm_target_io, clone);
        tio->inside_dm_io = true;