Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp850051ioo; Thu, 26 May 2022 16:57:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznVVj/Md5q8icomj910CJQnISspRq1qK8eIIs6mf3+MfGPZJ0gcy0uenDOODfi6laIUFxp X-Received: by 2002:a17:902:6b42:b0:15d:3603:6873 with SMTP id g2-20020a1709026b4200b0015d36036873mr40444216plt.30.1653609422732; Thu, 26 May 2022 16:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653609422; cv=none; d=google.com; s=arc-20160816; b=Ypgx/zrdfsKP//6c54Q34GFTFpkKfTbpF0D5FkmDbepcxjTujQMmRtGVCRrK2CKPv8 xDxCULL/WpgiHC7oxzandaFp/ZuCqBo1ua044xJI2ryE7wBHAIuWn0CY1pGGpnp63Dim xDeyPRCMNnBsYOES1mf97CnhcTe847uWzrIuQVJ4VRZH24NWyDAO/KSGIo2k9VEbW/pH D+GlB3aIOLPDrpwl/AbFbZbhW5fERczx8B2DQho8IQv6DxxOdnX+m2IqP+GN6GZ0BZiM puCVnena4RRwQXxYQSrVfqPl6rLXHkP/doYx+Ize96+9TUSUSZ/3n7iuBeLE8qkKW7uR 4S1Q== 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=BY0uwuvfpByIIEbA88X1ubdt91de5QP6Qq8gloHmh0c=; b=S2CCJTDYNqznkX2qBvrGENAPmeD7pr0ZcP8gV62NH718xvGcGAcgalEnLQ1sbNaRh5 zlvuPVmBBidN5aThatx/qGF1hC5dMn1X4WVxZmvml9g3EpsD/MVPqYmcI5AuJJrnrOB/ gtrn/j/l5nggXtU92b+X6CkctpWW2dzFBecIkwLEkcnaK0aux3OoR+kBmVUEgjJYgfHU nAt3KeoPsWcPLb+aOXEYMFpJaOqa/QNE/xwJjzFzam5yfzETnFdjmgU8FOpx0AEQlAh/ vLUGEO0rRyC2x17G31Sszl3ssvp0KeA4G0dR8WoeJGlbxeVXA/EQJxrvrfR5pOm8c+uA 7JTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Qf38dp/X"; 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 r5-20020a17090a454500b001df8f8d3daasi686779pjm.162.2022.05.26.16.56.51; Thu, 26 May 2022 16:57:02 -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="Qf38dp/X"; 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 S1345630AbiEZBRz (ORCPT + 99 others); Wed, 25 May 2022 21:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343986AbiEZBRs (ORCPT ); Wed, 25 May 2022 21:17:48 -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 D5D475799E for ; Wed, 25 May 2022 18:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653527867; 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=BY0uwuvfpByIIEbA88X1ubdt91de5QP6Qq8gloHmh0c=; b=Qf38dp/XqBo9d1R/w7Az8daw1ZtzJjeuzmGKnHhqu7PoP7GzeecIAa+qJsO8CNlYAUIlkz TLMDgQQJSywbCnMUFrgDTrAvSnNe3k05QtmrTNS8ccBDjQfJgKl/tRsIQD7qkVfkHsvcog 1R1ngyJBcXhE0xy60ItfXojam8qUJ7U= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-348-IXXakG4mN7mno6SV09tZgQ-1; Wed, 25 May 2022 21:17:43 -0400 X-MC-Unique: IXXakG4mN7mno6SV09tZgQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3B6C638041C6; Thu, 26 May 2022 01:17:43 +0000 (UTC) Received: from localhost (unknown [10.72.47.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 903A32166B26; Thu, 26 May 2022 01:17:42 +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 v6 1/2] fs/dcache: export d_same_name() helper Date: Thu, 26 May 2022 09:17:36 +0800 Message-Id: <20220526011737.371483-2-xiubli@redhat.com> In-Reply-To: <20220526011737.371483-1-xiubli@redhat.com> References: <20220526011737.371483-1-xiubli@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_FILL_THIS_FORM_SHORT,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Compare dentry name with case-exact name, return true if names are same, or false. Reviewed-by: Jeff Layton Signed-off-by: Xiubo Li --- fs/dcache.c | 15 +++++++++++---- include/linux/dcache.h | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 93f4f5ee07bf..a409312ee0df 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2247,10 +2247,16 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, } EXPORT_SYMBOL(d_add_ci); - -static inline bool d_same_name(const struct dentry *dentry, - const struct dentry *parent, - const struct qstr *name) +/** + * d_same_name - 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: true if names are same, or false + */ +bool d_same_name(const struct dentry *dentry, const struct dentry *parent, + const struct qstr *name) { if (likely(!(parent->d_flags & DCACHE_OP_COMPARE))) { if (dentry->d_name.len != name->len) @@ -2261,6 +2267,7 @@ static inline bool d_same_name(const struct dentry *dentry, dentry->d_name.len, dentry->d_name.name, name) == 0; } +EXPORT_SYMBOL_GPL(d_same_name); /** * __d_lookup_rcu - search for a dentry (racy, store-free) diff --git a/include/linux/dcache.h b/include/linux/dcache.h index f5bba51480b2..bb72361834de 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_same_name(const struct dentry *dentry, const struct dentry *parent, + 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