Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1612205rdb; Tue, 20 Feb 2024 01:16:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUWHb71LwIA6cT+6Xiia0uppQdKcKfqMd8xxArb++seIc4ka33+bM4QZiDteY3RFXyECVmH+3JeCozaa2pBrcJiXVhVTD9wYNrEb2yMCQ== X-Google-Smtp-Source: AGHT+IEg9QRqPp0l2nO0+wFPvbdxEq57xV94CJIzh19YBI/ZUQsQKwHrn9Hk6+V0h7kVEmk6LAe4 X-Received: by 2002:a05:6808:3a13:b0:3c1:36ac:2fea with SMTP id gr19-20020a0568083a1300b003c136ac2feamr21282865oib.10.1708420576083; Tue, 20 Feb 2024 01:16:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708420576; cv=pass; d=google.com; s=arc-20160816; b=0Bpy01bSY7IoXx1ccCHGgaREFRaCMsAjpvSJFXNhBrcUzfX180ceOfHSZzGMMbJ7lx yJhu4+jtry+SJ7yy+avyjMSgnRLsh3vI4F4y4ZxC+GRti4OmHpISmFCnbFQFMTEucC5C 8yWIgHb5emILlL9o6GFpC27xaOkp1jkaXLDkD7vmVkdheRTYCE9414Gj1+A+h0LV135b n8uf/e5AeEZ8F98q96tw01XBej7ZtgSTcfTJJd/DAPh80KejHOjfy6/jtkTGw0N5Xg3l nebkxQ9y2waCLB1jKznhxMGhd4KbfT2SuPkmjUl0ADMDRjYoisL5JZV2gOYN0ePNZLgJ 2+GA== 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=5v8Q4bL+GnyxyGiB/xjpiDsZhBzHuD24kApQSma/P+E=; fh=YX4HbHS7wMJfdu6Xp+2MgHIyDiEardnLcvtWgzaTy/w=; b=yICFjlkQ+fTWs0sIArBxqrOz1LDJuLJ1G9NQAKQ/d72IPelIgGVJv2wLe0l0668roT lxCg08aL2eaZblf8k10B+sQmwbRJLLpRgwT85Mj4HReTNZUekbdiuHNYKwLP77eAsFcT 6J0reknz1ygILj3F0AIwSp36qVwW444AP6zsUo93NNkbJrKSS0l+jOy+z1BmD4yS/p+j x2Fzs7CkeYjwVsS2qwoWx8uUd1lbXKG/hgdU+ehpfR+e1zadtcArofHd9S80J7kql0ED GHpyhvEAAKdz3s9K1w7HE6tYBEaX/n2zdn4oRkTOwIf6H47cUQr8RS6q4vfDI2OgXk61 T1Aw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=D74yQCZi; 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-1297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1297-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h8-20020a056a00170800b006e14613024bsi1154764pfc.146.2024.02.20.01.16.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 01:16:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=D74yQCZi; 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-1297-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1297-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5BA4D288AE8 for ; Tue, 20 Feb 2024 08:57:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26022664AC; Tue, 20 Feb 2024 08:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="D74yQCZi" 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 18F1860DF0; Tue, 20 Feb 2024 08:53:19 +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=1708419201; cv=none; b=OpaPxS8UfM2VC61r2M2svnMvjZhVCFy4kjMvLAmwoZazKLsYh0HBBDyHN+1DMH9AiT37ZGCTz4jU0W2y6ystNMNbfR+NMMKChU2sBMBAqhHvjOfYTmJs0bMfuHEI4l4ANgt7wLMTBcRtoQwvTy7RhL1eVakT61e+g2MReYtn4k8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708419201; c=relaxed/simple; bh=hw/qeTCsLdZ3kYNOmC9Du+A6MQKSFpNKhdzd2/uvICE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JuledejPq8qGMwZvwxiZuELe9WqnEgRZP6FC7sy2vdNkJT1+GqCgCTNbE+vt94urk9vQNH8IQBzCgLWlB7L86y1xDpmWynjUUshXueHEfUj9rogmLe3DG5sR2Y4PHMlVqio9iBEvTNuvTHlbRSAjoMs+4BtZGcvV5rcM+40vxx0= 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=D74yQCZi; 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=1708419198; bh=hw/qeTCsLdZ3kYNOmC9Du+A6MQKSFpNKhdzd2/uvICE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D74yQCZi+p1kV7dTH8/fZA6LhV3OXvTKZVX6v0EY9vTYa5S0W4Q4Z9EP3lNE/xJQh fOG6iPHJA++//scemL1A9YyK0v8bW1WQ3vOzEn0uVwd9CeNVU8R2M3/vG9nMMZKkSv Yr0WAbShJA82f+Ri/56S4W07TDX8+/I8L1E4dNdmUk2MIyNsoHzzTZrAPJKWgmImSN jk+kIDorbzN5IPVZxmzcZbahh3eEkwxLS+CZiJawQqVe5Q1wbAm3We3aJ6n0ddgnQg WbrBgcFj6Hah3pSBDOhMn+FXkyEjfuueYZFMkgleM/iQc725aMQapNTf9DB+UdjIlP mY/7FeXxIYB5g== 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 01349378209E; Tue, 20 Feb 2024 08:53:13 +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 , Eric Biggers Subject: [PATCH v12 7/8] ext4: Move CONFIG_UNICODE defguards into the code flow Date: Tue, 20 Feb 2024 10:52:34 +0200 Message-Id: <20240220085235.71132-8-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220085235.71132-1-eugen.hristev@collabora.com> References: <20240220085235.71132-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. Reviewed-by: Eric Biggers Signed-off-by: Gabriel Krisman Bertazi [eugen.hristev@collabora.com: port to 6.8-rc3] Signed-off-by: Eugen Hristev --- fs/ext4/crypto.c | 19 +++---------------- fs/ext4/ext4.h | 33 +++++++++++++++++++++------------ fs/ext4/namei.c | 14 +++++--------- fs/ext4/super.c | 4 +--- 4 files changed, 30 insertions(+), 40 deletions(-) diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c index 7ae0b61258a7..1d2f8b79529c 100644 --- a/fs/ext4/crypto.c +++ b/fs/ext4/crypto.c @@ -31,12 +31,7 @@ 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; + return ext4_fname_setup_ci_filename(dir, iname, fname); } int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry, @@ -51,12 +46,7 @@ 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; + return ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname); } void ext4_fname_free_filename(struct ext4_filename *fname) @@ -70,10 +60,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 932bae88b4a7..18362054b59e 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2742,8 +2742,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 */ @@ -2766,16 +2783,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, @@ -2787,10 +2799,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 7d357c417475..822bd16f76fa 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1835,8 +1835,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 @@ -1844,7 +1843,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi */ return NULL; } -#endif + return d_splice_alias(inode, dentry); } @@ -3174,16 +3173,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); @@ -3285,16 +3282,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 0f931d0c227d..933a9218c20c 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; } -#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