Back in October 2014, I proposed an improvement to fiemap to accomodate very large sparse files. This was done because the existing blockmap-based code skips holes one block at a time, which is extremely slow when it comes to large holes. For example, doing fiemap on a 1PB file whose only byte exists at EOF can take an extremely long time. To recreate: dd if=/dev/zero of=/mnt/holey-P bs=1 count=1 seek=1P time filefrag -v /mnt/holey-P At that time, someone suggested I use the iomap interface proposed by Dave Chinner a long time ago, and so my patches never got off the ground (until now). Since then, Christoph apparently added the basics of iomap to exportfs.h. which today is minimal, and limited to exportfs users. On 11 January 2016, I posted a vfs patch that expanded the use of the iomap infrastructure, but iomap was added to address_space_operations. On 21 January 2016, Jan Kara suggested it NOT be included as an a_op, but rather, to have the new iomap function be passed in, similar to get_blocks(), along with some pretty generic flags, rather than a set of commands. This v2 patch set is my latest attempt to implement Jan's suggestions. The first patch moves the iomap infrastructure from exportfs.h to its own iomap.h. It also adds some basic declares for the iomap type and flags. The second patch adds a new __generic_iomap_fiemap interface to be used by file systems who want it. My original version of this function looked nearly identical to the blockmap version, but this one is smaller and simpler. So if people don't like my implementation, I can revert to that one. The third patch introduces a new __gfs2_io_map function to the GFS2 file system. To keep things simple, I omitted block allocations from this function for now. The fourth patch hooks the new function into GFS2's fiemap to take advantage of the new code. The result: for a 1PB sparse file, filefrag takes milliseconds rather than a week. Signed-off-by: Bob Peterson <rpeterso@xxxxxxxxxx> --- Bob Peterson (4): VFS: move iomap infrastructure from exportfs.h, add iomap to aops VFS: Add new __generic_iomap_fiemap interface GFS2: Add function __gfs2_io_map GFS2: Use new iomap interface for fiemap fs/gfs2/bmap.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++ fs/gfs2/bmap.h | 2 + fs/gfs2/inode.c | 4 +- fs/ioctl.c | 97 ++++++++++++++++++++++++++++ include/linux/exportfs.h | 16 +---- include/linux/fs.h | 12 +++- include/linux/iomap.h | 29 +++++++++ 7 files changed, 302 insertions(+), 18 deletions(-) create mode 100644 include/linux/iomap.h -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html