Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2528256rwi; Fri, 28 Oct 2022 08:06:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM70/FSZ8ybzWEC+E4Z0pXHINOekzbtsbfysR+AxY9P1ufai8R4aoGGk7q9JKfHu/zAtrQ5G X-Received: by 2002:a63:234b:0:b0:46b:208f:1e72 with SMTP id u11-20020a63234b000000b0046b208f1e72mr45613748pgm.581.1666969595368; Fri, 28 Oct 2022 08:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666969595; cv=none; d=google.com; s=arc-20160816; b=l2zzmDRhKVKcu5qbdBfDZ7LDxSgvkdMNE6ymC8kJU+b82M5r5ujubh4/bsCuLlmPLo UueDt15mKgS0i9QqGhIEH9XocKYOYfd2jfwNPvpBsm5DQ0PFd8CAI94Vd7qD76GdyNki M+VTaztOLsvJed/weiEfd+rR3seHKxjy9hjXMyeEZwcG7dwb0qnae0vdD66ww8WGHqTW cyKd/aylFjfmZLX6N/eaH3hgbaBFBCL0cS8ZPKRCevRNVTDyuFqWULstFV6U0NasPPIQ vHwJsAc8MpzzO6Z5+dfH68X32yzO6gEKUws1ibGtbm9o8ZNnce6mX/Gm1jJy3DS2n14K T/6w== 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=sUOXgTwMuMizs4Z8xw/HsXeDwLE301Zo7sXognWjUKI=; b=laoQxNu4r3WR4MbzyqbagBqP2f6E6lWa+Es2D1i8ypscbA5U1ozs6GrwAeA8iU9zOc EXJ8k4laGK1lmvJz8OlG7v0ssSZzM7lpYpszw3XuBR8wAICt6FXiE5nqC6uuz713z+i9 CeeMNed1Q4bNDi7ItsS0iMXnXHw+8eX3xioM9oEg+qRPyj1hi2+K+fdOrcIMZwOriD6U hbXQX6NVkwIVA5FY3vchOXWdk5vWrMsx5tzFShS1M7MiZdeP9+Jr13SudcKperUQryeC YsSFQT+pWy+Z5CsmDiOx08aJtT9TN0oDTx44+Vg+WdTqpyVbbthkxMF8QiHB26Oj6kAQ UB3A== 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 h1-20020a170902f54100b00186be035c64si6403438plf.416.2022.10.28.08.06.15; Fri, 28 Oct 2022 08:06:35 -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 S229730AbiJ1OtI (ORCPT + 99 others); Fri, 28 Oct 2022 10:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231310AbiJ1Osb (ORCPT ); Fri, 28 Oct 2022 10:48:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 564231F8103 for ; Fri, 28 Oct 2022 07:47:32 -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 14364B82AA2 for ; Fri, 28 Oct 2022 14:47:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BCE0C433D6; Fri, 28 Oct 2022 14:47:29 +0000 (UTC) Subject: [PATCH v7 09/14] NFSD: Clean up nfsd4_init_file() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: neilb@suse.de, jlayton@redhat.com Date: Fri, 28 Oct 2022 10:47:28 -0400 Message-ID: <166696844871.106044.39412279713347759.stgit@klimt.1015granger.net> In-Reply-To: <166696812922.106044.679812521105874329.stgit@klimt.1015granger.net> References: <166696812922.106044.679812521105874329.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 Name this function more consistently. I'm going to use nfsd4_file_ and nfsd4_file_hash_ for these helpers. Change the @fh parameter to be const pointer for better type safety. Finally, move the hash insertion operation to the caller. This is typical for most other "init_object" type helpers, and it is where most of the other nfs4_file hash table operations are located. Signed-off-by: Chuck Lever Reviewed-by: NeilBrown --- fs/nfsd/nfs4state.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 60f1aa2c5442..3132e4844ef8 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4262,11 +4262,9 @@ static struct nfs4_file *nfsd4_alloc_file(void) } /* OPEN Share state helper functions */ -static void nfsd4_init_file(struct svc_fh *fh, unsigned int hashval, - struct nfs4_file *fp) -{ - lockdep_assert_held(&state_lock); +static void nfsd4_file_init(const struct svc_fh *fh, struct nfs4_file *fp) +{ refcount_set(&fp->fi_ref, 1); spin_lock_init(&fp->fi_lock); INIT_LIST_HEAD(&fp->fi_stateids); @@ -4284,7 +4282,6 @@ static void nfsd4_init_file(struct svc_fh *fh, unsigned int hashval, INIT_LIST_HEAD(&fp->fi_lo_states); atomic_set(&fp->fi_lo_recalls, 0); #endif - hlist_add_head_rcu(&fp->fi_hash, &file_hashtbl[hashval]); } void @@ -4702,7 +4699,8 @@ static struct nfs4_file *insert_file(struct nfs4_file *new, struct svc_fh *fh, fp->fi_aliased = alias_found = true; } if (likely(ret == NULL)) { - nfsd4_init_file(fh, hashval, new); + nfsd4_file_init(fh, new); + hlist_add_head_rcu(&new->fi_hash, &file_hashtbl[hashval]); new->fi_aliased = alias_found; ret = new; }