Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1152887rwi; Thu, 27 Oct 2022 11:55:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM470TsbEL2VfGGOiWAA/y9UHZosh6JZEm014UounegE/HBP8909hgM2xiAYZK8gbiFg1aQi X-Received: by 2002:a05:6a00:21c5:b0:56c:3ebf:2154 with SMTP id t5-20020a056a0021c500b0056c3ebf2154mr12500105pfj.63.1666896907249; Thu, 27 Oct 2022 11:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666896907; cv=none; d=google.com; s=arc-20160816; b=J1whrV/qgs9eYDOMCyRE8pAeNizXoWIPq2FLrLI+aC5WeN4yb3SbnLcYrbizdPNXyI teg0Kf8mlmgEtNVrOzhid3udXnP8zDXP1Rz91qBCWEh7S90x9MvRhLi+LlYRBrs3Uel3 58zUxFDhLR5GqZiP4AjAaw7JoelRXjeeitvWtWBLSB1Wf+oKgB+NTy44mNl7kKVcEivT w0bbaN7Yjn2bMpYjAqiZmHDgjKuNA3c4xKmD7+iHh/6OzdFcyfW34SiCaJu6iWwRw5PS QBAIY1YxcSpwQcrXgUNU+0/dEsVN2wCO+HdCE3aQ9NwB6Yvokn4luarD/fqlUgB4AFTX zXow== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject; bh=xHj3vvgmprZMmuq4sE7OqR5zxzxgA/6KDoJyRISZEh8=; b=nS3BMoLGCSdN0LWXTfGU4jtnHDLLVPxd4pHsQ9vZG3dWP+Z33GhS6G/B4EMFQm57/r 8kTmte6gGIZVAWG/tEl6sxRoticSXXERL1rYV3mZWSo0k0N1OjvcJD2YLX82AIlYpUQ9 WOfZACg4Mk+5cKi8NqA2dYhz703NArBH/o1b3OqYTp5WlDy7v96YxChUEwky+L/P5BUf yqIDcfVmJ3gkc03ciH32wY104CbhEoyXsJhlzrQZtLqWN4QTKfWRGQ8HM51mPZWw/NXg ILFSQhxb0qAARGwwdV9j1KxyV/2PcrG9CRhaVUHzCtVo4zZ7yEmVjj5bC3x9GctrhRgP lSiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x127-20020a633185000000b0046408c6d349si2538435pgx.478.2022.10.27.11.54.54; Thu, 27 Oct 2022 11:55:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233569AbiJ0Sw6 (ORCPT + 99 others); Thu, 27 Oct 2022 14:52:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235600AbiJ0Sw5 (ORCPT ); Thu, 27 Oct 2022 14:52:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 555475C9C0 for ; Thu, 27 Oct 2022 11:52:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CF1E56243B for ; Thu, 27 Oct 2022 18:52:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15C9AC433D6; Thu, 27 Oct 2022 18:52:55 +0000 (UTC) Subject: [PATCH v6 12/14] NFSD: Refactor find_file() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: neilb@suse.de, jlayton@redhat.com Date: Thu, 27 Oct 2022 14:52:54 -0400 Message-ID: <166689677417.90991.7714073021229314413.stgit@klimt.1015granger.net> In-Reply-To: <166689625728.90991.15067635142973595248.stgit@klimt.1015granger.net> References: <166689625728.90991.15067635142973595248.stgit@klimt.1015granger.net> User-Agent: StGit/1.5.dev3+g9561319 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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-nfs@vger.kernel.org find_file() is now the only caller of find_file_locked(), so just fold these two together. Name nfs4_file-related helpers consistently. There are already nfs4_file_yada functions, so let's go with the same convention used by put_nfs4_file(): find_nfs4_file(). Signed-off-by: Chuck Lever Reviewed-by: NeilBrown --- fs/nfsd/nfs4state.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 198ed86f873a..a07fbbe289cf 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4666,31 +4666,24 @@ move_to_close_lru(struct nfs4_ol_stateid *s, struct net *net) nfs4_put_stid(&last->st_stid); } -/* search file_hashtbl[] for file */ -static struct nfs4_file * -find_file_locked(const struct svc_fh *fh, unsigned int hashval) +static noinline_for_stack struct nfs4_file * +find_nfs4_file(const struct svc_fh *fhp) { - struct nfs4_file *fp; + unsigned int hashval = file_hashval(fhp); + struct nfs4_file *fi; - hlist_for_each_entry_rcu(fp, &file_hashtbl[hashval], fi_hash, - lockdep_is_held(&state_lock)) { - if (fh_match(&fp->fi_fhandle, &fh->fh_handle)) { - if (refcount_inc_not_zero(&fp->fi_ref)) - return fp; + rcu_read_lock(); + hlist_for_each_entry_rcu(fi, &file_hashtbl[hashval], fi_hash, + lockdep_is_held(&state_lock)) { + if (fh_match(&fi->fi_fhandle, &fhp->fh_handle)) { + if (refcount_inc_not_zero(&fi->fi_ref)) { + rcu_read_unlock(); + return fi; + } } } - return NULL; -} - -static struct nfs4_file * find_file(struct svc_fh *fh) -{ - struct nfs4_file *fp; - unsigned int hashval = file_hashval(fh); - - rcu_read_lock(); - fp = find_file_locked(fh, hashval); rcu_read_unlock(); - return fp; + return NULL; } /* @@ -4741,9 +4734,10 @@ nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type) struct nfs4_file *fp; __be32 ret = nfs_ok; - fp = find_file(current_fh); + fp = find_nfs4_file(current_fh); if (!fp) return ret; + /* Check for conflicting share reservations */ spin_lock(&fp->fi_lock); if (fp->fi_share_deny & deny_type)