Merge tag 'f2fs-for-6-6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk...
[platform/kernel/linux-rpi.git] / fs / f2fs / super.c
index aa1f9a3..a8c8232 100644 (file)
@@ -591,7 +591,7 @@ static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str)
        unsigned int level;
 
        if (strlen(str) == 3) {
-               F2FS_OPTION(sbi).compress_level = LZ4HC_DEFAULT_CLEVEL;
+               F2FS_OPTION(sbi).compress_level = 0;
                return 0;
        }
 
@@ -862,11 +862,6 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
                        if (!name)
                                return -ENOMEM;
                        if (!strcmp(name, "adaptive")) {
-                               if (f2fs_sb_has_blkzoned(sbi)) {
-                                       f2fs_warn(sbi, "adaptive mode is not allowed with zoned block device feature");
-                                       kfree(name);
-                                       return -EINVAL;
-                               }
                                F2FS_OPTION(sbi).fs_mode = FS_MODE_ADAPTIVE;
                        } else if (!strcmp(name, "lfs")) {
                                F2FS_OPTION(sbi).fs_mode = FS_MODE_LFS;
@@ -1331,6 +1326,11 @@ default_check:
                        F2FS_OPTION(sbi).discard_unit =
                                        DISCARD_UNIT_SECTION;
                }
+
+               if (F2FS_OPTION(sbi).fs_mode != FS_MODE_LFS) {
+                       f2fs_info(sbi, "Only lfs mode is allowed with zoned block device feature");
+                       return -EINVAL;
+               }
 #else
                f2fs_err(sbi, "Zoned block device support is not enabled");
                return -EINVAL;
@@ -1561,7 +1561,8 @@ static void destroy_device_list(struct f2fs_sb_info *sbi)
        int i;
 
        for (i = 0; i < sbi->s_ndevs; i++) {
-               blkdev_put(FDEV(i).bdev, sbi->sb);
+               if (i > 0)
+                       blkdev_put(FDEV(i).bdev, sbi->sb);
 #ifdef CONFIG_BLK_DEV_ZONED
                kvfree(FDEV(i).blkz_seq);
 #endif
@@ -1600,6 +1601,7 @@ static void f2fs_put_super(struct super_block *sb)
                struct cp_control cpc = {
                        .reason = CP_UMOUNT,
                };
+               stat_inc_cp_call_count(sbi, TOTAL_CALL);
                err = f2fs_write_checkpoint(sbi, &cpc);
        }
 
@@ -1609,6 +1611,7 @@ static void f2fs_put_super(struct super_block *sb)
                struct cp_control cpc = {
                        .reason = CP_UMOUNT | CP_TRIMMED,
                };
+               stat_inc_cp_call_count(sbi, TOTAL_CALL);
                err = f2fs_write_checkpoint(sbi, &cpc);
        }
 
@@ -1705,8 +1708,10 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
        if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
                return -EAGAIN;
 
-       if (sync)
+       if (sync) {
+               stat_inc_cp_call_count(sbi, TOTAL_CALL);
                err = f2fs_issue_checkpoint(sbi);
+       }
 
        return err;
 }
@@ -2205,6 +2210,7 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
                        .nr_free_secs = 1 };
 
                f2fs_down_write(&sbi->gc_lock);
+               stat_inc_gc_call_count(sbi, FOREGROUND);
                err = f2fs_gc(sbi, &gc_control);
                if (err == -ENODATA) {
                        err = 0;
@@ -2230,6 +2236,7 @@ skip_gc:
        f2fs_down_write(&sbi->gc_lock);
        cpc.reason = CP_PAUSE;
        set_sbi_flag(sbi, SBI_CP_DISABLED);
+       stat_inc_cp_call_count(sbi, TOTAL_CALL);
        err = f2fs_write_checkpoint(sbi, &cpc);
        if (err)
                goto out_unlock;
@@ -4190,16 +4197,12 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
        sbi->aligned_blksize = true;
 
        for (i = 0; i < max_devices; i++) {
-
-               if (i > 0 && !RDEV(i).path[0])
+               if (i == 0)
+                       FDEV(0).bdev = sbi->sb->s_bdev;
+               else if (!RDEV(i).path[0])
                        break;
 
-               if (max_devices == 1) {
-                       /* Single zoned block device mount */
-                       FDEV(0).bdev =
-                               blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev, mode,
-                                                 sbi->sb, NULL);
-               } else {
+               if (max_devices > 1) {
                        /* Multi-device mount */
                        memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN);
                        FDEV(i).total_segments =
@@ -4215,9 +4218,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
                                FDEV(i).end_blk = FDEV(i).start_blk +
                                        (FDEV(i).total_segments <<
                                        sbi->log_blocks_per_seg) - 1;
+                               FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path,
+                                       mode, sbi->sb, NULL);
                        }
-                       FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path, mode,
-                                                         sbi->sb, NULL);
                }
                if (IS_ERR(FDEV(i).bdev))
                        return PTR_ERR(FDEV(i).bdev);
@@ -4870,6 +4873,7 @@ static void kill_f2fs_super(struct super_block *sb)
                        struct cp_control cpc = {
                                .reason = CP_UMOUNT,
                        };
+                       stat_inc_cp_call_count(sbi, TOTAL_CALL);
                        f2fs_write_checkpoint(sbi, &cpc);
                }