From eb2a3ce5a998974e95e1e6cb024ed3c4d3360f1e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 21 Mar 2025 13:48:00 +0100 Subject: [PATCH] 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 --- fs/hfsplus/wrapper.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) 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) -- 2.50.1