]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
f2fs: fix to propagate error from f2fs_enable_checkpoint()
authorChao Yu <chao@kernel.org>
Tue, 30 Dec 2025 17:34:52 +0000 (12:34 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:10:07 +0000 (13:10 +0100)
[ Upstream commit be112e7449a6e1b54aa9feac618825d154b3a5c7 ]

In order to let userspace detect such error rather than suffering
silent failure.

Fixes: 4354994f097d ("f2fs: checkpoint disabling")
Cc: stable@kernel.org
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
[ Adjust context, no rollback ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/f2fs/super.c

index 81a273cfacfc3fffdbe361fd941e9890035b6ecb..6f6368400ee46b7327399d4c9df30f6f0779e230 100644 (file)
@@ -2177,9 +2177,10 @@ restore_flag:
        return err;
 }
 
-static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
+static int f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
 {
        int retry = DEFAULT_RETRY_IO_COUNT;
+       int ret;
 
        /* we should flush all the data to keep data consistency */
        do {
@@ -2197,10 +2198,14 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
        set_sbi_flag(sbi, SBI_IS_DIRTY);
        up_write(&sbi->gc_lock);
 
-       f2fs_sync_fs(sbi->sb, 1);
+       ret = f2fs_sync_fs(sbi->sb, 1);
+       if (ret)
+               f2fs_err(sbi, "%s sync_fs failed, ret: %d", __func__, ret);
 
        /* Let's ensure there's no pending checkpoint anymore */
        f2fs_flush_ckpt_thread(sbi);
+
+       return ret;
 }
 
 static int f2fs_remount(struct super_block *sb, int *flags, char *data)
@@ -2416,7 +2421,9 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
                        if (err)
                                goto restore_discard;
                } else {
-                       f2fs_enable_checkpoint(sbi);
+                       err = f2fs_enable_checkpoint(sbi);
+                       if (err)
+                               goto restore_discard;
                }
        }
 
@@ -4397,13 +4404,12 @@ reset_checkpoint:
        /* f2fs_recover_fsync_data() cleared this already */
        clear_sbi_flag(sbi, SBI_POR_DOING);
 
-       if (test_opt(sbi, DISABLE_CHECKPOINT)) {
+       if (test_opt(sbi, DISABLE_CHECKPOINT))
                err = f2fs_disable_checkpoint(sbi);
-               if (err)
-                       goto sync_free_meta;
-       } else if (is_set_ckpt_flags(sbi, CP_DISABLED_FLAG)) {
-               f2fs_enable_checkpoint(sbi);
-       }
+       else if (is_set_ckpt_flags(sbi, CP_DISABLED_FLAG))
+               err = f2fs_enable_checkpoint(sbi);
+       if (err)
+               goto sync_free_meta;
 
        /*
         * If filesystem is not mounted as read-only then