From patchwork Wed Jul 19 22:19:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13319567 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00E4EC001DF for ; Wed, 19 Jul 2023 22:19:48 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1qMFWO-0006pv-Rt; Wed, 19 Jul 2023 22:19:47 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qMFWO-0006pm-6l for linux-f2fs-devel@lists.sourceforge.net; Wed, 19 Jul 2023 22:19:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=VTjfGOkLLK6RUykHNMhioCEm2Hhni4kuLvFhlgXbJdo=; b=iPMX7aqxvk1U3On2wiPEwb2kvP pSwHZ4+3pZ4u+rWNKxcJ8TI8dkmsap5aQWMVNNYnYC5BHvCdTmjXDHqvfpqOhltyghxf6jKDm/lX1 ZYTBBRCyqkcGFEg+VYzXSNhuRg3PmxPaqjGNjs9OHGP1Scj8flmAGsEjRblb3WxhxjL8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=VTjfGOkLLK6RUykHNMhioCEm2Hhni4kuLvFhlgXbJdo=; b=DYC5Z/R11Y6I/rbjenrcdjtPN/ Wd7kSXHxiPiqJ7YveorawbhIl1IN/xxD1W1WPk1Ul5KWesT7/yZTm1acqOyf4BJlBRY3r8tSIFbOJ F9rWVnLyFnnYfnmvtrhNog16YJIm4GUXFoOsM5yur/MPxH4HiBclFUMIR5uMT9HDNWT8=; Received: from smtp-out2.suse.de ([195.135.220.29]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1qMFWM-00DW3I-8y for linux-f2fs-devel@lists.sourceforge.net; Wed, 19 Jul 2023 22:19:47 +0000 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0EF4B201F3; Wed, 19 Jul 2023 22:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689805180; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VTjfGOkLLK6RUykHNMhioCEm2Hhni4kuLvFhlgXbJdo=; b=1M7h5/A9IyHwu86mSVNuUu97s+QPdsgXlJERSKBsoW97Ba86xYOrSLwxrbNAqlhIPiOO5+ 1ojuYeH7CJMYFxVlc1eJ6WYm1I2WtFXVQNN0k+Dj4KdReEM29N9YLBUymYMqrcdGqdZrRg CCrKm9F6OC/zpkKzs2RF2PxTjO/Bkxw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689805180; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VTjfGOkLLK6RUykHNMhioCEm2Hhni4kuLvFhlgXbJdo=; b=tSZTvKuiJU0xt3vz6BEfEN4aAzdZSvolrTJRRJoMOjtsfnlQK6qMtvm0uZ7+LoyZUeCcy+ OTLwoa7nNsPQZhCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CDB6E1361C; Wed, 19 Jul 2023 22:19:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id hJ+kLHthuGQlJgAAMHmgww (envelope-from ); Wed, 19 Jul 2023 22:19:39 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, brauner@kernel.org, tytso@mit.edu, ebiggers@kernel.org, jaegeuk@kernel.org Date: Wed, 19 Jul 2023 18:19:17 -0400 Message-ID: <20230719221918.8937-7-krisman@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230719221918.8937-1-krisman@suse.de> References: <20230719221918.8937-1-krisman@suse.de> MIME-Version: 1.0 X-Headers-End: 1qMFWM-00DW3I-8y Subject: [f2fs-dev] [PATCH v3 6/7] ext4: Enable negative dentries on case-insensitive lookup X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi , linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Gabriel Krisman Bertazi Instead of invalidating negative dentries during case-insensitive lookups, mark them as such and let them be added to the dcache. d_ci_revalidate is able to properly filter them out if necessary based on the dentry casefold flag. Signed-off-by: Gabriel Krisman Bertazi --- Changes since v2: - Move dentry flag set closer to fscrypt code (Eric) --- fs/ext4/namei.c | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 0caf6c730ce3..b22194a83e1a 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1759,6 +1759,10 @@ static struct buffer_head *ext4_lookup_entry(struct inode *dir, err = ext4_fname_prepare_lookup(dir, dentry, &fname); generic_set_encrypted_ci_d_ops(dentry); + + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + d_set_casefold_lookup(dentry); + if (err == -ENOENT) return NULL; if (err) @@ -1866,16 +1870,6 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi } } -#if IS_ENABLED(CONFIG_UNICODE) - if (!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 - * from being cached. - */ - return NULL; - } -#endif return d_splice_alias(inode, dentry); } @@ -3206,17 +3200,6 @@ 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)) - d_invalidate(dentry); -#endif - end_rmdir: brelse(bh); if (handle) @@ -3317,16 +3300,6 @@ 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)) - d_invalidate(dentry); -#endif out_trace: trace_ext4_unlink_exit(dentry, retval);