ext4: remove redundant checks of s_encoding
authorEric Biggers <ebiggers@google.com>
Mon, 14 Aug 2023 18:29:02 +0000 (11:29 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 27 Aug 2023 15:27:13 +0000 (11:27 -0400)
Now that ext4 does not allow inodes with the casefold flag to be
instantiated when unsupported, it's unnecessary to repeatedly check for
support later on during random filesystem operations.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20230814182903.37267-3-ebiggers@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/hash.c
fs/ext4/namei.c

index 46c3423ddfa17e5363d451d7351de4d8aba14bc7..deabe29da7fbc3d35f674ff861a2f3b579ffdea2 100644 (file)
@@ -300,7 +300,7 @@ int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
        unsigned char *buff;
        struct qstr qstr = {.name = name, .len = len };
 
-       if (len && IS_CASEFOLDED(dir) && um &&
+       if (len && IS_CASEFOLDED(dir) &&
           (!IS_ENCRYPTED(dir) || fscrypt_has_encryption_key(dir))) {
                buff = kzalloc(sizeof(char) * PATH_MAX, GFP_KERNEL);
                if (!buff)
index 9a13431656cd8b3b72871eb21a450e609b39cf43..c0f0b4e2413b5e7dc4f9f23ad7ae49b250a69c3e 100644 (file)
@@ -1445,7 +1445,7 @@ int ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
        struct dx_hash_info *hinfo = &name->hinfo;
        int len;
 
-       if (!IS_CASEFOLDED(dir) || !dir->i_sb->s_encoding ||
+       if (!IS_CASEFOLDED(dir) ||
            (IS_ENCRYPTED(dir) && !fscrypt_has_encryption_key(dir))) {
                cf_name->name = NULL;
                return 0;
@@ -1496,7 +1496,7 @@ static bool ext4_match(struct inode *parent,
 #endif
 
 #if IS_ENABLED(CONFIG_UNICODE)
-       if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent) &&
+       if (IS_CASEFOLDED(parent) &&
            (!IS_ENCRYPTED(parent) || fscrypt_has_encryption_key(parent))) {
                if (fname->cf_name.name) {
                        struct qstr cf = {.name = fname->cf_name.name,
@@ -2393,7 +2393,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
 
 #if IS_ENABLED(CONFIG_UNICODE)
        if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) &&
-           sb->s_encoding && utf8_validate(sb->s_encoding, &dentry->d_name))
+           utf8_validate(sb->s_encoding, &dentry->d_name))
                return -EINVAL;
 #endif