Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

hfsplus: use bdev_rw_virt in hfsplus_submit_bio

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>

authored by

Christoph Hellwig and committed by
Jens Axboe
15c9d5f6 760aa181

+10 -38
+10 -38
fs/hfsplus/wrapper.c
··· 48 48 int hfsplus_submit_bio(struct super_block *sb, sector_t sector, 49 49 void *buf, void **data, blk_opf_t opf) 50 50 { 51 - const enum req_op op = opf & REQ_OP_MASK; 52 - struct bio *bio; 53 - int ret = 0; 54 - u64 io_size; 55 - loff_t start; 56 - int offset; 51 + u64 io_size = hfsplus_min_io_size(sb); 52 + loff_t start = (loff_t)sector << HFSPLUS_SECTOR_SHIFT; 53 + int offset = start & (io_size - 1); 57 54 58 - /* 59 - * Align sector to hardware sector size and find offset. We 60 - * assume that io_size is a power of two, which _should_ 61 - * be true. 62 - */ 63 - io_size = hfsplus_min_io_size(sb); 64 - start = (loff_t)sector << HFSPLUS_SECTOR_SHIFT; 65 - offset = start & (io_size - 1); 66 - sector &= ~((io_size >> HFSPLUS_SECTOR_SHIFT) - 1); 67 - 68 - bio = bio_alloc(sb->s_bdev, 1, opf, GFP_NOIO); 69 - bio->bi_iter.bi_sector = sector; 70 - 71 - if (op != REQ_OP_WRITE && data) 55 + if ((opf & REQ_OP_MASK) != REQ_OP_WRITE && data) 72 56 *data = (u8 *)buf + offset; 73 57 74 - while (io_size > 0) { 75 - unsigned int page_offset = offset_in_page(buf); 76 - unsigned int len = min_t(unsigned int, PAGE_SIZE - page_offset, 77 - io_size); 78 - 79 - ret = bio_add_page(bio, virt_to_page(buf), len, page_offset); 80 - if (ret != len) { 81 - ret = -EIO; 82 - goto out; 83 - } 84 - io_size -= len; 85 - buf = (u8 *)buf + len; 86 - } 87 - 88 - ret = submit_bio_wait(bio); 89 - out: 90 - bio_put(bio); 91 - return ret < 0 ? ret : 0; 58 + /* 59 + * Align sector to hardware sector size and find offset. We assume that 60 + * io_size is a power of two, which _should_ be true. 61 + */ 62 + sector &= ~((io_size >> HFSPLUS_SECTOR_SHIFT) - 1); 63 + return bdev_rw_virt(sb->s_bdev, sector, buf, io_size, opf); 92 64 } 93 65 94 66 static int hfsplus_read_mdb(void *bufptr, struct hfsplus_wd *wd)