Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp155334rwb; Thu, 27 Jul 2023 10:40:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlH6ExgwJ+vWL0KwDC86Zn6TtUGzDm3A3kgKA8qOqkn1T5rrACBLRgr8f4vCVZ3Yp6IVYRYq X-Received: by 2002:a17:902:f548:b0:1b0:307c:e6fe with SMTP id h8-20020a170902f54800b001b0307ce6femr24873plf.10.1690479636003; Thu, 27 Jul 2023 10:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690479635; cv=none; d=google.com; s=arc-20160816; b=P7jlqCXUv25bcKvOP1o4hVUskf6YsX6MLf8X/NwH+ujGXi9YTeK7/sxXnvMaWqEUPL O82vAlgFzEhtAn0+nQHVyJle1+pgcItxstb7yBUGNjml8zyxY86jt28EGOgb+dzC6zx0 Q5d09CR5qfN1usJDSquDuPl9icYBvCxpWQ7X+dP0o83MIV4I3GRZdLmBCpmKweVy+IjU +EC9YO1XnQ8ubaCcjxrg0Ve6V6TyXiO3nRbfAAB9i35fKX6BRBhYJ6HHu8XXQ/mSe0aW UIrsdPpsbF73bGe++6X4EIl0BtvubAn5pDE0BIbWxBohWgza8sumEJ57CpYWJONYl4lS yZAw== 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=RwtuevySX+AbS//fDYcBbWTfkuJMDP6s9+imz9u1e46/DRbFEXlLP7D5rCYFbaStaO WASHZpPD8LjZ8q2hKBnODbVrzFatbXCiNLeB5SidUvohF8ZsjNMKr8VrG/c0EKlLJZLO yeQNEkdjMGooQdZPgc/aMs2/YG48otF9ZMLH8x13aqvc1jGdDrKCST/DAci1bSX67vxD sdAxcV8LM2xU6osCiJIg8nZTA+cxGPpX4jXx43Er/n0k9uBYmHYNYkQyF1Mpwmq/t7oA 3kMvF3cifsxR5opFKfD6A0TCflbDlvv0ySEPQDfrgoqruzJik+yPf7hTQo1Pup1dq8Pe 6NPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kzgONCvI; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="l2/NDg3u"; 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 kr12-20020a170903080c00b001b9e0d0a01fsi1554987plb.256.2023.07.27.10.40.21; Thu, 27 Jul 2023 10:40:35 -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=kzgONCvI; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="l2/NDg3u"; 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 S230060AbjG0R3F (ORCPT + 99 others); Thu, 27 Jul 2023 13:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232548AbjG0R3A (ORCPT ); Thu, 27 Jul 2023 13:29:00 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45C3530F4; Thu, 27 Jul 2023 10:28:59 -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-out1.suse.de (Postfix) with ESMTPS id EDB3421AA0; Thu, 27 Jul 2023 17:28:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1690478937; 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=kzgONCvIwwwaeBQ19y/Pj0jIyJNqB0nO9UvX/DIt6W9st6e1fvRvUcZxxLfIMcBAyocYZb /7azvFdNLvcrl17hjci+wdGQgMHKZEYbGYQ0Py89C6yMFXqPPxocjhVQ1YzGV/L97qqPRS MmTP/vgmZD+OwxfK1pxIx+tuczGoMB0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1690478937; 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=l2/NDg3uA23YbKIHQ8MFuPAA48cGUxk4HmPq6ZqjnC93LFDruTjA6p/G7MZpxR3zvhY4qE QDCKGj/Bk4A2SaDg== 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 B82CB13902; Thu, 27 Jul 2023 17:28:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ThNbJ1mpwmTWaAAAMHmgww (envelope-from ); Thu, 27 Jul 2023 17:28:57 +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 v4 6/7] ext4: Enable negative dentries on case-insensitive lookup Date: Thu, 27 Jul 2023 13:28:42 -0400 Message-ID: <20230727172843.20542-7-krisman@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230727172843.20542-1-krisman@suse.de> References: <20230727172843.20542-1-krisman@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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