Skip to content

Commit f776f02

Browse files
krisman-at-collaborabrauner
authored andcommitted
ext4: Simplify the handling of cached casefolded names
Keeping it as qstr avoids the unnecessary conversion in ext4_match Signed-off-by: Gabriel Krisman Bertazi <[email protected]> [[email protected]: port to 6.10-rc1] Signed-off-by: Eugen Hristev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Eric Biggers <[email protected]> Reviewed-by: Gabriel Krisman Bertazi <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 1613e60 commit f776f02

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

fs/ext4/ext4.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2511,7 +2511,7 @@ struct ext4_filename {
25112511
struct fscrypt_str crypto_buf;
25122512
#endif
25132513
#if IS_ENABLED(CONFIG_UNICODE)
2514-
struct fscrypt_str cf_name;
2514+
struct qstr cf_name;
25152515
#endif
25162516
};
25172517

fs/ext4/namei.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,8 @@ static int ext4_ci_compare(const struct inode *parent, const struct qstr *name,
14451445
int ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
14461446
struct ext4_filename *name)
14471447
{
1448-
struct fscrypt_str *cf_name = &name->cf_name;
1448+
struct qstr *cf_name = &name->cf_name;
1449+
unsigned char *buf;
14491450
struct dx_hash_info *hinfo = &name->hinfo;
14501451
int len;
14511452

@@ -1455,18 +1456,18 @@ int ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
14551456
return 0;
14561457
}
14571458

1458-
cf_name->name = kmalloc(EXT4_NAME_LEN, GFP_NOFS);
1459-
if (!cf_name->name)
1459+
buf = kmalloc(EXT4_NAME_LEN, GFP_NOFS);
1460+
if (!buf)
14601461
return -ENOMEM;
14611462

1462-
len = utf8_casefold(dir->i_sb->s_encoding,
1463-
iname, cf_name->name,
1464-
EXT4_NAME_LEN);
1463+
len = utf8_casefold(dir->i_sb->s_encoding, iname, buf, EXT4_NAME_LEN);
14651464
if (len <= 0) {
1466-
kfree(cf_name->name);
1467-
cf_name->name = NULL;
1465+
kfree(buf);
1466+
buf = NULL;
14681467
}
1468+
cf_name->name = buf;
14691469
cf_name->len = (unsigned) len;
1470+
14701471
if (!IS_ENCRYPTED(dir))
14711472
return 0;
14721473

@@ -1503,8 +1504,6 @@ static bool ext4_match(struct inode *parent,
15031504
if (IS_CASEFOLDED(parent) &&
15041505
(!IS_ENCRYPTED(parent) || fscrypt_has_encryption_key(parent))) {
15051506
if (fname->cf_name.name) {
1506-
struct qstr cf = {.name = fname->cf_name.name,
1507-
.len = fname->cf_name.len};
15081507
if (IS_ENCRYPTED(parent)) {
15091508
if (fname->hinfo.hash != EXT4_DIRENT_HASH(de) ||
15101509
fname->hinfo.minor_hash !=
@@ -1513,8 +1512,8 @@ static bool ext4_match(struct inode *parent,
15131512
return false;
15141513
}
15151514
}
1516-
return !ext4_ci_compare(parent, &cf, de->name,
1517-
de->name_len, true);
1515+
return !ext4_ci_compare(parent, &fname->cf_name,
1516+
de->name, de->name_len, true);
15181517
}
15191518
return !ext4_ci_compare(parent, fname->usr_fname, de->name,
15201519
de->name_len, false);

0 commit comments

Comments
 (0)