summaryrefslogtreecommitdiffstats
path: root/fs/ext4/ext4.h
diff options
context:
space:
mode:
authorGabriel Krisman Bertazi <krisman@collabora.co.uk>2019-04-25 14:05:42 -0400
committerTheodore Ts'o <tytso@mit.edu>2019-04-25 14:05:42 -0400
commitc83ad55eaa91c8e85dd8cc3b7b3485fac45ef7bf (patch)
tree6c10e8bab625a1643fc7ca468fa00b6f20899971 /fs/ext4/ext4.h
parente765b4abb2215b88f227e3bed7757474b6e77402 (diff)
ext4: include charset encoding information in the superblock
Support for encoding is considered an incompatible feature, since it has potential to create collisions of file names in existing filesystems. If the feature flag is not enabled, the entire filesystem will operate on opaque byte sequences, respecting the original behavior. 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: Gabriel Krisman Bertazi <krisman@collabora.co.uk> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r--fs/ext4/ext4.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 2a2e6ed9aab4..c1504c471fef 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1313,7 +1313,9 @@ struct ext4_super_block {
1313 __u8 s_first_error_time_hi; 1313 __u8 s_first_error_time_hi;
1314 __u8 s_last_error_time_hi; 1314 __u8 s_last_error_time_hi;
1315 __u8 s_pad[2]; 1315 __u8 s_pad[2];
1316 __le32 s_reserved[96]; /* Padding to the end of the block */ 1316 __le16 s_encoding; /* Filename charset encoding */
1317 __le16 s_encoding_flags; /* Filename charset encoding flags */
1318 __le32 s_reserved[95]; /* Padding to the end of the block */
1317 __le32 s_checksum; /* crc32c(superblock) */ 1319 __le32 s_checksum; /* crc32c(superblock) */
1318}; 1320};
1319 1321
@@ -1338,6 +1340,16 @@ struct ext4_super_block {
1338/* Number of quota types we support */ 1340/* Number of quota types we support */
1339#define EXT4_MAXQUOTAS 3 1341#define EXT4_MAXQUOTAS 3
1340 1342
1343#define EXT4_ENC_UTF8_12_1 1
1344
1345/*
1346 * Flags for ext4_sb_info.s_encoding_flags.
1347 */
1348#define EXT4_ENC_STRICT_MODE_FL (1 << 0)
1349
1350#define ext4_has_strict_mode(sbi) \
1351 (sbi->s_encoding_flags & EXT4_ENC_STRICT_MODE_FL)
1352
1341/* 1353/*
1342 * fourth extended-fs super-block data in memory 1354 * fourth extended-fs super-block data in memory
1343 */ 1355 */
@@ -1387,6 +1399,10 @@ struct ext4_sb_info {
1387 struct kobject s_kobj; 1399 struct kobject s_kobj;
1388 struct completion s_kobj_unregister; 1400 struct completion s_kobj_unregister;
1389 struct super_block *s_sb; 1401 struct super_block *s_sb;
1402#ifdef CONFIG_UNICODE
1403 struct unicode_map *s_encoding;
1404 __u16 s_encoding_flags;
1405#endif
1390 1406
1391 /* Journaling */ 1407 /* Journaling */
1392 struct journal_s *s_journal; 1408 struct journal_s *s_journal;
@@ -1660,6 +1676,7 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
1660#define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 /* >2GB or 3-lvl htree */ 1676#define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 /* >2GB or 3-lvl htree */
1661#define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */ 1677#define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */
1662#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000 1678#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
1679#define EXT4_FEATURE_INCOMPAT_CASEFOLD 0x20000
1663 1680
1664extern void ext4_update_dynamic_rev(struct super_block *sb); 1681extern void ext4_update_dynamic_rev(struct super_block *sb);
1665 1682
@@ -1753,6 +1770,7 @@ EXT4_FEATURE_INCOMPAT_FUNCS(csum_seed, CSUM_SEED)
1753EXT4_FEATURE_INCOMPAT_FUNCS(largedir, LARGEDIR) 1770EXT4_FEATURE_INCOMPAT_FUNCS(largedir, LARGEDIR)
1754EXT4_FEATURE_INCOMPAT_FUNCS(inline_data, INLINE_DATA) 1771EXT4_FEATURE_INCOMPAT_FUNCS(inline_data, INLINE_DATA)
1755EXT4_FEATURE_INCOMPAT_FUNCS(encrypt, ENCRYPT) 1772EXT4_FEATURE_INCOMPAT_FUNCS(encrypt, ENCRYPT)
1773EXT4_FEATURE_INCOMPAT_FUNCS(casefold, CASEFOLD)
1756 1774
1757#define EXT2_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR 1775#define EXT2_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR
1758#define EXT2_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \ 1776#define EXT2_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \
@@ -1780,6 +1798,7 @@ EXT4_FEATURE_INCOMPAT_FUNCS(encrypt, ENCRYPT)
1780 EXT4_FEATURE_INCOMPAT_MMP | \ 1798 EXT4_FEATURE_INCOMPAT_MMP | \
1781 EXT4_FEATURE_INCOMPAT_INLINE_DATA | \ 1799 EXT4_FEATURE_INCOMPAT_INLINE_DATA | \
1782 EXT4_FEATURE_INCOMPAT_ENCRYPT | \ 1800 EXT4_FEATURE_INCOMPAT_ENCRYPT | \
1801 EXT4_FEATURE_INCOMPAT_CASEFOLD | \
1783 EXT4_FEATURE_INCOMPAT_CSUM_SEED | \ 1802 EXT4_FEATURE_INCOMPAT_CSUM_SEED | \
1784 EXT4_FEATURE_INCOMPAT_LARGEDIR) 1803 EXT4_FEATURE_INCOMPAT_LARGEDIR)
1785#define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ 1804#define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \