Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp549545iob; Wed, 18 May 2022 07:51:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrjbAtpV7a9/bbiG4EH6AcDC2mv/zWRgVAwWqGLlSFswWUJcsPw8pan47eBO6yHg5+8wXe X-Received: by 2002:a17:902:8602:b0:161:b911:8ba8 with SMTP id f2-20020a170902860200b00161b9118ba8mr105205plo.38.1652885463829; Wed, 18 May 2022 07:51:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652885463; cv=none; d=google.com; s=arc-20160816; b=RH+em34oxJMXNnuI2ZlEs//H8XoJRlajxsf1UrxAMOTGYVJivwTo6lCko2F8fEfjMy sgkGn9b+nApzZxv66kMIWpoANmOWGRjiBykglSR0gf1ZLk8H0rOE7glPhcuwQ2oorxDo Uyvdq5aMbUxCbOVUZX0389DN6J0mAinCxMxYTegTE/wpjB0wYXt7rSVsiYDM2p7/rKWv 2vdIq8ewUb92byRdCiCqPSlQxImuE65WUx+fguyfinsfKNGvR+r/rfcd8OF52LBR03lA 0aQ60mGQKW5bshoFfb7cDmvBe01rfjDBm+oxPoDVYq8YYuDZhbwrAxm6HQ0x/xKuy4BF Dlew== 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=sr0Su8VmpTGq2+kXIOmhRI/79j0nmk1mBS04kJYAJN4=; b=osp2Wx4SKT8TJJgD+N9mwVu/8fdxIF0bqhAAiiJ6t9+kNIK7poMiF2YFRDUyzpkksF JB2k1UJdVcn9MpL//SWqE5V9riIUvOTedyLi5G6kJIFD8qErYMAvtPnKYiKYk/mTotJ2 ud+EPXUjG872BuFGR7pQmLSztQLeLxwL60mD/H0PPs0eqf5EP7Hls4Tz0xUwJekLR4RU GeyOVW7Cg3AXAhYg9vOOOz9WJbwqZGOJ2WcwtbmkVCkubdtrLf55orsx8vbqZrcm5LxB irXgCUMolYy8O74a8e/E9Eb11T5YK+XP4pjYeQ7TbEwcO9tND2WcMzHwBl4d6zeEoadk r7hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iLDhCiXL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z27-20020a634c1b000000b003c6dde2affbsi2827131pga.126.2022.05.18.07.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 07:51:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iLDhCiXL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 29A49633AA; Wed, 18 May 2022 07:46:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238932AbiEROqV (ORCPT + 99 others); Wed, 18 May 2022 10:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238877AbiEROqJ (ORCPT ); Wed, 18 May 2022 10:46:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5FBA03DA6E for ; Wed, 18 May 2022 07:46:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652885167; 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=sr0Su8VmpTGq2+kXIOmhRI/79j0nmk1mBS04kJYAJN4=; b=iLDhCiXLsUW1UMj2KhTiyZ1yIK4XQKADtNkgzVjfS41ns7XgtJeMaJ+vXcRtZ1dME0X8IA Q0nwMtrCCOxAvbDN2wDkoDKaFWfbwUanq0EL/lWAAtqbxwV2OEzkUeRcFeYHr8OvVTGW5v aZlQ1MLLN8xRELkiPz8orFbg4O248Rc= 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-528-b2lhbogwOO-ybMHWfCZ-Rg-1; Wed, 18 May 2022 10:46:04 -0400 X-MC-Unique: b2lhbogwOO-ybMHWfCZ-Rg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E093B86B8B2; Wed, 18 May 2022 14:46:03 +0000 (UTC) Received: from localhost (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F39640C1244; Wed, 18 May 2022 14:46:02 +0000 (UTC) From: Xiubo Li To: jlayton@kernel.org, idryomov@gmail.com, viro@zeniv.linux.org.uk Cc: willy@infradead.org, vshankar@redhat.com, ceph-devel@vger.kernel.org, arnd@arndb.de, mcgrof@kernel.org, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Xiubo Li Subject: [PATCH v4 1/2] fs/dcache: add d_compare() helper support Date: Wed, 18 May 2022 22:45:44 +0800 Message-Id: <20220518144545.246604-2-xiubli@redhat.com> In-Reply-To: <20220518144545.246604-1-xiubli@redhat.com> References: <20220518144545.246604-1-xiubli@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Reviewed-by: Jeff Layton 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