summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/sysfs.c
diff options
context:
space:
mode:
authorDaniel Rosenberg <drosen@google.com>2019-07-23 19:05:28 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2019-08-23 10:57:13 -0400
commit5aba54302a46fdd589040b928d5d010e5ace1234 (patch)
tree8b6cc699256578666a66b49f8b72ae2eae36c143 /fs/f2fs/sysfs.c
parent71e90b4654a9298f9e2375cc733d57b8bf92ce73 (diff)
f2fs: include charset encoding information in the superblock
Add charset encoding to f2fs to support casefolding. It is modeled after the same feature introduced in commit c83ad55eaa91 ("ext4: include charset encoding information in the superblock") Currently this is not compatible with encryption, similar to the current ext4 imlpementation. This will change in the future. >From the ext4 patch: """ The s_encoding field stores a magic number indicating the encoding format and version used globally by file and directory names in the filesystem. The s_encoding_flags defines policies for using the charset encoding, like how to handle invalid sequences. The magic number is mapped to the exact charset table, but the mapping is specific to ext4. Since we don't have any commitment to support old encodings, the only encoding I am supporting right now is utf8-12.1.0. The current implementation prevents the user from enabling encoding and per-directory encryption on the same filesystem at the same time. The incompatibility between these features lies in how we do efficient directory searches when we cannot be sure the encryption of the user provided fname will match the actual hash stored in the disk without decrypting every directory entry, because of normalization cases. My quickest solution is to simply block the concurrent use of these features for now, and enable it later, once we have a better solution. """ Signed-off-by: Daniel Rosenberg <drosen@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/sysfs.c')
-rw-r--r--fs/f2fs/sysfs.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 3aeacd0aacfd..f9fcca695db9 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -10,6 +10,7 @@
10#include <linux/proc_fs.h> 10#include <linux/proc_fs.h>
11#include <linux/f2fs_fs.h> 11#include <linux/f2fs_fs.h>
12#include <linux/seq_file.h> 12#include <linux/seq_file.h>
13#include <linux/unicode.h>
13 14
14#include "f2fs.h" 15#include "f2fs.h"
15#include "segment.h" 16#include "segment.h"
@@ -81,6 +82,19 @@ static ssize_t unusable_show(struct f2fs_attr *a,
81 (unsigned long long)unusable); 82 (unsigned long long)unusable);
82} 83}
83 84
85static ssize_t encoding_show(struct f2fs_attr *a,
86 struct f2fs_sb_info *sbi, char *buf)
87{
88#ifdef CONFIG_UNICODE
89 if (f2fs_sb_has_casefold(sbi))
90 return snprintf(buf, PAGE_SIZE, "%s (%d.%d.%d)\n",
91 sbi->s_encoding->charset,
92 (sbi->s_encoding->version >> 16) & 0xff,
93 (sbi->s_encoding->version >> 8) & 0xff,
94 sbi->s_encoding->version & 0xff);
95#endif
96 return snprintf(buf, PAGE_SIZE, "(none)");
97}
84 98
85static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a, 99static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a,
86 struct f2fs_sb_info *sbi, char *buf) 100 struct f2fs_sb_info *sbi, char *buf)
@@ -134,6 +148,9 @@ static ssize_t features_show(struct f2fs_attr *a,
134 if (f2fs_sb_has_sb_chksum(sbi)) 148 if (f2fs_sb_has_sb_chksum(sbi))
135 len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", 149 len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
136 len ? ", " : "", "sb_checksum"); 150 len ? ", " : "", "sb_checksum");
151 if (f2fs_sb_has_casefold(sbi))
152 len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
153 len ? ", " : "", "casefold");
137 len += snprintf(buf + len, PAGE_SIZE - len, "\n"); 154 len += snprintf(buf + len, PAGE_SIZE - len, "\n");
138 return len; 155 return len;
139} 156}
@@ -365,6 +382,7 @@ enum feat_id {
365 FEAT_INODE_CRTIME, 382 FEAT_INODE_CRTIME,
366 FEAT_LOST_FOUND, 383 FEAT_LOST_FOUND,
367 FEAT_SB_CHECKSUM, 384 FEAT_SB_CHECKSUM,
385 FEAT_CASEFOLD,
368}; 386};
369 387
370static ssize_t f2fs_feature_show(struct f2fs_attr *a, 388static ssize_t f2fs_feature_show(struct f2fs_attr *a,
@@ -382,6 +400,7 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a,
382 case FEAT_INODE_CRTIME: 400 case FEAT_INODE_CRTIME:
383 case FEAT_LOST_FOUND: 401 case FEAT_LOST_FOUND:
384 case FEAT_SB_CHECKSUM: 402 case FEAT_SB_CHECKSUM:
403 case FEAT_CASEFOLD:
385 return snprintf(buf, PAGE_SIZE, "supported\n"); 404 return snprintf(buf, PAGE_SIZE, "supported\n");
386 } 405 }
387 return 0; 406 return 0;
@@ -455,6 +474,7 @@ F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes);
455F2FS_GENERAL_RO_ATTR(features); 474F2FS_GENERAL_RO_ATTR(features);
456F2FS_GENERAL_RO_ATTR(current_reserved_blocks); 475F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
457F2FS_GENERAL_RO_ATTR(unusable); 476F2FS_GENERAL_RO_ATTR(unusable);
477F2FS_GENERAL_RO_ATTR(encoding);
458 478
459#ifdef CONFIG_FS_ENCRYPTION 479#ifdef CONFIG_FS_ENCRYPTION
460F2FS_FEATURE_RO_ATTR(encryption, FEAT_CRYPTO); 480F2FS_FEATURE_RO_ATTR(encryption, FEAT_CRYPTO);
@@ -471,6 +491,7 @@ F2FS_FEATURE_RO_ATTR(quota_ino, FEAT_QUOTA_INO);
471F2FS_FEATURE_RO_ATTR(inode_crtime, FEAT_INODE_CRTIME); 491F2FS_FEATURE_RO_ATTR(inode_crtime, FEAT_INODE_CRTIME);
472F2FS_FEATURE_RO_ATTR(lost_found, FEAT_LOST_FOUND); 492F2FS_FEATURE_RO_ATTR(lost_found, FEAT_LOST_FOUND);
473F2FS_FEATURE_RO_ATTR(sb_checksum, FEAT_SB_CHECKSUM); 493F2FS_FEATURE_RO_ATTR(sb_checksum, FEAT_SB_CHECKSUM);
494F2FS_FEATURE_RO_ATTR(casefold, FEAT_CASEFOLD);
474 495
475#define ATTR_LIST(name) (&f2fs_attr_##name.attr) 496#define ATTR_LIST(name) (&f2fs_attr_##name.attr)
476static struct attribute *f2fs_attrs[] = { 497static struct attribute *f2fs_attrs[] = {
@@ -515,6 +536,7 @@ static struct attribute *f2fs_attrs[] = {
515 ATTR_LIST(features), 536 ATTR_LIST(features),
516 ATTR_LIST(reserved_blocks), 537 ATTR_LIST(reserved_blocks),
517 ATTR_LIST(current_reserved_blocks), 538 ATTR_LIST(current_reserved_blocks),
539 ATTR_LIST(encoding),
518 NULL, 540 NULL,
519}; 541};
520ATTRIBUTE_GROUPS(f2fs); 542ATTRIBUTE_GROUPS(f2fs);
@@ -535,6 +557,7 @@ static struct attribute *f2fs_feat_attrs[] = {
535 ATTR_LIST(inode_crtime), 557 ATTR_LIST(inode_crtime),
536 ATTR_LIST(lost_found), 558 ATTR_LIST(lost_found),
537 ATTR_LIST(sb_checksum), 559 ATTR_LIST(sb_checksum),
560 ATTR_LIST(casefold),
538 NULL, 561 NULL,
539}; 562};
540ATTRIBUTE_GROUPS(f2fs_feat); 563ATTRIBUTE_GROUPS(f2fs_feat);