Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd214422 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim
Browse files

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: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 6bce9632
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -1016,10 +1016,14 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
					*map->m_next_pgofs = pgofs + 1;
					*map->m_next_pgofs = pgofs + 1;
				goto sync_out;
				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;
				goto sync_out;
			}
			}
		}
		}
	}


	if (flag == F2FS_GET_BLOCK_PRE_AIO)
	if (flag == F2FS_GET_BLOCK_PRE_AIO)
		goto skip;
		goto skip;
+6 −5
Original line number Original line Diff line number Diff line
@@ -2043,10 +2043,10 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
					struct f2fs_defragment *range)
					struct f2fs_defragment *range)
{
{
	struct inode *inode = file_inode(filp);
	struct inode *inode = file_inode(filp);
	struct f2fs_map_blocks map = { .m_next_pgofs = NULL,
	struct f2fs_map_blocks map = { .m_next_extent = NULL,
			.m_next_extent = NULL, .m_seg_type = NO_CHECK_TYPE };
					.m_seg_type = NO_CHECK_TYPE };
	struct extent_info ei = {0,0,0};
	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 blk_per_seg = sbi->blocks_per_seg;
	unsigned int total = 0, sec_num;
	unsigned int total = 0, sec_num;
	block_t blk_end = 0;
	block_t blk_end = 0;
@@ -2080,6 +2080,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
	}
	}


	map.m_lblk = pg_start;
	map.m_lblk = pg_start;
	map.m_next_pgofs = &next_pgofs;


	/*
	/*
	 * lookup mapping info in dnode page cache, skip defragmenting if all
	 * lookup mapping info in dnode page cache, skip defragmenting if all
@@ -2093,7 +2094,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
			goto out;
			goto out;


		if (!(map.m_flags & F2FS_MAP_FLAGS)) {
		if (!(map.m_flags & F2FS_MAP_FLAGS)) {
			map.m_lblk++;
			map.m_lblk = next_pgofs;
			continue;
			continue;
		}
		}


@@ -2138,7 +2139,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
			goto clear_out;
			goto clear_out;


		if (!(map.m_flags & F2FS_MAP_FLAGS)) {
		if (!(map.m_flags & F2FS_MAP_FLAGS)) {
			map.m_lblk++;
			map.m_lblk = next_pgofs;
			continue;
			continue;
		}
		}