ext2: use iomap_fiemap to implement ->fiemap

Switch from generic_block_fiemap to use the iomap version.  The only
interesting part is that ext2_get_blocks gets confused when being
asked for overly long ranges, so copy over the limit to the inode
size from generic_block_fiemap into ext2_fiemap.

Link: https://lore.kernel.org/r/20210720133341.405438-3-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Christoph Hellwig 2021-07-20 15:33:39 +02:00 committed by Jan Kara
parent 9583db2332
commit 8b1e7076d2
2 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
config EXT2_FS
tristate "Second extended fs support"
select FS_IOMAP
help
Ext2 is a standard Linux file system for hard disks.

View File

@ -855,8 +855,14 @@ const struct iomap_ops ext2_iomap_ops = {
int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
u64 start, u64 len)
{
return generic_block_fiemap(inode, fieinfo, start, len,
ext2_get_block);
int ret;
inode_lock(inode);
len = min_t(u64, len, i_size_read(inode));
ret = iomap_fiemap(inode, fieinfo, start, len, &ext2_iomap_ops);
inode_unlock(inode);
return ret;
}
static int ext2_writepage(struct page *page, struct writeback_control *wbc)