diff options
-rw-r--r-- | Documentation/filesystems/f2fs.txt | 2 | ||||
-rw-r--r-- | fs/f2fs/dir.c | 4 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 8 | ||||
-rw-r--r-- | fs/f2fs/namei.c | 9 | ||||
-rw-r--r-- | fs/f2fs/super.c | 28 |
5 files changed, 47 insertions, 4 deletions
diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt index 514e44983a8e..12a147c9f87f 100644 --- a/Documentation/filesystems/f2fs.txt +++ b/Documentation/filesystems/f2fs.txt | |||
@@ -189,6 +189,8 @@ fsync_mode=%s Control the policy of fsync. Currently supports "posix" | |||
189 | fsync will be heavy and behaves in line with xfs, ext4 | 189 | fsync will be heavy and behaves in line with xfs, ext4 |
190 | and btrfs, where xfstest generic/342 will pass, but the | 190 | and btrfs, where xfstest generic/342 will pass, but the |
191 | performance will regress. | 191 | performance will regress. |
192 | test_dummy_encryption Enable dummy encryption, which provides a fake fscrypt | ||
193 | context. The fake fscrypt context is used by xfstests. | ||
192 | 194 | ||
193 | ================================================================================ | 195 | ================================================================================ |
194 | DEBUGFS ENTRIES | 196 | DEBUGFS ENTRIES |
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 9a0d103b5052..fe661274ff10 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c | |||
@@ -361,6 +361,7 @@ struct page *init_inode_metadata(struct inode *inode, struct inode *dir, | |||
361 | struct page *dpage) | 361 | struct page *dpage) |
362 | { | 362 | { |
363 | struct page *page; | 363 | struct page *page; |
364 | int dummy_encrypt = DUMMY_ENCRYPTION_ENABLED(F2FS_I_SB(dir)); | ||
364 | int err; | 365 | int err; |
365 | 366 | ||
366 | if (is_inode_flag_set(inode, FI_NEW_INODE)) { | 367 | if (is_inode_flag_set(inode, FI_NEW_INODE)) { |
@@ -387,7 +388,8 @@ struct page *init_inode_metadata(struct inode *inode, struct inode *dir, | |||
387 | if (err) | 388 | if (err) |
388 | goto put_error; | 389 | goto put_error; |
389 | 390 | ||
390 | if (f2fs_encrypted_inode(dir) && f2fs_may_encrypt(inode)) { | 391 | if ((f2fs_encrypted_inode(dir) || dummy_encrypt) && |
392 | f2fs_may_encrypt(inode)) { | ||
391 | err = fscrypt_inherit_context(dir, inode, page, false); | 393 | err = fscrypt_inherit_context(dir, inode, page, false); |
392 | if (err) | 394 | if (err) |
393 | goto put_error; | 395 | goto put_error; |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index c0d74ff9a6d7..191ee5718369 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -133,6 +133,7 @@ struct f2fs_mount_info { | |||
133 | int whint_mode; | 133 | int whint_mode; |
134 | int alloc_mode; /* segment allocation policy */ | 134 | int alloc_mode; /* segment allocation policy */ |
135 | int fsync_mode; /* fsync policy */ | 135 | int fsync_mode; /* fsync policy */ |
136 | bool test_dummy_encryption; /* test dummy encryption */ | ||
136 | }; | 137 | }; |
137 | 138 | ||
138 | #define F2FS_FEATURE_ENCRYPT 0x0001 | 139 | #define F2FS_FEATURE_ENCRYPT 0x0001 |
@@ -1077,6 +1078,13 @@ enum fsync_mode { | |||
1077 | FSYNC_MODE_STRICT, /* fsync behaves in line with ext4 */ | 1078 | FSYNC_MODE_STRICT, /* fsync behaves in line with ext4 */ |
1078 | }; | 1079 | }; |
1079 | 1080 | ||
1081 | #ifdef CONFIG_F2FS_FS_ENCRYPTION | ||
1082 | #define DUMMY_ENCRYPTION_ENABLED(sbi) \ | ||
1083 | (unlikely(F2FS_OPTION(sbi).test_dummy_encryption)) | ||
1084 | #else | ||
1085 | #define DUMMY_ENCRYPTION_ENABLED(sbi) (0) | ||
1086 | #endif | ||
1087 | |||
1080 | struct f2fs_sb_info { | 1088 | struct f2fs_sb_info { |
1081 | struct super_block *sb; /* pointer to VFS super block */ | 1089 | struct super_block *sb; /* pointer to VFS super block */ |
1082 | struct proc_dir_entry *s_proc; /* proc entry */ | 1090 | struct proc_dir_entry *s_proc; /* proc entry */ |
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index f4ae46282eef..d5098efe577c 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c | |||
@@ -78,7 +78,8 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) | |||
78 | set_inode_flag(inode, FI_NEW_INODE); | 78 | set_inode_flag(inode, FI_NEW_INODE); |
79 | 79 | ||
80 | /* If the directory encrypted, then we should encrypt the inode. */ | 80 | /* If the directory encrypted, then we should encrypt the inode. */ |
81 | if (f2fs_encrypted_inode(dir) && f2fs_may_encrypt(inode)) | 81 | if ((f2fs_encrypted_inode(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) && |
82 | f2fs_may_encrypt(inode)) | ||
82 | f2fs_set_encrypted_inode(inode); | 83 | f2fs_set_encrypted_inode(inode); |
83 | 84 | ||
84 | if (f2fs_sb_has_extra_attr(sbi->sb)) { | 85 | if (f2fs_sb_has_extra_attr(sbi->sb)) { |
@@ -787,10 +788,12 @@ out: | |||
787 | 788 | ||
788 | static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) | 789 | static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) |
789 | { | 790 | { |
790 | if (unlikely(f2fs_cp_error(F2FS_I_SB(dir)))) | 791 | struct f2fs_sb_info *sbi = F2FS_I_SB(dir); |
792 | |||
793 | if (unlikely(f2fs_cp_error(sbi))) | ||
791 | return -EIO; | 794 | return -EIO; |
792 | 795 | ||
793 | if (f2fs_encrypted_inode(dir)) { | 796 | if (f2fs_encrypted_inode(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) { |
794 | int err = fscrypt_get_encryption_info(dir); | 797 | int err = fscrypt_get_encryption_info(dir); |
795 | if (err) | 798 | if (err) |
796 | return err; | 799 | return err; |
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index dcdae3f932e2..98b2c7ff1804 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
@@ -132,6 +132,7 @@ enum { | |||
132 | Opt_whint, | 132 | Opt_whint, |
133 | Opt_alloc, | 133 | Opt_alloc, |
134 | Opt_fsync, | 134 | Opt_fsync, |
135 | Opt_test_dummy_encryption, | ||
135 | Opt_err, | 136 | Opt_err, |
136 | }; | 137 | }; |
137 | 138 | ||
@@ -188,6 +189,7 @@ static match_table_t f2fs_tokens = { | |||
188 | {Opt_whint, "whint_mode=%s"}, | 189 | {Opt_whint, "whint_mode=%s"}, |
189 | {Opt_alloc, "alloc_mode=%s"}, | 190 | {Opt_alloc, "alloc_mode=%s"}, |
190 | {Opt_fsync, "fsync_mode=%s"}, | 191 | {Opt_fsync, "fsync_mode=%s"}, |
192 | {Opt_test_dummy_encryption, "test_dummy_encryption"}, | ||
191 | {Opt_err, NULL}, | 193 | {Opt_err, NULL}, |
192 | }; | 194 | }; |
193 | 195 | ||
@@ -744,6 +746,21 @@ static int parse_options(struct super_block *sb, char *options) | |||
744 | } | 746 | } |
745 | kfree(name); | 747 | kfree(name); |
746 | break; | 748 | break; |
749 | case Opt_test_dummy_encryption: | ||
750 | #ifdef CONFIG_F2FS_FS_ENCRYPTION | ||
751 | if (!f2fs_sb_has_encrypt(sb)) { | ||
752 | f2fs_msg(sb, KERN_ERR, "Encrypt feature is off"); | ||
753 | return -EINVAL; | ||
754 | } | ||
755 | |||
756 | F2FS_OPTION(sbi).test_dummy_encryption = true; | ||
757 | f2fs_msg(sb, KERN_INFO, | ||
758 | "Test dummy encryption mode enabled"); | ||
759 | #else | ||
760 | f2fs_msg(sb, KERN_INFO, | ||
761 | "Test dummy encryption mount option ignored"); | ||
762 | #endif | ||
763 | break; | ||
747 | default: | 764 | default: |
748 | f2fs_msg(sb, KERN_ERR, | 765 | f2fs_msg(sb, KERN_ERR, |
749 | "Unrecognized mount option \"%s\" or missing value", | 766 | "Unrecognized mount option \"%s\" or missing value", |
@@ -1314,6 +1331,10 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root) | |||
1314 | seq_printf(seq, ",whint_mode=%s", "user-based"); | 1331 | seq_printf(seq, ",whint_mode=%s", "user-based"); |
1315 | else if (F2FS_OPTION(sbi).whint_mode == WHINT_MODE_FS) | 1332 | else if (F2FS_OPTION(sbi).whint_mode == WHINT_MODE_FS) |
1316 | seq_printf(seq, ",whint_mode=%s", "fs-based"); | 1333 | seq_printf(seq, ",whint_mode=%s", "fs-based"); |
1334 | #ifdef CONFIG_F2FS_FS_ENCRYPTION | ||
1335 | if (F2FS_OPTION(sbi).test_dummy_encryption) | ||
1336 | seq_puts(seq, ",test_dummy_encryption"); | ||
1337 | #endif | ||
1317 | 1338 | ||
1318 | if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_DEFAULT) | 1339 | if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_DEFAULT) |
1319 | seq_printf(seq, ",alloc_mode=%s", "default"); | 1340 | seq_printf(seq, ",alloc_mode=%s", "default"); |
@@ -1335,6 +1356,7 @@ static void default_options(struct f2fs_sb_info *sbi) | |||
1335 | F2FS_OPTION(sbi).whint_mode = WHINT_MODE_OFF; | 1356 | F2FS_OPTION(sbi).whint_mode = WHINT_MODE_OFF; |
1336 | F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_DEFAULT; | 1357 | F2FS_OPTION(sbi).alloc_mode = ALLOC_MODE_DEFAULT; |
1337 | F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_POSIX; | 1358 | F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_POSIX; |
1359 | F2FS_OPTION(sbi).test_dummy_encryption = false; | ||
1338 | sbi->readdir_ra = 1; | 1360 | sbi->readdir_ra = 1; |
1339 | 1361 | ||
1340 | set_opt(sbi, BG_GC); | 1362 | set_opt(sbi, BG_GC); |
@@ -1908,6 +1930,11 @@ static int f2fs_set_context(struct inode *inode, const void *ctx, size_t len, | |||
1908 | ctx, len, fs_data, XATTR_CREATE); | 1930 | ctx, len, fs_data, XATTR_CREATE); |
1909 | } | 1931 | } |
1910 | 1932 | ||
1933 | static bool f2fs_dummy_context(struct inode *inode) | ||
1934 | { | ||
1935 | return DUMMY_ENCRYPTION_ENABLED(F2FS_I_SB(inode)); | ||
1936 | } | ||
1937 | |||
1911 | static unsigned f2fs_max_namelen(struct inode *inode) | 1938 | static unsigned f2fs_max_namelen(struct inode *inode) |
1912 | { | 1939 | { |
1913 | return S_ISLNK(inode->i_mode) ? | 1940 | return S_ISLNK(inode->i_mode) ? |
@@ -1918,6 +1945,7 @@ static const struct fscrypt_operations f2fs_cryptops = { | |||
1918 | .key_prefix = "f2fs:", | 1945 | .key_prefix = "f2fs:", |
1919 | .get_context = f2fs_get_context, | 1946 | .get_context = f2fs_get_context, |
1920 | .set_context = f2fs_set_context, | 1947 | .set_context = f2fs_set_context, |
1948 | .dummy_context = f2fs_dummy_context, | ||
1921 | .empty_dir = f2fs_empty_dir, | 1949 | .empty_dir = f2fs_empty_dir, |
1922 | .max_namelen = f2fs_max_namelen, | 1950 | .max_namelen = f2fs_max_namelen, |
1923 | }; | 1951 | }; |