Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7600318rwi; Mon, 24 Oct 2022 17:27:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7sgYGujM2/uMN9crGeuaupaBcxRRI/7RIBnEujpUK2vukNBaROOmmKv4gNqmpGhQReUdom X-Received: by 2002:a05:6402:42c7:b0:461:c375:86b8 with SMTP id i7-20020a05640242c700b00461c37586b8mr7297191edc.40.1666657642569; Mon, 24 Oct 2022 17:27:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666657642; cv=none; d=google.com; s=arc-20160816; b=0MrAtL80krEfF/66lW3BKua6ju3GNmSQisDv2Qoj8voQV3pEJi6t3aCh/Ofm/Hhyu8 qOUw6s0dIkAV8HBzMBknA+K6r7CXY1sm4jpO/8h1IanbsC59VrWVLI1Xy3/2z/tn8YMQ eXvqdCdi664x0t/OdNYIcVWiZoMWyCXyJmflxLnvNZ+AMBVgMjxfBRay+rinLH6z5SaY dvXbu3/dPMo0lRTlgRMacfLPnMltdizC///abDRQoibVCM+PtCwLbv7g2ugBAlHQKKZh n+2wx3S1yYGFw0Kt3D3Un8cbDEgl9SudBltHvck2iM8SpXIN+cTbgehttSIyqtag+m/F O9fA== 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=mvJ9uUCHXV+S+GcLk6uLHnVJsCeUbPg8NIeWiK4nBiw=; b=0uaQR8oVv+M54KYUALctNrDGymLsj2I237PmQGhjJHdftzrD2/GXkQoHFUuxU2+9bt FYinCOUwZyrL127LThau+SZjv45WBqNg3Or2uPgYJXesl+kqx8ojfNitrqUhBRByg9yD oPThQmDkh3gXj4QaYv/5YPi2gmQag/LyVzU8ae89ImorkIeqQax4v6j0a/jme4WkqRsJ MpLCjA1HygPR4uO/aDrfuugO2tmg112WFAfsk4C5P4i6gKpCFg399tmuhaJCYysBmj0K vigd9epkPCW0Uu+RLDf7vfn/t+ojJG5Yl7I/VKRNha5t0VgWOpW1L0DYjiz/Uas5nPnS Bcgg== 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 dd21-20020a1709069b9500b00781a32fd847si1257724ejc.917.2022.10.24.17.26.55; Mon, 24 Oct 2022 17:27:22 -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 S231140AbiJYASU (ORCPT + 99 others); Mon, 24 Oct 2022 20:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231193AbiJYARx (ORCPT ); Mon, 24 Oct 2022 20:17:53 -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 A3682E8C4B for ; Mon, 24 Oct 2022 15:38:10 -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 2B4FF615F0 for ; Mon, 24 Oct 2022 22:38:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F145C433D7; Mon, 24 Oct 2022 22:38:09 +0000 (UTC) Subject: [PATCH v5 12/13] NFSD: Allocate an rhashtable for nfs4_file objects From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: neilb@suse.de Date: Mon, 24 Oct 2022 18:38:08 -0400 Message-ID: <166665108857.50761.11874625810370383309.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 Introduce the infrastructure for managing nfs4_file objects in an rhashtable. This infrastructure will be used by the next patch. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4state.c | 23 ++++++++++++++++++++++- fs/nfsd/state.h | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index abed795bb4ec..681cb2daa843 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -44,7 +44,9 @@ #include #include #include +#include #include + #include "xdr4.h" #include "xdr4cb.h" #include "vfs.h" @@ -721,6 +723,18 @@ static unsigned int file_hashval(const struct svc_fh *fh) static struct hlist_head file_hashtbl[FILE_HASH_SIZE]; +static struct rhltable nfs4_file_rhltable ____cacheline_aligned_in_smp; + +static const struct rhashtable_params nfs4_file_rhash_params = { + .key_len = sizeof_field(struct nfs4_file, fi_inode), + .key_offset = offsetof(struct nfs4_file, fi_inode), + .head_offset = offsetof(struct nfs4_file, fi_rlist), + + /* Reduce resizing churn on light workloads */ + .min_size = 256, /* buckets */ + .automatic_shrinking = true, +}; + /* * Check if courtesy clients have conflicting access and resolve it if possible * @@ -8023,10 +8037,16 @@ nfs4_state_start(void) { int ret; - ret = nfsd4_create_callback_queue(); + ret = rhltable_init(&nfs4_file_rhltable, &nfs4_file_rhash_params); if (ret) return ret; + ret = nfsd4_create_callback_queue(); + if (ret) { + rhltable_destroy(&nfs4_file_rhltable); + return ret; + } + set_max_delegations(); return 0; } @@ -8057,6 +8077,7 @@ nfs4_state_shutdown_net(struct net *net) nfsd4_client_tracking_exit(net); nfs4_state_destroy_net(net); + rhltable_destroy(&nfs4_file_rhltable); #ifdef CONFIG_NFSD_V4_2_INTER_SSC nfsd4_ssc_shutdown_umount(nn); #endif diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index e2daef3cc003..190fc7e418a4 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -546,6 +546,7 @@ struct nfs4_file { bool fi_aliased; spinlock_t fi_lock; struct hlist_node fi_hash; /* hash on fi_fhandle */ + struct rhlist_head fi_rlist; struct list_head fi_stateids; union { struct list_head fi_delegations;