From: Christoph Hellwig Date: Fri, 21 Mar 2025 12:48:00 +0000 (+0100) Subject: hfsplus: use bio_add_virt_nofail X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fblock-new-bio-helpers;p=users%2Fhch%2Fmisc.git hfsplus: use bio_add_virt_nofail 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 --- diff --git a/fs/hfsplus/wrapper.c b/fs/hfsplus/wrapper.c index 74801911bc1c..96c072f26808 100644 --- a/fs/hfsplus/wrapper.c +++ b/fs/hfsplus/wrapper.c @@ -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)