Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3291109iob; Mon, 16 May 2022 18:19:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD4ReQ5lpCj7eKXeu01c5i5CbLMN4p8tSSZJLI1t/nMi0scKDRVAvJbfUZi0niKbqeAVDe X-Received: by 2002:a17:907:d29:b0:6f4:87d4:ecad with SMTP id gn41-20020a1709070d2900b006f487d4ecadmr16936164ejc.166.1652750396385; Mon, 16 May 2022 18:19:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652750396; cv=none; d=google.com; s=arc-20160816; b=bzdQbNeefth4BYNLw/xW26eohmOL8h4db9mwbwP01GFjASLw1/9/1uHryVvfyeyUT8 opDX5PNiF+Q3e6sNBYUfv13wkYrS4WtE1k0h/4xxK9ZvCXuCKlbW1QAleVxENChFYzKl qXg++T2v47ugts9dfyXL3TfePiUQma+8DBNghUR8gNVkBgrjSonLJxtivcvZ5hWGL6i1 VvmhXuK6iH1URuS0DjRtb/bIdgpfO04k/ZmgqidxTzEN6j2c46YX2oQeyXB0T5kA1U1E 9w6XMbkz/7fHGYvK+SuVSVNy2b6ETc07biFxlbnkZpexmWLlyzWwiYULT/VoJf+aK4J+ Dg3w== 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=DIRyBjAdTpqgw14kErtwE29u9jq0/z5o4ktEpXWwZGE=; b=q1FZ7MnN/sbPnOrZ/2Y7OlOiRuLzjC6PUOti2wAbYzj9jsZ+dKgnkKwNO6qRQpC8jY gKCSxg9WC1rV+/CdYObg5SdJ13s4nlyBxM1j2jSEux9t5cyx6ZI7O/A5Bs1yg45yxGcr woS3UyBBjhl1qJVZrxaqnDZ6RYEhZbSOg+TFP/EmGA8JLGIKS8r3n/81B41V9SzHZpRL MqqK26vsYaec0Iy0KJjJvk++dOoxSQIvdh8Fk6WYOR/+un4aQovb7iigCI66z/Bll+7r IrtSBRdK31OpfWEdsue2pWNpBQp3NyQuBY88zdupE4URe+iAPkd2JzzbJeDWC6XeVxgE EjeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SLp6pXLx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc13-20020a1709078a0d00b006f398daeb92si1132907ejc.5.2022.05.16.18.19.31; Mon, 16 May 2022 18:19:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@redhat.com header.s=mimecast20190719 header.b=SLp6pXLx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234148AbiEPMVW (ORCPT + 99 others); Mon, 16 May 2022 08:21:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243356AbiEPMVQ (ORCPT ); Mon, 16 May 2022 08:21:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 552272BC5 for ; Mon, 16 May 2022 05:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652703674; h=from:from:reply-to:subject:subject: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=DIRyBjAdTpqgw14kErtwE29u9jq0/z5o4ktEpXWwZGE=; b=SLp6pXLx/zIqyEo4cWP4D/dyA93YL44V+rNutcXN02TRFgA2qkmY56LRvXgsLqqRrRWlCw NQI0IYVbHoKAo2bMKZ3FAm4GX79k+lFIyY8iNauQCyZw8JWPzVtVxWmGoeRCBcQEGMf8Xm fiuoPnc9T2XiCArBf1OyTPGIcVLlNQU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-427-bnVbQ3h8OfS8enSatJ__rw-1; Mon, 16 May 2022 08:21:09 -0400 X-MC-Unique: bnVbQ3h8OfS8enSatJ__rw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76A0291C7EB; Mon, 16 May 2022 12:20:58 +0000 (UTC) Received: from localhost (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0215400DE5E; Mon, 16 May 2022 12:20:57 +0000 (UTC) From: Xiubo Li To: jlayton@kernel.org, viro@zeniv.linux.org.uk Cc: idryomov@gmail.com, vshankar@redhat.com, ceph-devel@vger.kernel.org, mcgrof@kernel.org, akpm@linux-foundation.org, arnd@arndb.de, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Xiubo Li Subject: [PATCH 1/2] fs/dcache: add d_compare() helper support Date: Mon, 16 May 2022 20:20:45 +0800 Message-Id: <20220516122046.40655-2-xiubli@redhat.com> In-Reply-To: <20220516122046.40655-1-xiubli@redhat.com> References: <20220516122046.40655-1-xiubli@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,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-kernel@vger.kernel.org Signed-off-by: Xiubo Li --- fs/dcache.c | 15 +++++++++++++++ include/linux/dcache.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/fs/dcache.c b/fs/dcache.c index 93f4f5ee07bf..95a72f92a94b 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2262,6 +2262,21 @@ static inline bool d_same_name(const struct dentry *dentry, name) == 0; } +/** + * d_compare - compare dentry name with case-exact name + * @parent: parent dentry + * @dentry: the negative dentry that was passed to the parent's lookup func + * @name: the case-exact name to be associated with the returned dentry + * + * Return: 0 if names are same, or 1 + */ +bool d_compare(const struct dentry *parent, const struct dentry *dentry, + const struct qstr *name) +{ + return !d_same_name(dentry, parent, name); +} +EXPORT_SYMBOL(d_compare); + /** * __d_lookup_rcu - search for a dentry (racy, store-free) * @parent: parent dentry diff --git a/include/linux/dcache.h b/include/linux/dcache.h index f5bba51480b2..444b2230e5c3 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -233,6 +233,8 @@ extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr *, wait_queue_head_t *); extern struct dentry * d_splice_alias(struct inode *, struct dentry *); extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *); +extern bool d_compare(const struct dentry *parent, const struct dentry *dentry, + const struct qstr *name); extern struct dentry * d_exact_alias(struct dentry *, struct inode *); extern struct dentry *d_find_any_alias(struct inode *inode); extern struct dentry * d_obtain_alias(struct inode *); -- 2.36.0.rc1