]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
f2fs: fix wrong checkpoint_changed value in f2fs_remount()
authorChao Yu <chao@kernel.org>
Thu, 29 Jul 2021 01:22:17 +0000 (09:22 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:41:51 +0000 (13:41 +0200)
[ Upstream commit 277afbde6ca2b38729683fc17c031b4bc942068d ]

In f2fs_remount(), return value of test_opt() is an unsigned int type
variable, however when we compare it to a bool type variable, it cause
wrong result, fix it.

Fixes: 4354994f097d ("f2fs: checkpoint disabling")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/super.c

index 97e3efe5a0203143fc506a8ef023f2fc5cf24e4b..d61f7fcdc66b37e91175cbbfb6eb4a5ba6d4bb41 100644 (file)
@@ -1966,11 +1966,10 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
        bool need_restart_ckpt = false, need_stop_ckpt = false;
        bool need_restart_flush = false, need_stop_flush = false;
        bool no_extent_cache = !test_opt(sbi, EXTENT_CACHE);
-       bool disable_checkpoint = test_opt(sbi, DISABLE_CHECKPOINT);
+       bool enable_checkpoint = !test_opt(sbi, DISABLE_CHECKPOINT);
        bool no_io_align = !F2FS_IO_ALIGNED(sbi);
        bool no_atgc = !test_opt(sbi, ATGC);
        bool no_compress_cache = !test_opt(sbi, COMPRESS_CACHE);
-       bool checkpoint_changed;
 #ifdef CONFIG_QUOTA
        int i, j;
 #endif
@@ -2015,8 +2014,6 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
        err = parse_options(sb, data, true);
        if (err)
                goto restore_opts;
-       checkpoint_changed =
-                       disable_checkpoint != test_opt(sbi, DISABLE_CHECKPOINT);
 
        /*
         * Previous and new state of filesystem is RO,
@@ -2133,7 +2130,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
                need_stop_flush = true;
        }
 
-       if (checkpoint_changed) {
+       if (enable_checkpoint == !!test_opt(sbi, DISABLE_CHECKPOINT)) {
                if (test_opt(sbi, DISABLE_CHECKPOINT)) {
                        err = f2fs_disable_checkpoint(sbi);
                        if (err)