]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hfsplus: use bdev_rw_virt in hfsplus_submit_bio
authorChristoph Hellwig <hch@lst.de>
Wed, 7 May 2025 12:04:43 +0000 (14:04 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 7 May 2025 13:31:08 +0000 (07:31 -0600)
Replace the code building a bio from a kernel direct map address and
submitting it synchronously with the bdev_rw_virt helper.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20250507120451.4000627-20-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/hfsplus/wrapper.c

index 74801911bc1cc45bc14dd1035f606186882f266c..30cf4fe78b3d24bcf4c36fa1b0c20687a91fd092 100644 (file)
@@ -48,47 +48,19 @@ struct hfsplus_wd {
 int hfsplus_submit_bio(struct super_block *sb, sector_t sector,
                       void *buf, void **data, blk_opf_t opf)
 {
-       const enum req_op op = opf & REQ_OP_MASK;
-       struct bio *bio;
-       int ret = 0;
-       u64 io_size;
-       loff_t start;
-       int offset;
+       u64 io_size = hfsplus_min_io_size(sb);
+       loff_t start = (loff_t)sector << HFSPLUS_SECTOR_SHIFT;
+       int offset = start & (io_size - 1);
+
+       if ((opf & REQ_OP_MASK) != REQ_OP_WRITE && data)
+               *data = (u8 *)buf + offset;
 
        /*
-        * Align sector to hardware sector size and find offset. We
-        * assume that io_size is a power of two, which _should_
-        * be true.
+        * Align sector to hardware sector size and find offset. We assume that
+        * io_size is a power of two, which _should_ be true.
         */
-       io_size = hfsplus_min_io_size(sb);
-       start = (loff_t)sector << HFSPLUS_SECTOR_SHIFT;
-       offset = start & (io_size - 1);
        sector &= ~((io_size >> HFSPLUS_SECTOR_SHIFT) - 1);
-
-       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;
-       }
-
-       ret = submit_bio_wait(bio);
-out:
-       bio_put(bio);
-       return ret < 0 ? ret : 0;
+       return bdev_rw_virt(sb->s_bdev, sector, buf, io_size, opf);
 }
 
 static int hfsplus_read_mdb(void *bufptr, struct hfsplus_wd *wd)