Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8779158rwp; Wed, 19 Jul 2023 15:29:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlGp1tn+FE5SMtGes8Yb1ynNzIUyhOt6BD0nT5RPT/12P4tRr5Kx/LvsBMufUQhqHRDC83/k X-Received: by 2002:a17:906:3103:b0:993:f4cd:34b3 with SMTP id 3-20020a170906310300b00993f4cd34b3mr660332ejx.43.1689805770415; Wed, 19 Jul 2023 15:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689805770; cv=none; d=google.com; s=arc-20160816; b=u1THzHbD4ZrV6FY/VjGNDZGg896Y5GDnK+X8uDuDPLhF6XiouCF/zCkyUG5wxAGSCz Hs1NG9Nnz1qipE+ueZmNg1Tm87S2xY7iJ/yZ5jNNbY/BQbyp/naR9dMZPj4/1INY8u8H Xwi+jwkCigA2APc/+KuVATpNIeLdFAuUIe44WZM9uLfIGL5oRNmtUB9Yr1+dsw3B373L u9LLUh23u4gyYQ+5cQWGRvpkRklcsJ5VhTXFWXrEvm/KAe4ifAoEMQjsi4kEhaYvTukq BieYO9loGL3uaylcNSBI2w7N5sbgJQJ1wYdXq8VbwkRH5fPNDp4tI3s+BY88rTNyv/bp q5DA== 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:dkim-signature; bh=VTjfGOkLLK6RUykHNMhioCEm2Hhni4kuLvFhlgXbJdo=; fh=HFDFbc5lRXwuu0vgGURCiLYm5ywsvQKdSNBX4pGxTs4=; b=d8tbiz1L3K88QnLb1vOBTV7oWKjF1ExfhG0++wXuXoK5gdqMEubAoSS9Tq79RcpSbk wVnU4jojzDv3plzmZusJeUgmfbKDn3c8IncIJT1YcfVnnuffqB8mEB7A8ML/f4RLaO0R 683nW/ZoV7tqbeSFfqxA9Pkh5bj0e/N18982cDpjxMhWShiKWVmcp3Sxs79SJROCCD14 ooYmL5IsDuYEeddbKl9rE/Ae6wEtXuOKkm6wt6uk/ysqcvKk9bHnDcKoM1u12cHN2Yj8 krlsFweQ08p7i3EqPMnYcbOK8B7KKAwJzgiJPYsnLhjmElgWzVRmb5PuWllHtOITHSrd MTjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="1M7h5/A9"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=tSZTvKui; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m20-20020a1709062b9400b0098e1bbc3daesi3393880ejg.731.2023.07.19.15.29.06; Wed, 19 Jul 2023 15:29:30 -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=@suse.de header.s=susede2_rsa header.b="1M7h5/A9"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=tSZTvKui; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230076AbjGSWTo (ORCPT + 99 others); Wed, 19 Jul 2023 18:19:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjGSWTm (ORCPT ); Wed, 19 Jul 2023 18:19:42 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FDDF1FDC; Wed, 19 Jul 2023 15:19:41 -0700 (PDT) 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 Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Gabriel Krisman Bertazi , Gabriel Krisman Bertazi Subject: [PATCH v3 6/7] ext4: Enable negative dentries on case-insensitive lookup 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 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,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,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 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); -- 2.41.0