Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2521894rwi; Fri, 28 Oct 2022 08:03:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66V4Fi+nzD3hzkVoKlqBVoCDnozTVljNsrhwPbZ/p9AAK3KLMG8AFtxkXUBMTXlkUJlGat X-Received: by 2002:aa7:9e1c:0:b0:56c:78fa:2a2 with SMTP id y28-20020aa79e1c000000b0056c78fa02a2mr12402004pfq.65.1666969407761; Fri, 28 Oct 2022 08:03:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666969407; cv=none; d=google.com; s=arc-20160816; b=iVSy1VNiUdyc7cUKphf7SuqXmzp6jmXZjypEjqOkR3bYRaU3YbZGpvMAUWa9bzppl4 lCxMgIMp+/gcT2NffhkzPtzRUxoFWEHKLrHrkJoy+JrhcD/gOCDpZ19vgnA1EKb/WCVr AeqNWPEISh0H8AuuLuE3O/KXOQLSRAScewUK7ctCLV0Ec67VV1LVHC1lopCZSUk2qjmT 6hO0o6ats600qDy0/Ow+eYxDQBA6uqXONKwJlHI+emvhBWqH8T17HEhmI5mNsV153bvR oHQk8AmkCMvzT3CoDpqUyyq4hD6y3nwcigqaMrWlSjKbF6nkpBSDLnJAOg1v4SBszGZA M1pg== 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=BkIQEEoahnrpH05lbl/u+JRprtiEVNkhlOAUjVXWbz4=; b=VhnyuHvPZekpy4VlwFjGyzfvof9HmCpQPsUB5P0Vs7Njnj7j8ymF6JzGcK9BK/5676 0Ooe868VIPTvBAjkrKm2Iw8cKwEG6Ub8/H/oUAMLB6IW23mQ3pYXYX98xcjQEOaaO9Dc yK01kb324i3dmnPGpkFG8qHc1gRuotDUMtYCVr04SCjCmNkb3AbrgRNFj0hO6OLeFCz/ LONzOzw6kkFfDoeE70BXZjaNOXgM14lSxQwhtwoxuh4h25wQvdJgQ5rusD9Gzj+ZR10l 9YBHZ+MXQTF0Aubo2le62UAjjbtDhdNjqKLwBpHbhh06wqbuOArbLrM5rZOn8+d6rtA8 oiiw== 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 d6-20020a170902cec600b00186be05c702si6183192plg.530.2022.10.28.08.03.13; Fri, 28 Oct 2022 08:03:27 -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 S231295AbiJ1OtL (ORCPT + 99 others); Fri, 28 Oct 2022 10:49:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231472AbiJ1Os7 (ORCPT ); Fri, 28 Oct 2022 10:48:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03F4E20272F for ; Fri, 28 Oct 2022 07:47: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 949CA628ED for ; Fri, 28 Oct 2022 14:47:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDF08C433D6; Fri, 28 Oct 2022 14:47:54 +0000 (UTC) Subject: [PATCH v7 13/14] NFSD: Allocate an rhashtable for nfs4_file objects From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: neilb@suse.de, jlayton@redhat.com Date: Fri, 28 Oct 2022 10:47:53 -0400 Message-ID: <166696847392.106044.9319954364556566370.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 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 Reviewed-by: NeilBrown --- fs/nfsd/nfs4state.c | 26 +++++++++++++++++++++++++- fs/nfsd/state.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 2b694d693be5..c2ef2db9c84c 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,21 @@ 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), + + /* + * Start with a single page hash table to reduce resizing churn + * on light workloads. + */ + .min_size = 256, + .automatic_shrinking = true, +}; + /* * Check if courtesy clients have conflicting access and resolve it if possible * @@ -8026,10 +8043,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; } @@ -8060,6 +8083,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;