Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7600268rwi; Mon, 24 Oct 2022 17:27:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7/9owvImX6TMqExw7yWTGPVDtVH+XG6C6dyNOYKku8VsQQNw5fl5tw3S16esfQqy1pi+mj X-Received: by 2002:a17:907:320b:b0:780:280:7b72 with SMTP id xg11-20020a170907320b00b0078002807b72mr31037998ejb.146.1666657639307; Mon, 24 Oct 2022 17:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666657639; cv=none; d=google.com; s=arc-20160816; b=AyMcAZdq1szeXFwV5Q+sNasB3lUsf/xz45HOxzsNE8pWD3Avo5zAYAGFCSHND7RFDL V4ULOSdkFc2pVTUQO8n4zR5ZcOP32elNriYPH3vhbPtbuTPkB7fpLzjElbQc7j1IEnDQ NQzWtxJsjJByt4R0qEPQtWE+yGa0mcfVzydlpmQikBCTM54AvVbU+yn57XERW7jKNV+F rXz5s6M9PkXjImo+R4WUWwpZBtVKgYHdvFjIZy7qBVLdgK2ByKamAeJUzeWzEKnP+4ad RNoA6gEqm8093W5REi+POpDGfXyn516wPCJXuNc2TVr9tby5hIWPLKTQoDHr9L406fP2 KavA== 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=Ie+ZfMlrkEP90tCmITtAJFsr+YL/AyVLeyBclOxQ5lw=; b=MXdHVa3DaSUdQyVSMIlbmdetfLy9jGg240rtFinYR4rxl/6a9Q/4rHrEJcPM27N95T OpbYQycdxWe7sPqWN2REEpFiqh9n0nPNa3F4u11Zel+VHj8JEbyYJwKQ1Qm9XEM3mnEf ueUpYhEG7STYw2j4Gxu6d30bWCc68CHzkJlf9TftXNMmspvXDvb+bgm/8gBNX2wNudha JH49/XR0n7vBAXOtPHEyz9mbdQHij7XJoQ9pi62NJZpHSnDtGxrGiKI0C1RYYUQYCDFJ hJ0om+PUtO3hxc9MILaFthr7ZRnA8iOzVKNEnZHER4noIUxGrHy2cLd/2HOfDhmIryNF ZT3g== 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 e16-20020a056402089000b0046154f0f813si953670edy.271.2022.10.24.17.26.54; Mon, 24 Oct 2022 17:27:19 -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 S230446AbiJYASN (ORCPT + 99 others); Mon, 24 Oct 2022 20:18:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbiJYARw (ORCPT ); Mon, 24 Oct 2022 20:17:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07E34357DB for ; Mon, 24 Oct 2022 15:38:06 -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 ams.source.kernel.org (Postfix) with ESMTPS id ADEE4B816AD for ; Mon, 24 Oct 2022 22:38:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40E6EC433D7; Mon, 24 Oct 2022 22:38:03 +0000 (UTC) Subject: [PATCH v5 11/13] NFSD: Refactor find_file() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: neilb@suse.de Date: Mon, 24 Oct 2022 18:38:02 -0400 Message-ID: <166665108230.50761.12047289373435044414.stgit@klimt.1015granger.net> In-Reply-To: <166664935937.50761.7812494396457965637.stgit@klimt.1015granger.net> References: <166664935937.50761.7812494396457965637.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 --- fs/nfsd/nfs4state.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 529995a9e916..abed795bb4ec 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4666,31 +4666,23 @@ 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 = NULL; - 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)) + fi = NULL; + break; } } - 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 fi; } /* @@ -4741,9 +4733,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)