Skip to content

Commit be112e7

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix to propagate error from f2fs_enable_checkpoint()
In order to let userspace detect such error rather than suffering silent failure. Fixes: 4354994 ("f2fs: checkpoint disabling") Cc: stable@kernel.org Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 89c1662 commit be112e7

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

fs/f2fs/super.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,10 +2632,11 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
26322632
return err;
26332633
}
26342634

2635-
static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
2635+
static int f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
26362636
{
26372637
unsigned int nr_pages = get_pages(sbi, F2FS_DIRTY_DATA) / 16;
26382638
long long start, writeback, end;
2639+
int ret;
26392640

26402641
f2fs_info(sbi, "f2fs_enable_checkpoint() starts, meta: %lld, node: %lld, data: %lld",
26412642
get_pages(sbi, F2FS_DIRTY_META),
@@ -2669,7 +2670,9 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
26692670
set_sbi_flag(sbi, SBI_IS_DIRTY);
26702671
f2fs_up_write(&sbi->gc_lock);
26712672

2672-
f2fs_sync_fs(sbi->sb, 1);
2673+
ret = f2fs_sync_fs(sbi->sb, 1);
2674+
if (ret)
2675+
f2fs_err(sbi, "%s sync_fs failed, ret: %d", __func__, ret);
26732676

26742677
/* Let's ensure there's no pending checkpoint anymore */
26752678
f2fs_flush_ckpt_thread(sbi);
@@ -2679,6 +2682,7 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
26792682
f2fs_info(sbi, "f2fs_enable_checkpoint() finishes, writeback:%llu, sync:%llu",
26802683
ktime_ms_delta(writeback, start),
26812684
ktime_ms_delta(end, writeback));
2685+
return ret;
26822686
}
26832687

26842688
static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
@@ -2892,7 +2896,9 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
28922896
goto restore_discard;
28932897
need_enable_checkpoint = true;
28942898
} else {
2895-
f2fs_enable_checkpoint(sbi);
2899+
err = f2fs_enable_checkpoint(sbi);
2900+
if (err)
2901+
goto restore_discard;
28962902
need_disable_checkpoint = true;
28972903
}
28982904
}
@@ -2935,7 +2941,8 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
29352941
return 0;
29362942
restore_checkpoint:
29372943
if (need_enable_checkpoint) {
2938-
f2fs_enable_checkpoint(sbi);
2944+
if (f2fs_enable_checkpoint(sbi))
2945+
f2fs_warn(sbi, "checkpoint has not been enabled");
29392946
} else if (need_disable_checkpoint) {
29402947
if (f2fs_disable_checkpoint(sbi))
29412948
f2fs_warn(sbi, "checkpoint has not been disabled");
@@ -5212,13 +5219,12 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc)
52125219
if (err)
52135220
goto sync_free_meta;
52145221

5215-
if (test_opt(sbi, DISABLE_CHECKPOINT)) {
5222+
if (test_opt(sbi, DISABLE_CHECKPOINT))
52165223
err = f2fs_disable_checkpoint(sbi);
5217-
if (err)
5218-
goto sync_free_meta;
5219-
} else if (is_set_ckpt_flags(sbi, CP_DISABLED_FLAG)) {
5220-
f2fs_enable_checkpoint(sbi);
5221-
}
5224+
else if (is_set_ckpt_flags(sbi, CP_DISABLED_FLAG))
5225+
err = f2fs_enable_checkpoint(sbi);
5226+
if (err)
5227+
goto sync_free_meta;
52225228

52235229
/*
52245230
* If filesystem is not mounted as read-only then

0 commit comments

Comments
 (0)