Skip to content

Commit e6ca288

Browse files
committed
libfs: Merge encrypted_ci_dentry_ops and ci_dentry_ops
In preparation to get case-insensitive dentry operations from sb->s_d_op again, use the same structure with and without fscrypt. Reviewed-by: Eric Biggers <ebiggers@google.com> Link: https://lore.kernel.org/r/20240221171412.10710-6-krisman@suse.de Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
1 parent e9b1071 commit e6ca288

File tree

1 file changed

+6
-28
lines changed

1 file changed

+6
-28
lines changed

fs/libfs.c

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,19 +1772,14 @@ static int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str)
17721772
static const struct dentry_operations generic_ci_dentry_ops = {
17731773
.d_hash = generic_ci_d_hash,
17741774
.d_compare = generic_ci_d_compare,
1775-
};
1776-
#endif
1777-
17781775
#ifdef CONFIG_FS_ENCRYPTION
1779-
static const struct dentry_operations generic_encrypted_dentry_ops = {
17801776
.d_revalidate = fscrypt_d_revalidate,
1777+
#endif
17811778
};
17821779
#endif
17831780

1784-
#if defined(CONFIG_FS_ENCRYPTION) && IS_ENABLED(CONFIG_UNICODE)
1785-
static const struct dentry_operations generic_encrypted_ci_dentry_ops = {
1786-
.d_hash = generic_ci_d_hash,
1787-
.d_compare = generic_ci_d_compare,
1781+
#ifdef CONFIG_FS_ENCRYPTION
1782+
static const struct dentry_operations generic_encrypted_dentry_ops = {
17881783
.d_revalidate = fscrypt_d_revalidate,
17891784
};
17901785
#endif
@@ -1805,38 +1800,21 @@ static const struct dentry_operations generic_encrypted_ci_dentry_ops = {
18051800
* Encryption works differently in that the only dentry operation it needs is
18061801
* d_revalidate, which it only needs on dentries that have the no-key name flag.
18071802
* The no-key flag can't be set "later", so we don't have to worry about that.
1808-
*
1809-
* Finally, to maximize compatibility with overlayfs (which isn't compatible
1810-
* with certain dentry operations) and to avoid taking an unnecessary
1811-
* performance hit, we use custom dentry_operations for each possible
1812-
* combination rather than always installing all operations.
18131803
*/
18141804
void generic_set_encrypted_ci_d_ops(struct dentry *dentry)
18151805
{
1816-
#ifdef CONFIG_FS_ENCRYPTION
1817-
bool needs_encrypt_ops = dentry->d_flags & DCACHE_NOKEY_NAME;
1818-
#endif
18191806
#if IS_ENABLED(CONFIG_UNICODE)
1820-
bool needs_ci_ops = dentry->d_sb->s_encoding;
1821-
#endif
1822-
#if defined(CONFIG_FS_ENCRYPTION) && IS_ENABLED(CONFIG_UNICODE)
1823-
if (needs_encrypt_ops && needs_ci_ops) {
1824-
d_set_d_op(dentry, &generic_encrypted_ci_dentry_ops);
1807+
if (dentry->d_sb->s_encoding) {
1808+
d_set_d_op(dentry, &generic_ci_dentry_ops);
18251809
return;
18261810
}
18271811
#endif
18281812
#ifdef CONFIG_FS_ENCRYPTION
1829-
if (needs_encrypt_ops) {
1813+
if (dentry->d_flags & DCACHE_NOKEY_NAME) {
18301814
d_set_d_op(dentry, &generic_encrypted_dentry_ops);
18311815
return;
18321816
}
18331817
#endif
1834-
#if IS_ENABLED(CONFIG_UNICODE)
1835-
if (needs_ci_ops) {
1836-
d_set_d_op(dentry, &generic_ci_dentry_ops);
1837-
return;
1838-
}
1839-
#endif
18401818
}
18411819
EXPORT_SYMBOL(generic_set_encrypted_ci_d_ops);
18421820

0 commit comments

Comments
 (0)