Skip to content

Commit d98c822

Browse files
krisman-at-collaborabrauner
authored andcommitted
ext4: Move CONFIG_UNICODE defguards into the code flow
Instead of a bunch of ifdefs, make the unicode built checks part of the code flow where possible, as requested by Torvalds. 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 d66858e commit d98c822

File tree

4 files changed

+29
-32
lines changed

4 files changed

+29
-32
lines changed

fs/ext4/crypto.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname,
3131

3232
ext4_fname_from_fscrypt_name(fname, &name);
3333

34-
#if IS_ENABLED(CONFIG_UNICODE)
3534
err = ext4_fname_setup_ci_filename(dir, iname, fname);
3635
if (err)
3736
ext4_fname_free_filename(fname);
38-
#endif
37+
3938
return err;
4039
}
4140

@@ -51,11 +50,9 @@ int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry,
5150

5251
ext4_fname_from_fscrypt_name(fname, &name);
5352

54-
#if IS_ENABLED(CONFIG_UNICODE)
5553
err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname);
5654
if (err)
5755
ext4_fname_free_filename(fname);
58-
#endif
5956
return err;
6057
}
6158

@@ -70,10 +67,7 @@ void ext4_fname_free_filename(struct ext4_filename *fname)
7067
fname->usr_fname = NULL;
7168
fname->disk_name.name = NULL;
7269

73-
#if IS_ENABLED(CONFIG_UNICODE)
74-
kfree(fname->cf_name.name);
75-
fname->cf_name.name = NULL;
76-
#endif
70+
ext4_fname_free_ci_filename(fname);
7771
}
7872

7973
static bool uuid_is_zero(__u8 u[16])

fs/ext4/ext4.h

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,8 +2745,25 @@ ext4_fsblk_t ext4_inode_to_goal_block(struct inode *);
27452745

27462746
#if IS_ENABLED(CONFIG_UNICODE)
27472747
extern int ext4_fname_setup_ci_filename(struct inode *dir,
2748-
const struct qstr *iname,
2749-
struct ext4_filename *fname);
2748+
const struct qstr *iname,
2749+
struct ext4_filename *fname);
2750+
2751+
static inline void ext4_fname_free_ci_filename(struct ext4_filename *fname)
2752+
{
2753+
kfree(fname->cf_name.name);
2754+
fname->cf_name.name = NULL;
2755+
}
2756+
#else
2757+
static inline int ext4_fname_setup_ci_filename(struct inode *dir,
2758+
const struct qstr *iname,
2759+
struct ext4_filename *fname)
2760+
{
2761+
return 0;
2762+
}
2763+
2764+
static inline void ext4_fname_free_ci_filename(struct ext4_filename *fname)
2765+
{
2766+
}
27502767
#endif
27512768

27522769
/* ext4 encryption related stuff goes here crypto.c */
@@ -2769,16 +2786,11 @@ static inline int ext4_fname_setup_filename(struct inode *dir,
27692786
int lookup,
27702787
struct ext4_filename *fname)
27712788
{
2772-
int err = 0;
27732789
fname->usr_fname = iname;
27742790
fname->disk_name.name = (unsigned char *) iname->name;
27752791
fname->disk_name.len = iname->len;
27762792

2777-
#if IS_ENABLED(CONFIG_UNICODE)
2778-
err = ext4_fname_setup_ci_filename(dir, iname, fname);
2779-
#endif
2780-
2781-
return err;
2793+
return ext4_fname_setup_ci_filename(dir, iname, fname);
27822794
}
27832795

27842796
static inline int ext4_fname_prepare_lookup(struct inode *dir,
@@ -2790,10 +2802,7 @@ static inline int ext4_fname_prepare_lookup(struct inode *dir,
27902802

27912803
static inline void ext4_fname_free_filename(struct ext4_filename *fname)
27922804
{
2793-
#if IS_ENABLED(CONFIG_UNICODE)
2794-
kfree(fname->cf_name.name);
2795-
fname->cf_name.name = NULL;
2796-
#endif
2805+
ext4_fname_free_ci_filename(fname);
27972806
}
27982807

27992808
static inline int ext4_ioctl_get_encryption_pwsalt(struct file *filp,

fs/ext4/namei.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,16 +1825,15 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
18251825
}
18261826
}
18271827

1828-
#if IS_ENABLED(CONFIG_UNICODE)
1829-
if (!inode && IS_CASEFOLDED(dir)) {
1828+
if (IS_ENABLED(CONFIG_UNICODE) && !inode && IS_CASEFOLDED(dir)) {
18301829
/* Eventually we want to call d_add_ci(dentry, NULL)
18311830
* for negative dentries in the encoding case as
18321831
* well. For now, prevent the negative dentry
18331832
* from being cached.
18341833
*/
18351834
return NULL;
18361835
}
1837-
#endif
1836+
18381837
return d_splice_alias(inode, dentry);
18391838
}
18401839

@@ -3164,16 +3163,14 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
31643163
ext4_fc_track_unlink(handle, dentry);
31653164
retval = ext4_mark_inode_dirty(handle, dir);
31663165

3167-
#if IS_ENABLED(CONFIG_UNICODE)
31683166
/* VFS negative dentries are incompatible with Encoding and
31693167
* Case-insensitiveness. Eventually we'll want avoid
31703168
* invalidating the dentries here, alongside with returning the
31713169
* negative dentries at ext4_lookup(), when it is better
31723170
* supported by the VFS for the CI case.
31733171
*/
3174-
if (IS_CASEFOLDED(dir))
3172+
if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir))
31753173
d_invalidate(dentry);
3176-
#endif
31773174

31783175
end_rmdir:
31793176
brelse(bh);
@@ -3275,16 +3272,15 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
32753272
goto out_trace;
32763273

32773274
retval = __ext4_unlink(dir, &dentry->d_name, d_inode(dentry), dentry);
3278-
#if IS_ENABLED(CONFIG_UNICODE)
3275+
32793276
/* VFS negative dentries are incompatible with Encoding and
32803277
* Case-insensitiveness. Eventually we'll want avoid
32813278
* invalidating the dentries here, alongside with returning the
32823279
* negative dentries at ext4_lookup(), when it is better
32833280
* supported by the VFS for the CI case.
32843281
*/
3285-
if (IS_CASEFOLDED(dir))
3282+
if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir))
32863283
d_invalidate(dentry);
3287-
#endif
32883284

32893285
out_trace:
32903286
trace_ext4_unlink_exit(dentry, retval);

fs/ext4/super.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,14 +3586,12 @@ int ext4_feature_set_ok(struct super_block *sb, int readonly)
35863586
return 0;
35873587
}
35883588

3589-
#if !IS_ENABLED(CONFIG_UNICODE)
3590-
if (ext4_has_feature_casefold(sb)) {
3589+
if (!IS_ENABLED(CONFIG_UNICODE) && ext4_has_feature_casefold(sb)) {
35913590
ext4_msg(sb, KERN_ERR,
35923591
"Filesystem with casefold feature cannot be "
35933592
"mounted without CONFIG_UNICODE");
35943593
return 0;
35953594
}
3596-
#endif
35973595

35983596
if (readonly)
35993597
return 1;

0 commit comments

Comments
 (0)