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

hpfs: use iomap_fiemap to implement ->fiemap

hpfs is the last user of generic_block_fiemap, so add a trivial
iomap_ops based on the ext2 version and switch to iomap_fiemap.

Link: https://lore.kernel.org/r/20210720133341.405438-4-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Christoph Hellwig and committed by
Jan Kara
e0cba89d 8b1e7076

+51 -1
+1
fs/hpfs/Kconfig
··· 2 2 config HPFS_FS 3 3 tristate "OS/2 HPFS file system support" 4 4 depends on BLOCK 5 + select FS_IOMAP 5 6 help 6 7 OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS 7 8 is the file system used for organizing files on OS/2 hard disk
+50 -1
fs/hpfs/file.c
··· 9 9 10 10 #include "hpfs_fn.h" 11 11 #include <linux/mpage.h> 12 + #include <linux/iomap.h> 12 13 #include <linux/fiemap.h> 13 14 14 15 #define BLOCKS(size) (((size) + 511) >> 9) ··· 117 116 return r; 118 117 } 119 118 119 + static int hpfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length, 120 + unsigned flags, struct iomap *iomap, struct iomap *srcmap) 121 + { 122 + struct super_block *sb = inode->i_sb; 123 + unsigned int blkbits = inode->i_blkbits; 124 + unsigned int n_secs; 125 + secno s; 126 + 127 + if (WARN_ON_ONCE(flags & (IOMAP_WRITE | IOMAP_ZERO))) 128 + return -EINVAL; 129 + 130 + iomap->bdev = inode->i_sb->s_bdev; 131 + iomap->offset = offset; 132 + 133 + hpfs_lock(sb); 134 + s = hpfs_bmap(inode, offset >> blkbits, &n_secs); 135 + if (s) { 136 + n_secs = hpfs_search_hotfix_map_for_range(sb, s, 137 + min_t(loff_t, n_secs, length)); 138 + if (unlikely(!n_secs)) { 139 + s = hpfs_search_hotfix_map(sb, s); 140 + n_secs = 1; 141 + } 142 + iomap->type = IOMAP_MAPPED; 143 + iomap->flags = IOMAP_F_MERGED; 144 + iomap->addr = (u64)s << blkbits; 145 + iomap->length = (u64)n_secs << blkbits; 146 + } else { 147 + iomap->type = IOMAP_HOLE; 148 + iomap->addr = IOMAP_NULL_ADDR; 149 + iomap->length = 1 << blkbits; 150 + } 151 + 152 + hpfs_unlock(sb); 153 + return 0; 154 + } 155 + 156 + static const struct iomap_ops hpfs_iomap_ops = { 157 + .iomap_begin = hpfs_iomap_begin, 158 + }; 159 + 120 160 static int hpfs_readpage(struct file *file, struct page *page) 121 161 { 122 162 return mpage_readpage(page, hpfs_get_block); ··· 234 192 235 193 static int hpfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 len) 236 194 { 237 - return generic_block_fiemap(inode, fieinfo, start, len, hpfs_get_block); 195 + int ret; 196 + 197 + inode_lock(inode); 198 + len = min_t(u64, len, i_size_read(inode)); 199 + ret = iomap_fiemap(inode, fieinfo, start, len, &hpfs_iomap_ops); 200 + inode_unlock(inode); 201 + 202 + return ret; 238 203 } 239 204 240 205 const struct address_space_operations hpfs_aops = {