From nobody Mon Feb 9 10:26:24 2026 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0160132C36; Tue, 2 Apr 2024 15:48:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072941; cv=none; b=HwsCqNuaBuPlHS7WzTpcbMADmE8aQAG7Aq0xhsuVI3Yyh1gOC0XYINJvjWh7fhgPWFPj1T0k50eR7cz45tHwHCVQgLu/iS0dvjTDFkIbW5+B1aeUrXmHgzj/JCXNzpaNCXj3uka618Wdh5CSDrN+f5MCv8mkrY6HMe8Rp9I9nPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072941; c=relaxed/simple; bh=T1flGX4U2b3MklKHYXqMuwFU6gzEg9+QkC8LDI9FchY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qdHFO5tOVbHsdhYDEA0hZ81MkGFrksLuZpDI+ON7ZDxX9nuL9ZQ57bNXaZDm/o/rep4thVswvK2JozacOzfl3ET+58jdM9dW6l3KsfDW/aTObR+dk1dbUgSNoz+s/o+GXB0SQsV64xKFbblBScdeKFGMzuDvbMcGcqeeSOrH7Yo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=OOp3wELE; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="OOp3wELE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712072938; bh=T1flGX4U2b3MklKHYXqMuwFU6gzEg9+QkC8LDI9FchY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OOp3wELEyrUsGGRo4ggcjf7XYfAi0Xh2Gxx5wYSu3TMwsGyVCrErEQNjEZtARwbIx xLLV91e2KqEXy2mztTMQv1oHzrccr4TeZBBiCdeDeEN3ahWhCaZ8YQBqkwRDAjiRzB yyN7ImcHDoT6CLMQY24i9f3uYUuE7IDrK/TbDuvqIbo+OXgBKp38450Qrih2Z3xaLb xAOsewU/Wmc/C79EEq1cLyXtHyCK0K3ctisj284xHgc9tcbIns5QSXTUEuSfXIjKLG RHPslfkJevcsjKn/4KvwqujOZTIHHgYqcBMBxE092HrDdKYFJh3TdpvD5pNBlrPUnq dR8CSdKFrCrSw== Received: from eugen-station.. (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: ehristev) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 1F09C378212C; Tue, 2 Apr 2024 15:48:57 +0000 (UTC) From: Eugen Hristev To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, jaegeuk@kernel.org, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel@collabora.com, eugen.hristev@collabora.com, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, krisman@suse.de, Gabriel Krisman Bertazi Subject: [PATCH v15 8/9] ext4: Move CONFIG_UNICODE defguards into the code flow Date: Tue, 2 Apr 2024 18:48:41 +0300 Message-Id: <20240402154842.508032-9-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402154842.508032-1-eugen.hristev@collabora.com> References: <20240402154842.508032-1-eugen.hristev@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gabriel Krisman Bertazi 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 [eugen.hristev@collabora.com: port to 6.8-rc3] Signed-off-by: Eugen Hristev --- fs/ext4/crypto.c | 10 ++-------- fs/ext4/ext4.h | 33 +++++++++++++++++++++------------ fs/ext4/namei.c | 14 +++++--------- fs/ext4/super.c | 4 +--- 4 files changed, 29 insertions(+), 32 deletions(-) diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c index 7ae0b61258a7..0a056d97e640 100644 --- a/fs/ext4/crypto.c +++ b/fs/ext4/crypto.c @@ -31,11 +31,10 @@ int ext4_fname_setup_filename(struct inode *dir, const = struct qstr *iname, =20 ext4_fname_from_fscrypt_name(fname, &name); =20 -#if IS_ENABLED(CONFIG_UNICODE) err =3D ext4_fname_setup_ci_filename(dir, iname, fname); if (err) ext4_fname_free_filename(fname); -#endif + return err; } =20 @@ -51,11 +50,9 @@ int ext4_fname_prepare_lookup(struct inode *dir, struct = dentry *dentry, =20 ext4_fname_from_fscrypt_name(fname, &name); =20 -#if IS_ENABLED(CONFIG_UNICODE) err =3D ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname); if (err) ext4_fname_free_filename(fname); -#endif return err; } =20 @@ -70,10 +67,7 @@ void ext4_fname_free_filename(struct ext4_filename *fnam= e) fname->usr_fname =3D NULL; fname->disk_name.name =3D NULL; =20 -#if IS_ENABLED(CONFIG_UNICODE) - kfree(fname->cf_name.name); - fname->cf_name.name =3D NULL; -#endif + ext4_fname_free_ci_filename(fname); } =20 static bool uuid_is_zero(__u8 u[16]) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 4061d11b9763..c68f48f706cd 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2740,8 +2740,25 @@ ext4_fsblk_t ext4_inode_to_goal_block(struct inode *= ); =20 #if IS_ENABLED(CONFIG_UNICODE) extern int ext4_fname_setup_ci_filename(struct inode *dir, - const struct qstr *iname, - struct ext4_filename *fname); + const struct qstr *iname, + struct ext4_filename *fname); + +static inline void ext4_fname_free_ci_filename(struct ext4_filename *fname) +{ + kfree(fname->cf_name.name); + fname->cf_name.name =3D NULL; +} +#else +static inline int ext4_fname_setup_ci_filename(struct inode *dir, + const struct qstr *iname, + struct ext4_filename *fname) +{ + return 0; +} + +static inline void ext4_fname_free_ci_filename(struct ext4_filename *fname) +{ +} #endif =20 /* ext4 encryption related stuff goes here crypto.c */ @@ -2764,16 +2781,11 @@ static inline int ext4_fname_setup_filename(struct = inode *dir, int lookup, struct ext4_filename *fname) { - int err =3D 0; fname->usr_fname =3D iname; fname->disk_name.name =3D (unsigned char *) iname->name; fname->disk_name.len =3D iname->len; =20 -#if IS_ENABLED(CONFIG_UNICODE) - err =3D ext4_fname_setup_ci_filename(dir, iname, fname); -#endif - - return err; + return ext4_fname_setup_ci_filename(dir, iname, fname); } =20 static inline int ext4_fname_prepare_lookup(struct inode *dir, @@ -2785,10 +2797,7 @@ static inline int ext4_fname_prepare_lookup(struct i= node *dir, =20 static inline void ext4_fname_free_filename(struct ext4_filename *fname) { -#if IS_ENABLED(CONFIG_UNICODE) - kfree(fname->cf_name.name); - fname->cf_name.name =3D NULL; -#endif + ext4_fname_free_ci_filename(fname); } =20 static inline int ext4_ioctl_get_encryption_pwsalt(struct file *filp, diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 3268cf45d9db..a5d9e5b01015 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1834,8 +1834,7 @@ static struct dentry *ext4_lookup(struct inode *dir, = struct dentry *dentry, unsi } } =20 -#if IS_ENABLED(CONFIG_UNICODE) - if (!inode && IS_CASEFOLDED(dir)) { + if (IS_ENABLED(CONFIG_UNICODE) && !inode && IS_CASEFOLDED(dir)) { /* Eventually we want to call d_add_ci(dentry, NULL) * for negative dentries in the encoding case as * well. For now, prevent the negative dentry @@ -1843,7 +1842,7 @@ static struct dentry *ext4_lookup(struct inode *dir, = struct dentry *dentry, unsi */ return NULL; } -#endif + return d_splice_alias(inode, dentry); } =20 @@ -3173,16 +3172,14 @@ static int ext4_rmdir(struct inode *dir, struct den= try *dentry) ext4_fc_track_unlink(handle, dentry); retval =3D ext4_mark_inode_dirty(handle, dir); =20 -#if IS_ENABLED(CONFIG_UNICODE) /* VFS negative dentries are incompatible with Encoding and * Case-insensitiveness. Eventually we'll want avoid * invalidating the dentries here, alongside with returning the * negative dentries at ext4_lookup(), when it is better * supported by the VFS for the CI case. */ - if (IS_CASEFOLDED(dir)) + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) d_invalidate(dentry); -#endif =20 end_rmdir: brelse(bh); @@ -3284,16 +3281,15 @@ static int ext4_unlink(struct inode *dir, struct de= ntry *dentry) goto out_trace; =20 retval =3D __ext4_unlink(dir, &dentry->d_name, d_inode(dentry), dentry); -#if IS_ENABLED(CONFIG_UNICODE) + /* VFS negative dentries are incompatible with Encoding and * Case-insensitiveness. Eventually we'll want avoid * invalidating the dentries here, alongside with returning the * negative dentries at ext4_lookup(), when it is better * supported by the VFS for the CI case. */ - if (IS_CASEFOLDED(dir)) + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) d_invalidate(dentry); -#endif =20 out_trace: trace_ext4_unlink_exit(dentry, retval); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 215b4614eb15..179083728b4b 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3609,14 +3609,12 @@ int ext4_feature_set_ok(struct super_block *sb, int= readonly) return 0; } =20 -#if !IS_ENABLED(CONFIG_UNICODE) - if (ext4_has_feature_casefold(sb)) { + if (!IS_ENABLED(CONFIG_UNICODE) && ext4_has_feature_casefold(sb)) { ext4_msg(sb, KERN_ERR, "Filesystem with casefold feature cannot be " "mounted without CONFIG_UNICODE"); return 0; } -#endif =20 if (readonly) return 1; --=20 2.34.1