Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp204680lqt; Thu, 6 Jun 2024 00:36:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWpwLwynpr7RdHBru7LZUgWLKYkABmQDKl92zBzGJFlJKgD695H6qKaWCwkx800Ce/lSs7D7jLF2iZHEdtDTs+HheCZPrpwsNmNY3mKw== X-Google-Smtp-Source: AGHT+IGboJk5qrQKBxybNtQ0PUkAiX5USXeJSahV/tKcxMR1S6FiRRd1D+c/7iRfZl7/CjAgxo7C X-Received: by 2002:ac8:58d5:0:b0:440:1c5f:2298 with SMTP id d75a77b69052e-4402b60e5b1mr46551351cf.29.1717659388814; Thu, 06 Jun 2024 00:36:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717659388; cv=pass; d=google.com; s=arc-20160816; b=H2NGX374A2yuG0Gh3UZdlHO4oHfIo7GJG1t9OPl9E0UZc8FHB0qOPk2sa8RP6bJAqS e6bJPIk6etBp0JWI/cyiN+MCfutciEzWnxdEpXuv0s92BY9lLyG8fGBSGMZhZAmaM2Wr uOi55Nu2ksPV1FaMoJ0nP2mrdZflkgvUfy0TdllqcrDKj4MkUzNQhKqCtj8QeJ8LVu+a k2+3ZSKIjn9xlnpCEw0mX+BBA5Y9Fqy4v85HY/o5EC3rue4ywXf/hIG4RPvpMaHrlGjY JFIFcYxivUwXPg4C3aeVlzk8MiQcWHdp6G8b8RN7ffkNeEhzOcJGg5NkplKwShnz567J Ma/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TeZmLddASyUyyqW0lGMXvlubSJASJqH4uDkBM8DY1vw=; fh=JvuDsSGtkczZqWhaRfigYAR3g2CTmyQpNIyLSKcTTXA=; b=FemmO2PzJb5dw9tIu1DdgNyBOQIQUzsNzHv/Uc2lsdbNx8sN6zbtU4XVsUreBWf24Y 4imCC4O486nMvdKLjlHmIAxyTEnzvTLrXTzCBE2QRALiGG263ddJ+RDNuWeMQ+FFNWdR mtG6G53C2sbqLPPfenEUj76Esp1/P67hhdpJnaOdtgwEhRoF7sN+apGwaN3YndIRPQDd Tu9Qwta+sMpNZKKlxNqMwpZehysujaiE35fz2NwG/pGhzz9rdkvR1REUMrTjKQew50LH n+IPeblFgI2nQYP8gK4T1zxaPTFqTrRe7LuKy9+8fWFpDm2RO+jE22R+ZI5S4uMaRLXN d6gw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=gtn1sEAP; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-ext4+bounces-2797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2797-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-79533333b19si81489385a.539.2024.06.06.00.36.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 00:36:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=gtn1sEAP; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-ext4+bounces-2797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2797-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7BA6A1C24241 for ; Thu, 6 Jun 2024 07:36:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 899F813EFEE; Thu, 6 Jun 2024 07:34:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="gtn1sEAP" X-Original-To: linux-ext4@vger.kernel.org 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 8614713B28F; Thu, 6 Jun 2024 07:34:43 +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=1717659285; cv=none; b=ZenCSMbfLia9FGH1q4X4xjkmIRgrnA1028QOEFyaLEBiKbbSM7lKaOpW8L06fhOWAbRo44sajthbl6DA8Z/CUtL7ixP51XdIApCG154pQ2VqWJZM2qx5GY/+3gERhLn6+9/yi6Sh4Sz5SZO9kwIa/YQRE7N7EWM8htCZNK8H2hw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717659285; c=relaxed/simple; bh=7MXCNIfbhOHe7WuXF+nvpbNl5SCDeGsd3fUVla5hgUU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sXGqrIEougrnTREcHBHB8MLFZS8Cj6xO/2aSplOl9j0ehlWSPORj29BWBzK/90pxH5itTwVQ4VMbW4VDjHs94Fx2Lhnqts6+fLMDcJrzT12k5//LsK3zTisK/ygnPd7toS4gOuNaOQpw5yZkoM7eHIsiYVujIrosULx9A3Z2pC4= 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=gtn1sEAP; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1717659282; bh=7MXCNIfbhOHe7WuXF+nvpbNl5SCDeGsd3fUVla5hgUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gtn1sEAP3bzQJnQTgYb0KBb7QkSr+LCpLQmBzfIpQHK4kAjEaJxWQBrnBh/C4sf0y gVXeny5hAk9eP9hNFyVEEeQvuTOpCUMQmFIIi5uy53g/Va1Yz0QeAdlbPsO3R78exP +lguXn5UAFwKhZJROLWpq6uE7Ik7vMjw/l0SvFmb4y/6pQWA5H6/JOswlyr9fR1i+D pZwM2BfC1/Imdieb3Yc5wjPXo4O8lTaKlb2ifkJ/t3gw3LPhRROydVx7w2keV1A9nm 7PtZKeellt3vLuMKXDfjiQ/BgriFbPIKft9+ebmFvNK1Rii0uG/SaBV0yCc3Ql5Ww8 5Gw0OI/Wi0frQ== 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 0690037821DD; Thu, 6 Jun 2024 07:34:40 +0000 (UTC) From: Eugen Hristev To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, jaegeuk@kernel.org, adilger.kernel@dilger.ca, tytso@mit.edu Cc: chao@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, ebiggers@google.com, krisman@suse.de, kernel@collabora.com, Gabriel Krisman Bertazi , Eugen Hristev Subject: [PATCH v18 6/7] ext4: Move CONFIG_UNICODE defguards into the code flow Date: Thu, 6 Jun 2024 10:33:52 +0300 Message-Id: <20240606073353.47130-7-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240606073353.47130-1-eugen.hristev@collabora.com> References: <20240606073353.47130-1-eugen.hristev@collabora.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.10-rc1] Signed-off-by: Eugen Hristev Reviewed-by: Eric Biggers --- 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, ext4_fname_from_fscrypt_name(fname, &name); -#if IS_ENABLED(CONFIG_UNICODE) err = ext4_fname_setup_ci_filename(dir, iname, fname); if (err) ext4_fname_free_filename(fname); -#endif + return err; } @@ -51,11 +50,9 @@ int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry, ext4_fname_from_fscrypt_name(fname, &name); -#if IS_ENABLED(CONFIG_UNICODE) err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname); if (err) ext4_fname_free_filename(fname); -#endif return err; } @@ -70,10 +67,7 @@ void ext4_fname_free_filename(struct ext4_filename *fname) fname->usr_fname = NULL; fname->disk_name.name = NULL; -#if IS_ENABLED(CONFIG_UNICODE) - kfree(fname->cf_name.name); - fname->cf_name.name = NULL; -#endif + ext4_fname_free_ci_filename(fname); } static bool uuid_is_zero(__u8 u[16]) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index deffd7431c8b..8007abd4972d 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2745,8 +2745,25 @@ ext4_fsblk_t ext4_inode_to_goal_block(struct inode *); #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 = 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 /* ext4 encryption related stuff goes here crypto.c */ @@ -2769,16 +2786,11 @@ static inline int ext4_fname_setup_filename(struct inode *dir, int lookup, struct ext4_filename *fname) { - int err = 0; fname->usr_fname = iname; fname->disk_name.name = (unsigned char *) iname->name; fname->disk_name.len = iname->len; -#if IS_ENABLED(CONFIG_UNICODE) - err = ext4_fname_setup_ci_filename(dir, iname, fname); -#endif - - return err; + return ext4_fname_setup_ci_filename(dir, iname, fname); } static inline int ext4_fname_prepare_lookup(struct inode *dir, @@ -2790,10 +2802,7 @@ static inline int ext4_fname_prepare_lookup(struct inode *dir, 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 = NULL; -#endif + ext4_fname_free_ci_filename(fname); } static inline int ext4_ioctl_get_encryption_pwsalt(struct file *filp, diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index d10ea0f3f64d..e6769b97a970 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1825,8 +1825,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi } } -#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 @@ -1834,7 +1833,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi */ return NULL; } -#endif + return d_splice_alias(inode, dentry); } @@ -3164,16 +3163,14 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) ext4_fc_track_unlink(handle, dentry); retval = ext4_mark_inode_dirty(handle, dir); -#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 end_rmdir: brelse(bh); @@ -3275,16 +3272,15 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) goto out_trace; retval = __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 out_trace: trace_ext4_unlink_exit(dentry, retval); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index c682fb927b64..d2d2254a9ded 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3586,14 +3586,12 @@ int ext4_feature_set_ok(struct super_block *sb, int readonly) return 0; } -#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 if (readonly) return 1; -- 2.34.1