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 cdca2087dba0305aaabc7ea84f0128974cf831be..dfa072fa80815af4dfe7683c461bb68878d0fd5a 100644 (file)
@@ -138,6 +138,7 @@ enum {
        Opt_alloc,
        Opt_fsync,
        Opt_test_dummy_encryption,
+       Opt_inlinecrypt,
        Opt_checkpoint_disable,
        Opt_checkpoint_disable_cap,
        Opt_checkpoint_disable_cap_perc,
@@ -204,6 +205,7 @@ static match_table_t f2fs_tokens = {
        {Opt_fsync, "fsync_mode=%s"},
        {Opt_test_dummy_encryption, "test_dummy_encryption=%s"},
        {Opt_test_dummy_encryption, "test_dummy_encryption"},
+       {Opt_inlinecrypt, "inlinecrypt"},
        {Opt_checkpoint_disable, "checkpoint=disable"},
        {Opt_checkpoint_disable_cap, "checkpoint=disable:%u"},
        {Opt_checkpoint_disable_cap_perc, "checkpoint=disable:%u%%"},
@@ -836,6 +838,13 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
                        if (ret)
                                return ret;
                        break;
+               case Opt_inlinecrypt:
+#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT
+                       sb->s_flags |= SB_INLINECRYPT;
+#else
+                       f2fs_info(sbi, "inline encryption not supported");
+#endif
+                       break;
                case Opt_checkpoint_disable_cap_perc:
                        if (args->from && match_int(args, &arg))
                                return -EINVAL;
@@ -1604,6 +1613,9 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
 
        fscrypt_show_test_dummy_encryption(seq, ',', sbi->sb);
 
+       if (sbi->sb->s_flags & SB_INLINECRYPT)
+               seq_puts(seq, ",inlinecrypt");
+
        if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_DEFAULT)
                seq_printf(seq, ",alloc_mode=%s", "default");
        else if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_REUSE)
@@ -1640,6 +1652,8 @@ static void default_options(struct f2fs_sb_info *sbi)
        F2FS_OPTION(sbi).compress_ext_cnt = 0;
        F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON;
 
+       sbi->sb->s_flags &= ~SB_INLINECRYPT;
+
        set_opt(sbi, INLINE_XATTR);
        set_opt(sbi, INLINE_DATA);
        set_opt(sbi, INLINE_DENTRY);
@@ -2486,6 +2500,25 @@ static void f2fs_get_ino_and_lblk_bits(struct super_block *sb,
        *lblk_bits_ret = 8 * sizeof(block_t);
 }
 
+static int f2fs_get_num_devices(struct super_block *sb)
+{
+       struct f2fs_sb_info *sbi = F2FS_SB(sb);
+
+       if (f2fs_is_multi_device(sbi))
+               return sbi->s_ndevs;
+       return 1;
+}
+
+static void f2fs_get_devices(struct super_block *sb,
+                            struct request_queue **devs)
+{
+       struct f2fs_sb_info *sbi = F2FS_SB(sb);
+       int i;
+
+       for (i = 0; i < sbi->s_ndevs; i++)
+               devs[i] = bdev_get_queue(FDEV(i).bdev);
+}
+
 static const struct fscrypt_operations f2fs_cryptops = {
        .key_prefix             = "f2fs:",
        .get_context            = f2fs_get_context,
@@ -2495,6 +2528,8 @@ static const struct fscrypt_operations f2fs_cryptops = {
        .max_namelen            = F2FS_NAME_LEN,
        .has_stable_inodes      = f2fs_has_stable_inodes,
        .get_ino_and_lblk_bits  = f2fs_get_ino_and_lblk_bits,
+       .get_num_devices        = f2fs_get_num_devices,
+       .get_devices            = f2fs_get_devices,
 };
 #endif