]> www.infradead.org Git - users/hch/misc.git/commitdiff
hfsplus: use bio_add_virt_nofail block-new-bio-helpers
authorChristoph Hellwig <hch@lst.de>
Fri, 21 Mar 2025 12:48:00 +0000 (13:48 +0100)
committerChristoph Hellwig <hch@lst.de>
Fri, 21 Mar 2025 13:17:41 +0000 (14:17 +0100)
Use bio_add_virt_nofail to add a single buffer to a bio instead of a loop
calling into bio_add_page for each PAGE_SIZE granularity chunk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/hfsplus/wrapper.c

index 74801911bc1cc45bc14dd1035f606186882f266c..96c072f268086c45f5a71f5599700ae7d46601a0 100644 (file)
@@ -67,28 +67,12 @@ int hfsplus_submit_bio(struct super_block *sb, sector_t sector,
 
        bio = bio_alloc(sb->s_bdev, 1, opf, GFP_NOIO);
        bio->bi_iter.bi_sector = sector;
-
        if (op != REQ_OP_WRITE && data)
                *data = (u8 *)buf + offset;
-
-       while (io_size > 0) {
-               unsigned int page_offset = offset_in_page(buf);
-               unsigned int len = min_t(unsigned int, PAGE_SIZE - page_offset,
-                                        io_size);
-
-               ret = bio_add_page(bio, virt_to_page(buf), len, page_offset);
-               if (ret != len) {
-                       ret = -EIO;
-                       goto out;
-               }
-               io_size -= len;
-               buf = (u8 *)buf + len;
-       }
-
+       bio_add_virt_nofail(bio, buf, io_size);
        ret = submit_bio_wait(bio);
-out:
        bio_put(bio);
-       return ret < 0 ? ret : 0;
+       return ret;
 }
 
 static int hfsplus_read_mdb(void *bufptr, struct hfsplus_wd *wd)