Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp678110iob; Wed, 18 May 2022 10:25:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj563NzqalAW+WgnDD+s6WZ1RPZ+KTU77dnea+BIJmcmMvIsccHvLeSRnyDvASaHIPUMnq X-Received: by 2002:a17:90b:4b8a:b0:1df:75f2:d2f4 with SMTP id lr10-20020a17090b4b8a00b001df75f2d2f4mr473929pjb.109.1652894718722; Wed, 18 May 2022 10:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652894718; cv=none; d=google.com; s=arc-20160816; b=CR1zRqoJ0q8JTPefVXXnOLR59C611DxFuN1fDCLOpViTLYblcIjV5twTkVths3l9Il gSe0QaAZ4XLf3MdBI9YcyjZzXy27c6vLVp+6ggcFqnC7twLphwkVmZTMX0dugGFFEggs NtGhzL17UmC3RKPDiSBlZCY313jkK35Nep+M5RUCKDuyvHpCbk/Hs9g7It5SLNq7vOXf FmhM820J6uQoXI316fTfcs2mbJe+3FnmLvp/EXT7xzpkqYC5CjZ0e88sOwYgehNOoxIw fnIOw+7bQA6hubgVGfJQpITBHm5An2radjZIAcC17HebEzyiV/lULB7sLMzBGJdsOuMN rehQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dTtuy6FHL3LDsNMmhMcZalJs4r3jCsg4l9LdOBoHKWs=; b=lNVDNjgUX4BLk2EsKAYbtdF9kH9i49hFbns5HHwLjUEMR0mRoqb8H80dNLQcROnKTf K8BcRJKpA8MEDhEhATEBnZBVqAb0TQR+ERvUXVgU2MEUMPr+q/p7j6tLSy5NAypNm4WW 8KXooK7Xnz3YKtF09LkRW7Oo+i0TuW9cAMP4Uc9c1VABFfJfQ5qAu4Tf7U6H7ygEDkTy u+CfeyK2U4AkwdD/uC/iIS2B7ey+N35tN4fnk6dDpUVukx67iLZ8TxUKyKdT//NWsD+2 eGc8EvOg9cyDFUVOBnHOSyzh7hoHP4ikbNbNGqP3GV3tH/jvg0m3Hn/YuQeFjuYpJqRK CTvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="fE/j4efQ"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u6-20020a056a00158600b005104bd4abfbsi4117373pfk.22.2022.05.18.10.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 10:25:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="fE/j4efQ"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 692111AB78A; Wed, 18 May 2022 10:24:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240979AbiERRX7 (ORCPT + 99 others); Wed, 18 May 2022 13:23:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240986AbiERRX6 (ORCPT ); Wed, 18 May 2022 13:23:58 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D2EA1A6AFA for ; Wed, 18 May 2022 10:23:57 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id CBBA01F41D2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1652894636; bh=qMxG+YpzRa2Wq/dXFds2CiSdQlWL7Xpfua9M2xxz+Yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fE/j4efQcO18YVnQn2Z/ck/HtH3yHG/qyxHZxcmP2hrny7b1xRMpV8xb295NlFwL7 N7oCR6PY/BloslcLUJ9Jsp9ov1Lq8ldXOK96+gCHf3hPgrReltgKEKE5rPwfbdpysn Y7D73c7qxY+8oq2JfXFGy/VePX4BQle9xRJkc+9RxRIo/hVVhs0JCliAIqm5aDiXJX h9gxdMDojBaPBkw5kRssWOkwjSYahk7JyBbWdAPQE3BJ68nhz3XqD9j/MV1bnZhboI 7hUkZVFFEck7CQS2tMB1BIRZs1c+I0P5rFXoHCUmgYQf8SyJLbNQPPtVGRc3dNOIBE qxaxCyBjIAKqg== From: Gabriel Krisman Bertazi To: tytso@mit.edu, adilger.kernel@dilger.ca, jaegeuk@kernel.org, ebiggers@kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v5 7/8] ext4: Move CONFIG_UNICODE defguards into the code flow Date: Wed, 18 May 2022 13:23:19 -0400 Message-Id: <20220518172320.333617-8-krisman@collabora.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220518172320.333617-1-krisman@collabora.com> References: <20220518172320.333617-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- Changes since v4: - Create stub for !CONFIG_UNICODE case (eric) --- fs/ext4/ext4.h | 37 ++++++++++++++++++++----------------- fs/ext4/namei.c | 15 ++++++--------- fs/ext4/super.c | 4 +--- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 93a28fcb2e22..c38999ee3627 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2727,8 +2727,24 @@ 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 #ifdef CONFIG_FS_ENCRYPTION @@ -2758,9 +2774,7 @@ static inline int ext4_fname_setup_filename(struct inode *dir, ext4_fname_from_fscrypt_name(fname, &name); -#if IS_ENABLED(CONFIG_UNICODE) err = ext4_fname_setup_ci_filename(dir, iname, fname); -#endif return err; } @@ -2777,9 +2791,7 @@ static inline int ext4_fname_prepare_lookup(struct inode *dir, ext4_fname_from_fscrypt_name(fname, &name); -#if IS_ENABLED(CONFIG_UNICODE) err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname); -#endif return err; } @@ -2794,10 +2806,7 @@ static inline 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); } #else /* !CONFIG_FS_ENCRYPTION */ static inline int ext4_fname_setup_filename(struct inode *dir, @@ -2810,10 +2819,7 @@ static inline int ext4_fname_setup_filename(struct inode *dir, 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; } @@ -2826,10 +2832,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); } #endif /* !CONFIG_FS_ENCRYPTION */ diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 8fbb35187f72..f142c8fef750 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1755,8 +1755,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 @@ -1764,7 +1763,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi */ return NULL; } -#endif + return d_splice_alias(inode, dentry); } @@ -3081,16 +3080,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); @@ -3186,16 +3183,16 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) retval = __ext4_unlink(handle, dir, &dentry->d_name, d_inode(dentry)); if (!retval) ext4_fc_track_unlink(handle, 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 + if (handle) ext4_journal_stop(handle); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 1847b46af808..fa0004459dd6 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3645,14 +3645,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.36.1