]> www.infradead.org Git - users/hch/misc.git/commitdiff
dm-integrity: use bio_add_virt_nofail
authorChristoph Hellwig <hch@lst.de>
Fri, 21 Mar 2025 12:46:36 +0000 (13:46 +0100)
committerChristoph Hellwig <hch@lst.de>
Fri, 21 Mar 2025 13:17:41 +0000 (14:17 +0100)
Convert the __bio_add_page(..., virt_to_page(out), ...) pattern to the
bio_add_virt_nofail helper implementing it, and do the same for the
similar pattern using bio_add_page for adding the first segment after
a bio allocation as that can't fail either.

Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/md/dm-integrity.c

index e743657379f7fc166d671e337bc1bdd2d51ecec5..86874746c884cb8481b30152f8a60aad3e7316c2 100644 (file)
@@ -2558,14 +2558,8 @@ static void dm_integrity_inline_recheck(struct work_struct *w)
                char *mem;
 
                outgoing_bio = bio_alloc_bioset(ic->dev->bdev, 1, REQ_OP_READ, GFP_NOIO, &ic->recheck_bios);
-
-               r = bio_add_page(outgoing_bio, virt_to_page(outgoing_data), ic->sectors_per_block << SECTOR_SHIFT, 0);
-               if (unlikely(r != (ic->sectors_per_block << SECTOR_SHIFT))) {
-                       bio_put(outgoing_bio);
-                       bio->bi_status = BLK_STS_RESOURCE;
-                       bio_endio(bio);
-                       return;
-               }
+               bio_add_virt_nofail(outgoing_bio, outgoing_data,
+                               ic->sectors_per_block << SECTOR_SHIFT);
 
                bip = bio_integrity_alloc(outgoing_bio, GFP_NOIO, 1);
                if (IS_ERR(bip)) {
@@ -3212,7 +3206,8 @@ next_chunk:
 
        bio = bio_alloc_bioset(ic->dev->bdev, 1, REQ_OP_READ, GFP_NOIO, &ic->recalc_bios);
        bio->bi_iter.bi_sector = ic->start + SB_SECTORS + range.logical_sector;
-       __bio_add_page(bio, virt_to_page(recalc_buffer), range.n_sectors << SECTOR_SHIFT, offset_in_page(recalc_buffer));
+       bio_add_virt_nofail(bio, recalc_buffer,
+                       range.n_sectors << SECTOR_SHIFT);
        r = submit_bio_wait(bio);
        bio_put(bio);
        if (unlikely(r)) {
@@ -3229,7 +3224,8 @@ next_chunk:
 
        bio = bio_alloc_bioset(ic->dev->bdev, 1, REQ_OP_WRITE, GFP_NOIO, &ic->recalc_bios);
        bio->bi_iter.bi_sector = ic->start + SB_SECTORS + range.logical_sector;
-       __bio_add_page(bio, virt_to_page(recalc_buffer), range.n_sectors << SECTOR_SHIFT, offset_in_page(recalc_buffer));
+       bio_add_virt_nofail(bio, recalc_buffer,
+                       range.n_sectors << SECTOR_SHIFT);
 
        bip = bio_integrity_alloc(bio, GFP_NOIO, 1);
        if (unlikely(IS_ERR(bip))) {