Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp8118308rwn; Wed, 14 Sep 2022 09:10:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR71Mo752e0WxABpxDNEiG3G3Hz/H/gLayWH/BYZYIq9Ggb14bHP8xbeCWo7Ykrm0OAV+a8j X-Received: by 2002:a05:6402:5507:b0:452:183f:16d1 with SMTP id fi7-20020a056402550700b00452183f16d1mr10818051edb.96.1663171849402; Wed, 14 Sep 2022 09:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663171849; cv=none; d=google.com; s=arc-20160816; b=gcyma+I94SP3Dd0xE5leSgjZCBntayfFQ2bt259jOQZcGhulpykE66Ri7XjfQegZ62 wsye8re8L0/ZMnY9SLD3dcIe0HpRduQKihGbPeh5/ILa+VZIdF4dAJdSPKO3ePj9Mbs3 Oj4EkipfIwAtx5wCjaQugbFo/h4oMdfjAfIva9esT8lDKYYkr5FuAeKCWm+rKIJIW+8W /J/x9Og+3rDnLAo5r/pT3aTL3+ZPX15vryKYXY9KzvS01Yh5dxH0/tg0kK11+2YZ/c9h Rpft1sMc0Heu+Htpq3SOX+nskf9fNIqT8ZOYm29Tj1Uls6ycD4zU8yE40siURgGKfqGe djgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=dDUIV++FOlZw1FyU7tZpkjCVLJFUnwGdPEj9nHJkAPo=; b=qjMscO/hw22ZWLp2Lhdh5XEfvnm5LN27kDoCe7hMewLS1Ek8kyEqXaQtPT5jpF8deI P4BpiA2DB2q+GfE9v2+aW7OnFC2lPf1a/5NpeV6UqRrS1areZgGIdLoYIzyhQN+TtaX9 SyzwhDzd0hXPm9ggkNwCdiGJXNfP2f93GcTDod6xqM9cyNheGEB2eLF/AUiLLQugMq0/ euRTotP3CpgYuK7PAJQqjd2zEZiV+l0S7bUEf54tFs5DCTxcpRLKe6FuUpKjNWkA/lnh tirCB6bI7UZOZ6Xg78c508qmlVpERUzQWcwh0KUM8U8sV9P/59VOMLqAN1YFPw/7yscQ 2VQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=ABiHxNnj; 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=pass (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 i22-20020a05640242d600b00450bda7e40esi16334692edc.19.2022.09.14.09.10.19; Wed, 14 Sep 2022 09:10:49 -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; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=ABiHxNnj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbiINPyn (ORCPT + 99 others); Wed, 14 Sep 2022 11:54:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230240AbiINPyl (ORCPT ); Wed, 14 Sep 2022 11:54:41 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CDDD6474 for ; Wed, 14 Sep 2022 08:54:37 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28EFkNnp006721; Wed, 14 Sep 2022 15:54:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2022-7-12; bh=dDUIV++FOlZw1FyU7tZpkjCVLJFUnwGdPEj9nHJkAPo=; b=ABiHxNnjytJ5zW0Ti9bGj1DlqlFZt5lqQwa60EKY9XtIgvle+gat7z8sW8660mJBt9yX D/WtVXL6O6jI0Ehf5jF0dW49OZ6W+BOH6WOteb3vemTLqRpzwR0JVsD3dy236rdySp3E euTU/f1U75g/7rB0ezjJ+H8Udxps1mjdcMwZoXHzL413tDrK6t9zQYgnuWpcIQ1zcUQz BMpdP7uHZwCf7qq9BChIPNB7Do99lawEJa73nRyCI3qv90ETIvNuBIFziKCZ/v/ynzxz HA8Nk1lAiEE5yppbdhkx9Yu+xUWu7+eI7g/uFelhpa9O5uMmrsxnLwr9ysm4D5dgdzpv zA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3jjxyr2sp0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Sep 2022 15:54:34 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 28EDZbln035456; Wed, 14 Sep 2022 15:54:33 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3jjykyt0y0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Sep 2022 15:54:33 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 28EFp3ZG025970; Wed, 14 Sep 2022 15:54:33 GMT Received: from ca-common-hq.us.oracle.com (ca-common-hq.us.oracle.com [10.211.9.209]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3jjykyt0xj-2; Wed, 14 Sep 2022 15:54:33 +0000 From: Dai Ngo To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH v7 1/2] NFSD: keep track of the number of courtesy clients in the system Date: Wed, 14 Sep 2022 08:54:25 -0700 Message-Id: <1663170866-21524-2-git-send-email-dai.ngo@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1663170866-21524-1-git-send-email-dai.ngo@oracle.com> References: <1663170866-21524-1-git-send-email-dai.ngo@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-14_07,2022-09-14_04,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2208220000 definitions=main-2209140077 X-Proofpoint-GUID: 5F7dVH_lgu2iw7JtSzrVD41Mk6TAQKfP X-Proofpoint-ORIG-GUID: 5F7dVH_lgu2iw7JtSzrVD41Mk6TAQKfP X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Add counter nfs4_courtesy_client_count to nfsd_net to keep track of the number of courtesy clients in the system. Signed-off-by: Dai Ngo --- fs/nfsd/netns.h | 2 ++ fs/nfsd/nfs4state.c | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index ffe17743cc74..55c7006d6109 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h @@ -192,6 +192,8 @@ struct nfsd_net { atomic_t nfs4_client_count; int nfs4_max_clients; + + atomic_t nfsd_courtesy_clients; }; /* Simple check to find out if a given net was properly initialized */ diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c5d199d7e6b4..2827329704ea 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -160,6 +160,13 @@ static bool is_client_expired(struct nfs4_client *clp) return clp->cl_time == 0; } +static void nfsd4_dec_courtesy_client_count(struct nfsd_net *nn, + struct nfs4_client *clp) +{ + if (clp->cl_state != NFSD4_ACTIVE) + atomic_add_unless(&nn->nfsd_courtesy_clients, -1, 0); +} + static __be32 get_client_locked(struct nfs4_client *clp) { struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); @@ -169,6 +176,7 @@ static __be32 get_client_locked(struct nfs4_client *clp) if (is_client_expired(clp)) return nfserr_expired; atomic_inc(&clp->cl_rpc_users); + nfsd4_dec_courtesy_client_count(nn, clp); clp->cl_state = NFSD4_ACTIVE; return nfs_ok; } @@ -190,6 +198,7 @@ renew_client_locked(struct nfs4_client *clp) list_move_tail(&clp->cl_lru, &nn->client_lru); clp->cl_time = ktime_get_boottime_seconds(); + nfsd4_dec_courtesy_client_count(nn, clp); clp->cl_state = NFSD4_ACTIVE; } @@ -2233,6 +2242,7 @@ __destroy_client(struct nfs4_client *clp) if (clp->cl_cb_conn.cb_xprt) svc_xprt_put(clp->cl_cb_conn.cb_xprt); atomic_add_unless(&nn->nfs4_client_count, -1, 0); + nfsd4_dec_courtesy_client_count(nn, clp); free_client(clp); wake_up_all(&expiry_wq); } @@ -4356,6 +4366,8 @@ void nfsd4_init_leases_net(struct nfsd_net *nn) max_clients = (u64)si.totalram * si.mem_unit / (1024 * 1024 * 1024); max_clients *= NFS4_CLIENTS_PER_GB; nn->nfs4_max_clients = max_t(int, max_clients, NFS4_CLIENTS_PER_GB); + + atomic_set(&nn->nfsd_courtesy_clients, 0); } static void init_nfs4_replay(struct nfs4_replay *rp) @@ -5878,8 +5890,11 @@ nfs4_get_client_reaplist(struct nfsd_net *nn, struct list_head *reaplist, goto exp_client; if (!state_expired(lt, clp->cl_time)) break; - if (!atomic_read(&clp->cl_rpc_users)) + if (!atomic_read(&clp->cl_rpc_users)) { + if (clp->cl_state == NFSD4_ACTIVE) + atomic_inc(&nn->nfsd_courtesy_clients); clp->cl_state = NFSD4_COURTESY; + } if (!client_has_state(clp)) goto exp_client; if (!nfs4_anylock_blockers(clp)) -- 2.9.5