Skip to content

Commit 40409e0

Browse files
chaseyugregkh
authored andcommitted
f2fs: fix to propagate error from f2fs_enable_checkpoint()
commit be112e7 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 86a85a7 commit 40409e0

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

fs/f2fs/super.c

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

2637-
static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
2637+
static int f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
26382638
{
26392639
unsigned int nr_pages = get_pages(sbi, F2FS_DIRTY_DATA) / 16;
26402640
long long start, writeback, end;
2641+
int ret;
26412642

26422643
f2fs_info(sbi, "f2fs_enable_checkpoint() starts, meta: %lld, node: %lld, data: %lld",
26432644
get_pages(sbi, F2FS_DIRTY_META),
@@ -2671,7 +2672,9 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
26712672
set_sbi_flag(sbi, SBI_IS_DIRTY);
26722673
f2fs_up_write(&sbi->gc_lock);
26732674

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

26762679
/* Let's ensure there's no pending checkpoint anymore */
26772680
f2fs_flush_ckpt_thread(sbi);
@@ -2681,6 +2684,7 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
26812684
f2fs_info(sbi, "f2fs_enable_checkpoint() finishes, writeback:%llu, sync:%llu",
26822685
ktime_ms_delta(writeback, start),
26832686
ktime_ms_delta(end, writeback));
2687+
return ret;
26842688
}
26852689

26862690
static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
@@ -2894,7 +2898,9 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
28942898
goto restore_discard;
28952899
need_enable_checkpoint = true;
28962900
} else {
2897-
f2fs_enable_checkpoint(sbi);
2901+
err = f2fs_enable_checkpoint(sbi);
2902+
if (err)
2903+
goto restore_discard;
28982904
need_disable_checkpoint = true;
28992905
}
29002906
}
@@ -2937,7 +2943,8 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
29372943
return 0;
29382944
restore_checkpoint:
29392945
if (need_enable_checkpoint) {
2940-
f2fs_enable_checkpoint(sbi);
2946+
if (f2fs_enable_checkpoint(sbi))
2947+
f2fs_warn(sbi, "checkpoint has not been enabled");
29412948
} else if (need_disable_checkpoint) {
29422949
if (f2fs_disable_checkpoint(sbi))
29432950
f2fs_warn(sbi, "checkpoint has not been disabled");
@@ -5232,13 +5239,12 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc)
52325239
if (err)
52335240
goto sync_free_meta;
52345241

5235-
if (test_opt(sbi, DISABLE_CHECKPOINT)) {
5242+
if (test_opt(sbi, DISABLE_CHECKPOINT))
52365243
err = f2fs_disable_checkpoint(sbi);
5237-
if (err)
5238-
goto sync_free_meta;
5239-
} else if (is_set_ckpt_flags(sbi, CP_DISABLED_FLAG)) {
5240-
f2fs_enable_checkpoint(sbi);
5241-
}
5244+
else if (is_set_ckpt_flags(sbi, CP_DISABLED_FLAG))
5245+
err = f2fs_enable_checkpoint(sbi);
5246+
if (err)
5247+
goto sync_free_meta;
52425248

52435249
/*
52445250
* If filesystem is not mounted as read-only then

0 commit comments

Comments
 (0)