Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp303332iob; Wed, 11 May 2022 15:01:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaliYYz82txjzsmtu2NM5WWezQvcjWqy56rsRHXS2fOhAWEELlzdzSVjn5B3vT8Nw4xhAo X-Received: by 2002:a63:2a4a:0:b0:3c1:5f7e:beb3 with SMTP id q71-20020a632a4a000000b003c15f7ebeb3mr22125779pgq.441.1652306489268; Wed, 11 May 2022 15:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652306489; cv=none; d=google.com; s=arc-20160816; b=BrIBt8VF2EFOH95gAHWcg33EkQ9876T5owYAKYUDrKMi9Ayon6A6e0OURTNQ2B4Gz4 +zRbBTVSNhdwo3eywL8Yvot9AnGdRrrothwnWkjhQghnZ2R3dRubc7EEgqtfcLI/nOZG RVzCWNg/d9+I4XVLlMSyshF5JTlOXiwtwy4ivchSJDMAyt+WuMOKQRqOe5OjrC5lccpv VQ5lADFp4V8jlJrz+CRNdZWgKZLSl55GiwPgijCi4dsA/yZW5v8K4zfGt15zuruEmxtG PuFa8FgK0kLydtcnShF4VX4hWlBrGYR4WAR8gDTmBWddH45p4NGAQ5UHfX7KDWEXVSYT 1WJw== 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=BiWQtMKZVsSpK2p5rq0NxHvLH8gusOX5yxhKUCGeM1s=; b=YhZhcjrBrGuvyUHb/geLCFrEWEKJnRO65PCfA2vcO0mapmP0pILKNtc65jkZ0fkHz1 6d7FC9xinfwKmLxu5PeNg/NRpND8SmGDB3YYPI6ox9hmd9vZwHLUpcfGKzrFs3T/anEZ +YJcvC9itO3wtHxMR/MKk3MITza4WHVnMjaFA8dYfd/xwsPS0vXzr8XYIFWUZMNsryel L3XOaEY2gXMbkvu/DWjXU5fGMEgca8DG9pqkyABXXpglJYu/TrFKHC2aGBffaWxmQ4WN v+R4rJ9ETMqoJk5pocxTXWwv/LWysYiJ2EDKNkA2VLpJdj4phF7mI8HSE8QHOSNsDnUl qGxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=W3vuzqnc; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n1-20020a6546c1000000b003db370eada7si1183740pgr.11.2022.05.11.15.01.08; Wed, 11 May 2022 15:01:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=W3vuzqnc; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346968AbiEKTci (ORCPT + 99 others); Wed, 11 May 2022 15:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346984AbiEKTce (ORCPT ); Wed, 11 May 2022 15:32:34 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BFF5118010 for ; Wed, 11 May 2022 12:32:26 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 500411F42971 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1652297545; bh=I+NTXd5q40UlKaGrc5vhldVVShFaNrxghoaW9oyhz2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W3vuzqnciBUXQAAjjldyha/9KoplRdfGtrygVkV+9yF+2HgZ1RQVPwcjT5LVfWVlX l09WQx0hbmm/qQvOx+/EnZoPJsJqPP3v5wUQuNIcNFtg/RrKflcVblF2GxKsSqS9uL G1vmxv3uFcW4PUPBiQFeH1NIyYbm/3KW2AqxzAynd54teE2dsVStUK9F8RfLIEAH0D U3afw/i30GH8dRSlPCtoci4AgXfQf7D4zvghbO33hIqIiKvCNELuS7JSf4i5XRO3/M ZTW2vtMh+Z4ptWAhevYRGGDnNVwfpBOyaPuKG+G+IrbCjms8ZPhn8AIiwidsXKlAVL 7/yUOcNBi+0Ew== From: Gabriel Krisman Bertazi To: tytso@mit.edu, adilger.kernel@dilger.ca, jaegeuk@kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, ebiggers@kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v4 09/10] ext4: Move CONFIG_UNICODE defguards into the code flow Date: Wed, 11 May 2022 15:31:45 -0400 Message-Id: <20220511193146.27526-10-krisman@collabora.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220511193146.27526-1-krisman@collabora.com> References: <20220511193146.27526-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham 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 --- fs/ext4/ext4.h | 39 +++++++++++++++++++-------------------- fs/ext4/namei.c | 15 ++++++--------- fs/ext4/super.c | 4 +--- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 93a28fcb2e22..e3c55a8e23bd 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2725,11 +2725,17 @@ extern unsigned ext4_free_clusters_after_init(struct super_block *sb, struct ext4_group_desc *gdp); 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) +{ +#if IS_ENABLED(CONFIG_UNICODE) + kfree(fname->cf_name.name); + fname->cf_name.name = NULL; #endif +} #ifdef CONFIG_FS_ENCRYPTION static inline void ext4_fname_from_fscrypt_name(struct ext4_filename *dst, @@ -2758,9 +2764,9 @@ 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 + if (IS_ENABLED(CONFIG_UNICODE)) + err = ext4_fname_setup_ci_filename(dir, iname, fname); + return err; } @@ -2777,9 +2783,9 @@ 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 + if (IS_ENABLED(CONFIG_UNICODE)) + err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname); + return err; } @@ -2794,10 +2800,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,9 +2813,8 @@ 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 + if (IS_ENABLED(CONFIG_UNICODE)) + err = ext4_fname_setup_ci_filename(dir, iname, fname); return err; } @@ -2826,10 +2828,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 16fd0df5f8a8..0892f9ee15cf 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1757,8 +1757,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 @@ -1766,7 +1765,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi */ return NULL; } -#endif + return d_splice_alias(inode, dentry); } @@ -3083,16 +3082,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); @@ -3188,16 +3185,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