From patchwork Tue May 17 01:03:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 575453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF038C4332F for ; Tue, 17 May 2022 01:03:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242266AbiEQBDv (ORCPT ); Mon, 16 May 2022 21:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243459AbiEQBDe (ORCPT ); Mon, 16 May 2022 21:03:34 -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 0CA1D47062 for ; Mon, 16 May 2022 18:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652749411; 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=bIRgrzoJIi9CK7XHU8nK5c2cMia02GaE+IPetmOvb1jSLK2nfOcmlv+xuHHo4OQNoozLGQ Dsu2aReTkl1CGtXyeqPBoNBeiAhbk7EY3NHzcs62VXZn36s+vx5YAJMJJ0kHG3P53gwubq viEn+xcYZo5GD0luIAEDEMtfbwDDKD8= 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-91-KnC_sT4AMFiEFxMcx4vgGw-1; Mon, 16 May 2022 21:03:24 -0400 X-MC-Unique: KnC_sT4AMFiEFxMcx4vgGw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2719B80A0B9; Tue, 17 May 2022 01:03:24 +0000 (UTC) Received: from localhost (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C7FD7774; Tue, 17 May 2022 01:03:23 +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, arnd@arndb.de, mcgrof@kernel.org, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Xiubo Li Subject: [PATCH v2 1/2] fs/dcache: add d_compare() helper support Date: Tue, 17 May 2022 09:03:15 +0800 Message-Id: <20220517010316.81483-2-xiubli@redhat.com> In-Reply-To: <20220517010316.81483-1-xiubli@redhat.com> References: <20220517010316.81483-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@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 *);