mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 17:44:14 +08:00
f2fs: fix to retry fill_super only if recovery failed
With current retry mechanism in f2fs_fill_super, first fill_super fails due to no memory, then second fill_super runs w/o recovery, if we succeed, we may lose fsynced data, it doesn't make sense. Let's retry fill_super only if it occurs non-ENOMEM error during recovery. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
bc73a4b241
commit
aa2c8c43e4
@ -3053,10 +3053,11 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
|
|||||||
struct f2fs_super_block *raw_super;
|
struct f2fs_super_block *raw_super;
|
||||||
struct inode *root;
|
struct inode *root;
|
||||||
int err;
|
int err;
|
||||||
bool retry = true, need_fsck = false;
|
bool skip_recovery = false, need_fsck = false;
|
||||||
char *options = NULL;
|
char *options = NULL;
|
||||||
int recovery, i, valid_super_block;
|
int recovery, i, valid_super_block;
|
||||||
struct curseg_info *seg_i;
|
struct curseg_info *seg_i;
|
||||||
|
int retry_cnt = 1;
|
||||||
|
|
||||||
try_onemore:
|
try_onemore:
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
@ -3345,7 +3346,7 @@ try_onemore:
|
|||||||
goto free_meta;
|
goto free_meta;
|
||||||
|
|
||||||
if (unlikely(is_set_ckpt_flags(sbi, CP_DISABLED_FLAG)))
|
if (unlikely(is_set_ckpt_flags(sbi, CP_DISABLED_FLAG)))
|
||||||
goto skip_recovery;
|
goto reset_checkpoint;
|
||||||
|
|
||||||
/* recover fsynced data */
|
/* recover fsynced data */
|
||||||
if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) {
|
if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) {
|
||||||
@ -3362,11 +3363,13 @@ try_onemore:
|
|||||||
if (need_fsck)
|
if (need_fsck)
|
||||||
set_sbi_flag(sbi, SBI_NEED_FSCK);
|
set_sbi_flag(sbi, SBI_NEED_FSCK);
|
||||||
|
|
||||||
if (!retry)
|
if (skip_recovery)
|
||||||
goto skip_recovery;
|
goto reset_checkpoint;
|
||||||
|
|
||||||
err = f2fs_recover_fsync_data(sbi, false);
|
err = f2fs_recover_fsync_data(sbi, false);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
|
if (err != -ENOMEM)
|
||||||
|
skip_recovery = true;
|
||||||
need_fsck = true;
|
need_fsck = true;
|
||||||
f2fs_msg(sb, KERN_ERR,
|
f2fs_msg(sb, KERN_ERR,
|
||||||
"Cannot recover all fsync data errno=%d", err);
|
"Cannot recover all fsync data errno=%d", err);
|
||||||
@ -3382,7 +3385,7 @@ try_onemore:
|
|||||||
goto free_meta;
|
goto free_meta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
skip_recovery:
|
reset_checkpoint:
|
||||||
/* f2fs_recover_fsync_data() cleared this already */
|
/* f2fs_recover_fsync_data() cleared this already */
|
||||||
clear_sbi_flag(sbi, SBI_POR_DOING);
|
clear_sbi_flag(sbi, SBI_POR_DOING);
|
||||||
|
|
||||||
@ -3428,7 +3431,7 @@ skip_recovery:
|
|||||||
sync_free_meta:
|
sync_free_meta:
|
||||||
/* safe to flush all the data */
|
/* safe to flush all the data */
|
||||||
sync_filesystem(sbi->sb);
|
sync_filesystem(sbi->sb);
|
||||||
retry = false;
|
retry_cnt = 0;
|
||||||
|
|
||||||
free_meta:
|
free_meta:
|
||||||
#ifdef CONFIG_QUOTA
|
#ifdef CONFIG_QUOTA
|
||||||
@ -3488,8 +3491,8 @@ free_sbi:
|
|||||||
kvfree(sbi);
|
kvfree(sbi);
|
||||||
|
|
||||||
/* give only one another chance */
|
/* give only one another chance */
|
||||||
if (retry) {
|
if (retry_cnt > 0 && skip_recovery) {
|
||||||
retry = false;
|
retry_cnt--;
|
||||||
shrink_dcache_sb(sb);
|
shrink_dcache_sb(sb);
|
||||||
goto try_onemore;
|
goto try_onemore;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user