diff options
author | Chao Yu | 2019-07-29 23:02:29 +0800 |
---|---|---|
committer | Jaegeuk Kim | 2019-08-23 07:57:13 -0700 |
commit | d3a1a0e1bf5d4d2107d6b485c5d33e65acaa7cf6 (patch) | |
tree | 63c87ffa83c892c3508698509c683c3db508353f /fs/f2fs/file.c | |
parent | 33ac18a15c880d253565c08e8cec3ee4c8a76657 (diff) |
f2fs: fix to migrate blocks correctly during defragment
During defragment, we missed to trigger fragmented blocks migration
for below condition:
In defragment region:
- total number of valid blocks is smaller than 512;
- the tail part of the region are all holes;
In addtion, return zero to user via range->len if there is no
fragmented blocks.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r-- | fs/f2fs/file.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 2d392887b92d..16f39c0c457d 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2383,8 +2383,10 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, map.m_lblk += map.m_len; } - if (!fragmented) + if (!fragmented) { + total = 0; goto out; + } sec_num = DIV_ROUND_UP(total, BLKS_PER_SEC(sbi)); @@ -2414,7 +2416,7 @@ do_map: if (!(map.m_flags & F2FS_MAP_FLAGS)) { map.m_lblk = next_pgofs; - continue; + goto check; } set_inode_flag(inode, FI_DO_DEFRAG); @@ -2438,8 +2440,8 @@ do_map: } map.m_lblk = idx; - - if (idx < pg_end && cnt < blk_per_seg) +check: + if (map.m_lblk < pg_end && cnt < blk_per_seg) goto do_map; clear_inode_flag(inode, FI_DO_DEFRAG); |