f2fs: don't start checkpoint thread in readonly mountpoint
authorChao Yu <yuchao0@huawei.com>
Wed, 17 Mar 2021 09:56:03 +0000 (17:56 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 26 Mar 2021 01:20:51 +0000 (18:20 -0700)
In readonly mountpoint, there should be no write IOs include checkpoint
IO, so that it's not needed to create kernel checkpoint thread.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/super.c

index e03b2f0f69d051848ee7438e1012d2bbabd175f8..721dc64609b41bd7de8bcaee58b74c8db5e03cc2 100644 (file)
@@ -2069,8 +2069,10 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
                }
        }
 
-       if (!test_opt(sbi, DISABLE_CHECKPOINT) &&
-                       test_opt(sbi, MERGE_CHECKPOINT)) {
+       if ((*flags & SB_RDONLY) || test_opt(sbi, DISABLE_CHECKPOINT) ||
+                       !test_opt(sbi, MERGE_CHECKPOINT)) {
+               f2fs_stop_ckpt_thread(sbi);
+       } else {
                err = f2fs_start_ckpt_thread(sbi);
                if (err) {
                        f2fs_err(sbi,
@@ -2078,8 +2080,6 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
                            err);
                        goto restore_gc;
                }
-       } else {
-               f2fs_stop_ckpt_thread(sbi);
        }
 
        /*
@@ -3835,7 +3835,7 @@ try_onemore:
 
        /* setup checkpoint request control and start checkpoint issue thread */
        f2fs_init_ckpt_req_control(sbi);
-       if (!test_opt(sbi, DISABLE_CHECKPOINT) &&
+       if (!f2fs_readonly(sb) && !test_opt(sbi, DISABLE_CHECKPOINT) &&
                        test_opt(sbi, MERGE_CHECKPOINT)) {
                err = f2fs_start_ckpt_thread(sbi);
                if (err) {