diff options
| author | Chao Yu <yuchao0@huawei.com> | 2018-01-10 18:18:52 +0800 |
|---|---|---|
| committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2018-02-07 18:05:58 -0800 |
| commit | 4dca47531eb037d663a903508f636f8758cbc172 (patch) | |
| tree | 289ac73a807466daa7bab147e0d32f7dd4d70304 | |
| parent | 999f806a7c9e29e74019e6c2566be04d54c956ea (diff) | |
f2fs: speed up defragment on sparse file
We have supported to get next page offset with valid mapping crossing
hole in f2fs_map_blocks, utilizing it to speed up defragment on sparse
file.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
| -rw-r--r-- | fs/f2fs/data.c | 6 | ||||
| -rw-r--r-- | fs/f2fs/file.c | 11 |
2 files changed, 11 insertions, 6 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 95a649467272..ec6698bc8021 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1016,8 +1016,12 @@ next_block: *map->m_next_pgofs = pgofs + 1; goto sync_out; } - if (flag != F2FS_GET_BLOCK_FIEMAP) + if (flag != F2FS_GET_BLOCK_FIEMAP) { + /* for defragment case */ + if (map->m_next_pgofs) + *map->m_next_pgofs = pgofs + 1; goto sync_out; + } } } diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 29c1aed384f6..02c20d55cf90 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2047,10 +2047,10 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, struct f2fs_defragment *range) { struct inode *inode = file_inode(filp); - struct f2fs_map_blocks map = { .m_next_pgofs = NULL, - .m_next_extent = NULL, .m_seg_type = NO_CHECK_TYPE }; + struct f2fs_map_blocks map = { .m_next_extent = NULL, + .m_seg_type = NO_CHECK_TYPE }; struct extent_info ei = {0,0,0}; - pgoff_t pg_start, pg_end; + pgoff_t pg_start, pg_end, next_pgofs; unsigned int blk_per_seg = sbi->blocks_per_seg; unsigned int total = 0, sec_num; block_t blk_end = 0; @@ -2084,6 +2084,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, } map.m_lblk = pg_start; + map.m_next_pgofs = &next_pgofs; /* * lookup mapping info in dnode page cache, skip defragmenting if all @@ -2097,7 +2098,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, goto out; if (!(map.m_flags & F2FS_MAP_FLAGS)) { - map.m_lblk++; + map.m_lblk = next_pgofs; continue; } @@ -2142,7 +2143,7 @@ do_map: goto clear_out; if (!(map.m_flags & F2FS_MAP_FLAGS)) { - map.m_lblk++; + map.m_lblk = next_pgofs; continue; } |
