f2fs: fix to release discard entries during checkpoint
commit 2dd15654ac0abe587a245a09a7823bbbd588bfb7 upstream. In f2fs_fill_super, if there is any IO error occurs during recovery, cached discard entries will be leaked, in order to avoid this, make write_checkpoint() handle memory release by itself, besides, move clear_prefree_segments to write_checkpoint for readability. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
311aa690ef
commit
ab38818bdd
2 changed files with 4 additions and 2 deletions
|
@ -1187,7 +1187,6 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
|
||||||
if (unlikely(f2fs_cp_error(sbi)))
|
if (unlikely(f2fs_cp_error(sbi)))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
clear_prefree_segments(sbi, cpc);
|
|
||||||
clear_sbi_flag(sbi, SBI_IS_DIRTY);
|
clear_sbi_flag(sbi, SBI_IS_DIRTY);
|
||||||
clear_sbi_flag(sbi, SBI_NEED_CP);
|
clear_sbi_flag(sbi, SBI_NEED_CP);
|
||||||
__set_cp_next_pack(sbi);
|
__set_cp_next_pack(sbi);
|
||||||
|
@ -1264,6 +1263,10 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
|
||||||
|
|
||||||
/* unlock all the fs_lock[] in do_checkpoint() */
|
/* unlock all the fs_lock[] in do_checkpoint() */
|
||||||
err = do_checkpoint(sbi, cpc);
|
err = do_checkpoint(sbi, cpc);
|
||||||
|
if (err)
|
||||||
|
release_discard_addrs(sbi);
|
||||||
|
else
|
||||||
|
clear_prefree_segments(sbi, cpc);
|
||||||
|
|
||||||
unblock_operations(sbi);
|
unblock_operations(sbi);
|
||||||
stat_inc_cp_count(sbi->stat_info);
|
stat_inc_cp_count(sbi->stat_info);
|
||||||
|
|
|
@ -738,7 +738,6 @@ static void f2fs_put_super(struct super_block *sb)
|
||||||
* In addition, EIO will skip do checkpoint, we need this as well.
|
* In addition, EIO will skip do checkpoint, we need this as well.
|
||||||
*/
|
*/
|
||||||
release_ino_entry(sbi, true);
|
release_ino_entry(sbi, true);
|
||||||
release_discard_addrs(sbi);
|
|
||||||
|
|
||||||
f2fs_leave_shrinker(sbi);
|
f2fs_leave_shrinker(sbi);
|
||||||
mutex_unlock(&sbi->umount_mutex);
|
mutex_unlock(&sbi->umount_mutex);
|
||||||
|
|
Loading…
Add table
Reference in a new issue