Merge tag 'f2fs-for-5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk...
[linux-block.git] / fs / f2fs / super.c
index 23c49c313fb6820e68e80e1aa2946ec78f34c733..dfa072fa80815af4dfe7683c461bb68878d0fd5a 100644 (file)
@@ -350,7 +350,7 @@ static int f2fs_set_qf_name(struct super_block *sb, int qtype,
        set_opt(sbi, QUOTA);
        return 0;
 errout:
-       kvfree(qname);
+       kfree(qname);
        return ret;
 }
 
@@ -362,7 +362,7 @@ static int f2fs_clear_qf_name(struct super_block *sb, int qtype)
                f2fs_err(sbi, "Cannot change journaled quota options when quota turned on");
                return -EINVAL;
        }
-       kvfree(F2FS_OPTION(sbi).s_qf_names[qtype]);
+       kfree(F2FS_OPTION(sbi).s_qf_names[qtype]);
        F2FS_OPTION(sbi).s_qf_names[qtype] = NULL;
        return 0;
 }
@@ -462,9 +462,12 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
 {
        struct f2fs_sb_info *sbi = F2FS_SB(sb);
        substring_t args[MAX_OPT_ARGS];
+#ifdef CONFIG_F2FS_FS_COMPRESSION
        unsigned char (*ext)[F2FS_EXTENSION_LEN];
+       int ext_cnt;
+#endif
        char *p, *name;
-       int arg = 0, ext_cnt;
+       int arg = 0;
        kuid_t uid;
        kgid_t gid;
        int ret;
@@ -496,10 +499,10 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
                        } else if (!strcmp(name, "sync")) {
                                F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_SYNC;
                        } else {
-                               kvfree(name);
+                               kfree(name);
                                return -EINVAL;
                        }
-                       kvfree(name);
+                       kfree(name);
                        break;
                case Opt_disable_roll_forward:
                        set_opt(sbi, DISABLE_ROLL_FORWARD);
@@ -656,17 +659,17 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
                        if (!strcmp(name, "adaptive")) {
                                if (f2fs_sb_has_blkzoned(sbi)) {
                                        f2fs_warn(sbi, "adaptive mode is not allowed with zoned block device feature");
-                                       kvfree(name);
+                                       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;
                        } else {
-                               kvfree(name);
+                               kfree(name);
                                return -EINVAL;
                        }
-                       kvfree(name);
+                       kfree(name);
                        break;
                case Opt_io_size_bits:
                        if (args->from && match_int(args, &arg))
@@ -792,10 +795,10 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
                        } else if (!strcmp(name, "fs-based")) {
                                F2FS_OPTION(sbi).whint_mode = WHINT_MODE_FS;
                        } else {
-                               kvfree(name);
+                               kfree(name);
                                return -EINVAL;
                        }
-                       kvfree(name);
+                       kfree(name);
                        break;
                case Opt_alloc:
                        name = match_strdup(&args[0]);
@@ -807,10 +810,10 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
                        } else if (!strcmp(name, "reuse")) {
                                F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_REUSE;
                        } else {
-                               kvfree(name);
+                               kfree(name);
                                return -EINVAL;
                        }
-                       kvfree(name);
+                       kfree(name);
                        break;
                case Opt_fsync:
                        name = match_strdup(&args[0]);
@@ -824,10 +827,10 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
                                F2FS_OPTION(sbi).fsync_mode =
                                                        FSYNC_MODE_NOBARRIER;
                        } else {
-                               kvfree(name);
+                               kfree(name);
                                return -EINVAL;
                        }
-                       kvfree(name);
+                       kfree(name);
                        break;
                case Opt_test_dummy_encryption:
                        ret = f2fs_set_test_dummy_encryption(sb, p, &args[0],
@@ -862,6 +865,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
                case Opt_checkpoint_enable:
                        clear_opt(sbi, DISABLE_CHECKPOINT);
                        break;
+#ifdef CONFIG_F2FS_FS_COMPRESSION
                case Opt_compress_algorithm:
                        if (!f2fs_sb_has_compression(sbi)) {
                                f2fs_err(sbi, "Compression feature if off");
@@ -927,6 +931,13 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
                        F2FS_OPTION(sbi).compress_ext_cnt++;
                        kfree(name);
                        break;
+#else
+               case Opt_compress_algorithm:
+               case Opt_compress_log_size:
+               case Opt_compress_extension:
+                       f2fs_info(sbi, "compression options not supported");
+                       break;
+#endif
                default:
                        f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value",
                                 p);
@@ -1024,6 +1035,8 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb)
        /* Will be used by directory only */
        fi->i_dir_level = F2FS_SB(sb)->dir_level;
 
+       fi->ra_offset = -1;
+
        return &fi->vfs_inode;
 }
 
@@ -1182,6 +1195,9 @@ static void f2fs_put_super(struct super_block *sb)
        int i;
        bool dropped;
 
+       /* unregister procfs/sysfs entries in advance to avoid race case */
+       f2fs_unregister_sysfs(sbi);
+
        f2fs_quota_off_umount(sb);
 
        /* prevent remaining shrinker jobs */
@@ -1247,19 +1263,17 @@ static void f2fs_put_super(struct super_block *sb)
 
        kvfree(sbi->ckpt);
 
-       f2fs_unregister_sysfs(sbi);
-
        sb->s_fs_info = NULL;
        if (sbi->s_chksum_driver)
                crypto_free_shash(sbi->s_chksum_driver);
-       kvfree(sbi->raw_super);
+       kfree(sbi->raw_super);
 
        destroy_device_list(sbi);
        f2fs_destroy_xattr_caches(sbi);
        mempool_destroy(sbi->write_io_dummy);
 #ifdef CONFIG_QUOTA
        for (i = 0; i < MAXQUOTAS; i++)
-               kvfree(F2FS_OPTION(sbi).s_qf_names[i]);
+               kfree(F2FS_OPTION(sbi).s_qf_names[i]);
 #endif
        fscrypt_free_dummy_context(&F2FS_OPTION(sbi).dummy_enc_ctx);
        destroy_percpu_info(sbi);
@@ -1268,7 +1282,7 @@ static void f2fs_put_super(struct super_block *sb)
 #ifdef CONFIG_UNICODE
        utf8_unload(sbi->s_encoding);
 #endif
-       kvfree(sbi);
+       kfree(sbi);
 }
 
 int f2fs_sync_fs(struct super_block *sb, int sync)
@@ -1617,7 +1631,9 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
        else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_NOBARRIER)
                seq_printf(seq, ",fsync_mode=%s", "nobarrier");
 
+#ifdef CONFIG_F2FS_FS_COMPRESSION
        f2fs_show_compress_options(seq, sbi->sb);
+#endif
        return 0;
 }
 
@@ -1768,7 +1784,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
                                GFP_KERNEL);
                        if (!org_mount_opt.s_qf_names[i]) {
                                for (j = 0; j < i; j++)
-                                       kvfree(org_mount_opt.s_qf_names[j]);
+                                       kfree(org_mount_opt.s_qf_names[j]);
                                return -ENOMEM;
                        }
                } else {
@@ -1893,7 +1909,7 @@ skip:
 #ifdef CONFIG_QUOTA
        /* Release old quota file names */
        for (i = 0; i < MAXQUOTAS; i++)
-               kvfree(org_mount_opt.s_qf_names[i]);
+               kfree(org_mount_opt.s_qf_names[i]);
 #endif
        /* Update the POSIXACL Flag */
        sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
@@ -1914,7 +1930,7 @@ restore_opts:
 #ifdef CONFIG_QUOTA
        F2FS_OPTION(sbi).s_jquota_fmt = org_mount_opt.s_jquota_fmt;
        for (i = 0; i < MAXQUOTAS; i++) {
-               kvfree(F2FS_OPTION(sbi).s_qf_names[i]);
+               kfree(F2FS_OPTION(sbi).s_qf_names[i]);
                F2FS_OPTION(sbi).s_qf_names[i] = org_mount_opt.s_qf_names[i];
        }
 #endif
@@ -3172,7 +3188,7 @@ static int read_raw_super_block(struct f2fs_sb_info *sbi,
 
        /* No valid superblock */
        if (!*raw_super)
-               kvfree(super);
+               kfree(super);
        else
                err = 0;
 
@@ -3846,16 +3862,16 @@ free_bio_info:
 free_options:
 #ifdef CONFIG_QUOTA
        for (i = 0; i < MAXQUOTAS; i++)
-               kvfree(F2FS_OPTION(sbi).s_qf_names[i]);
+               kfree(F2FS_OPTION(sbi).s_qf_names[i]);
 #endif
        fscrypt_free_dummy_context(&F2FS_OPTION(sbi).dummy_enc_ctx);
        kvfree(options);
 free_sb_buf:
-       kvfree(raw_super);
+       kfree(raw_super);
 free_sbi:
        if (sbi->s_chksum_driver)
                crypto_free_shash(sbi->s_chksum_driver);
-       kvfree(sbi);
+       kfree(sbi);
 
        /* give only one another chance */
        if (retry_cnt > 0 && skip_recovery) {