Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7600233rwi; Mon, 24 Oct 2022 17:27:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5vGvef7BxlgaHqeLxWZQZKOy4d4roXwxGIw6/Z/YqO0paJ90MQPE/Wt5x8qtBGKXgfnGtM X-Received: by 2002:a17:907:971e:b0:78d:e7ed:7585 with SMTP id jg30-20020a170907971e00b0078de7ed7585mr28969579ejc.258.1666657636707; Mon, 24 Oct 2022 17:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666657636; cv=none; d=google.com; s=arc-20160816; b=aHzNDaqk8rUBvHv8Dmg+URtFvQyOZfApjyi5+TclIezng70Y9g+fnqqhJNXNyJiXu6 F8K5Qr9TpM4zPkKx2c/DlnOMvRBZ0xCAjaYPfRTNsjEc/91sjZTE2eHyb/0sl6ibD36e 3v1x5zhpHEEJSLkn8mFX2jgaA1FLPPgKJJ/5k2gi8jqPgr6avxsdgKwlIqnovG8ZUmkq EkP5m3tGT3D8JszzXk3I1M3XDANCjoHtZTEyDfgAZPdpdW5ZnoqoTGZe7lg7ky54p72Z Ztkghk2eV77TYC04bSUcy1KgkdzE4KAv9V7KuQ1MP/Yh1q+IxJRr8GSKu4WMjjSbSrtb vLfQ== 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=mHnNEWjGN64NjwZ3NR63TSD7c+wPOeBk074dKLTaI60=; b=dwR1uEoYQK+yHok0FaxUQpe6Z8PX7WIUZh4GDxVEis2MX6V0LLPvd+10Sw0TSKpMZx YcFKuTArN8QTVW2/8RaK1lQeXzDRAB381Zk8s067ePfKe8el7PHVtw5h+ANmHfdPKI3a 7aqp3b+rEoMfW+jB9oAJF3XueQibPyxqRNmTBVh12QIJAxysJrhchEUiYmQWLmNenMR2 mE11QYUFL7ss36wP8nlT2sBTKHbNC2ZvFX8wmr9A10dj8QaVZiWe1BT24sQUCCKOn1xE DHQVoWmnHaGxyda2Cqa6K8sEc+45hcIA9cram6XUy368ElhvAReAwMTXiEOz6YEgQKwg 4oaQ== 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 gs13-20020a1709072d0d00b007721f88d3e0si1230981ejc.554.2022.10.24.17.26.52; Mon, 24 Oct 2022 17:27:16 -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 S230225AbiJYASD (ORCPT + 99 others); Mon, 24 Oct 2022 20:18:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230381AbiJYARq (ORCPT ); Mon, 24 Oct 2022 20:17:46 -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 CB752248CF for ; Mon, 24 Oct 2022 15:37:51 -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 695A0615ED for ; Mon, 24 Oct 2022 22:37:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC9F2C433D6; Mon, 24 Oct 2022 22:37:50 +0000 (UTC) Subject: [PATCH v5 09/13] NFSD: Add a remove_nfs4_file() helper From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: neilb@suse.de Date: Mon, 24 Oct 2022 18:37:49 -0400 Message-ID: <166665106980.50761.4655586852736721135.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 Refactor to relocate hash deletion operation to a helper function that is close to most other nfs4_file data structure operations. The "noinline" annotation will become useful in a moment when the hlist_del_rcu() is replaced with a more complex rhash remove operation. It also guarantees that hash remove operations can be traced with "-p function -l remove_nfs4_file_locked". This also simplifies the organization of forward declarations: the to-be-added rhashtable and its param structure will be defined /after/ put_nfs4_file(). Signed-off-by: Chuck Lever --- fs/nfsd/nfs4state.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 644ff4310fa9..373b1d52fcd7 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -84,6 +84,7 @@ static bool check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner) static void nfs4_free_ol_stateid(struct nfs4_stid *stid); void nfsd4_end_grace(struct nfsd_net *nn); static void _free_cpntf_state_locked(struct nfsd_net *nn, struct nfs4_cpntf_state *cps); +static void remove_nfs4_file_locked(struct nfs4_file *fi); /* Locking: */ @@ -591,7 +592,7 @@ put_nfs4_file(struct nfs4_file *fi) might_lock(&state_lock); if (refcount_dec_and_lock(&fi->fi_ref, &state_lock)) { - hlist_del_rcu(&fi->fi_hash); + remove_nfs4_file_locked(fi); spin_unlock(&state_lock); WARN_ON_ONCE(!list_empty(&fi->fi_clnt_odstate)); WARN_ON_ONCE(!list_empty(&fi->fi_delegations)); @@ -4733,6 +4734,11 @@ find_or_add_file(struct nfs4_file *new, struct svc_fh *fh) return insert_file(new, fh, hashval); } +static noinline_for_stack void remove_nfs4_file_locked(struct nfs4_file *fi) +{ + hlist_del_rcu(&fi->fi_hash); +} + /* * Called to check deny when READ with all zero stateid or * WRITE with all zero or all one stateid