From patchwork Fri Feb 3 21:00:34 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: 1737257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=gandalf.ozlabs.org; envelope-from=srs0=bcsk=57=vger.kernel.org=linux-ext4-owner@ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=HYahpR9q; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Y781/F/K; dkim-atps=neutral Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P7p6K0c6Qz23hd for ; Sat, 4 Feb 2023 08:03:37 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4P7p6K09VXz4xZj for ; Sat, 4 Feb 2023 08:03:37 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4P7p6K071Wz4xxJ; Sat, 4 Feb 2023 08:03:37 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=HYahpR9q; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Y781/F/K; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4P7p6K02Crz4xZj for ; Sat, 4 Feb 2023 08:03:36 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233693AbjBCVDd (ORCPT ); Fri, 3 Feb 2023 16:03:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233386AbjBCVCQ (ORCPT ); Fri, 3 Feb 2023 16:02:16 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65549A9D70; Fri, 3 Feb 2023 13:01:00 -0800 (PST) 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 22B4F35227; Fri, 3 Feb 2023 21:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1675458059; 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=xvvmq4e+UnqjqHZYFWY+SBLpSNDieXa5F6FXm74ran0=; b=HYahpR9qIPXN3yqqoea6UWTGw+G2MhBYnPG+zcq5zAeBZX0gULd/yYcU6CW29w7Odn6VI1 a9TZ+WyDDp+QYjCadv8Gb9crGeYiUSCnTRYFehvRVKlQwYQOnfjAyokM2jxVpn8T66gOTn /A7qGafBe/dADhpfCfIxbAtlEO4VDPE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1675458059; 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=xvvmq4e+UnqjqHZYFWY+SBLpSNDieXa5F6FXm74ran0=; b=Y781/F/KHOG0LdivmD+cc4alLvZS7OpJHSbM0xnLmCcV3guYK11s9UwrrOMNvSpO/tVtHn PqpADwhJwjvLbeDQ== 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 A52641358A; Fri, 3 Feb 2023 21:00:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id BT5aGwp23WPwJgAAMHmgww (envelope-from ); Fri, 03 Feb 2023 21:00:58 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, tytso@mit.edu, jaegeuk@kernel.org, ebiggers@kernel.org, jack@suse.cz Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Gabriel Krisman Bertazi Subject: [PATCH v2 2/7] fs: Add DCACHE_CASEFOLD_LOOKUP flag Date: Fri, 3 Feb 2023 18:00:34 -0300 Message-Id: <20230203210039.16289-3-krisman@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230203210039.16289-1-krisman@suse.de> References: <20230203210039.16289-1-krisman@suse.de> MIME-Version: 1.0 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 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 This flag marks a negative or positive dentry as being created after a case-insensitive lookup operation. It is useful to differentiate dentries this way to detect whether the negative dentry can be trusted during a case-insensitive lookup. Signed-off-by: Gabriel Krisman Bertazi --- fs/dcache.c | 8 ++++++++ include/linux/dcache.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/fs/dcache.c b/fs/dcache.c index 98521862e58a..05e4c7019e17 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1958,6 +1958,14 @@ void d_set_fallthru(struct dentry *dentry) } EXPORT_SYMBOL(d_set_fallthru); +void d_set_casefold_lookup(struct dentry *dentry) +{ + spin_lock(&dentry->d_lock); + dentry->d_flags |= DCACHE_CASEFOLD_LOOKUP; + spin_unlock(&dentry->d_lock); +} +EXPORT_SYMBOL(d_set_casefold_lookup); + static unsigned d_flags_for_inode(struct inode *inode) { unsigned add_flags = DCACHE_REGULAR_TYPE; diff --git a/include/linux/dcache.h b/include/linux/dcache.h index b6188f2e8950..457345123cb6 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -209,6 +209,7 @@ struct dentry_operations { #define DCACHE_FALLTHRU 0x01000000 /* Fall through to lower layer */ #define DCACHE_NOKEY_NAME 0x02000000 /* Encrypted name encoded without key */ #define DCACHE_OP_REAL 0x04000000 +#define DCACHE_CASEFOLD_LOOKUP 0x08000000 /* Dentry comes from a casefold directory */ #define DCACHE_PAR_LOOKUP 0x10000000 /* being looked up (with parent locked shared) */ #define DCACHE_DENTRY_CURSOR 0x20000000 @@ -497,6 +498,13 @@ static inline bool d_is_fallthru(const struct dentry *dentry) return dentry->d_flags & DCACHE_FALLTHRU; } +extern void d_set_casefold_lookup(struct dentry *dentry); + +static inline bool d_is_casefold_lookup(const struct dentry *dentry) +{ + return dentry->d_flags & DCACHE_CASEFOLD_LOOKUP; +} + extern int sysctl_vfs_cache_pressure;