From: Chuck Lever III <chuck.lever@oracle.com>
To: Dai Ngo <dai.ngo@oracle.com>
Cc: "jlayton@kernel.org" <jlayton@kernel.org>,
Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH v4 1/2] NFSD: keep track of the number of courtesy clients in the system
Date: Wed, 31 Aug 2022 14:30:39 +0000 [thread overview]
Message-ID: <B4F7A73D-3306-4D9F-9DF2-A964F95EEAFD@oracle.com> (raw)
In-Reply-To: <1661896113-8013-2-git-send-email-dai.ngo@oracle.com>
> On Aug 30, 2022, at 5:48 PM, Dai Ngo <dai.ngo@oracle.com> wrote:
>
> 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 <dai.ngo@oracle.com>
> ---
> fs/nfsd/netns.h | 2 ++
> fs/nfsd/nfs4state.c | 13 ++++++++++++-
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h
> index ffe17743cc74..2695dff1378a 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_client_count;
See comment for 2/2: rename this variable?
> };
>
> /* 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..eaf7b4dcea33 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -169,6 +169,8 @@ static __be32 get_client_locked(struct nfs4_client *clp)
> if (is_client_expired(clp))
> return nfserr_expired;
> atomic_inc(&clp->cl_rpc_users);
> + if (clp->cl_state != NFSD4_ACTIVE)
> + atomic_add_unless(&nn->nfsd_courtesy_client_count, -1, 0);
This appears to be a common bit of logic. Create a helper for it?
> clp->cl_state = NFSD4_ACTIVE;
> return nfs_ok;
> }
> @@ -190,6 +192,8 @@ renew_client_locked(struct nfs4_client *clp)
>
> list_move_tail(&clp->cl_lru, &nn->client_lru);
> clp->cl_time = ktime_get_boottime_seconds();
> + if (clp->cl_state != NFSD4_ACTIVE)
> + atomic_add_unless(&nn->nfsd_courtesy_client_count, -1, 0);
> clp->cl_state = NFSD4_ACTIVE;
> }
>
> @@ -2233,6 +2237,8 @@ __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);
> + if (clp->cl_state != NFSD4_ACTIVE)
> + atomic_add_unless(&nn->nfsd_courtesy_client_count, -1, 0);
> free_client(clp);
> wake_up_all(&expiry_wq);
> }
> @@ -4356,6 +4362,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_client_count, 0);
> }
>
> static void init_nfs4_replay(struct nfs4_replay *rp)
> @@ -5878,8 +5886,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_client_count);
> clp->cl_state = NFSD4_COURTESY;
> + }
> if (!client_has_state(clp))
> goto exp_client;
> if (!nfs4_anylock_blockers(clp))
> --
> 2.9.5
>
--
Chuck Lever
next prev parent reply other threads:[~2022-08-31 14:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 21:48 [PATCH v4 0/2] NFSD: memory shrinker for NFSv4 clients Dai Ngo
2022-08-30 21:48 ` [PATCH v4 1/2] NFSD: keep track of the number of courtesy clients in the system Dai Ngo
2022-08-31 14:30 ` Chuck Lever III [this message]
2022-08-30 21:48 ` [PATCH v4 2/2] NFSD: add shrinker to reap courtesy clients on low memory condition Dai Ngo
2022-08-31 14:30 ` Chuck Lever III
2022-09-02 1:56 ` dai.ngo
2022-09-02 4:32 ` Chuck Lever III
2022-09-02 16:44 ` dai.ngo
2022-09-02 17:58 ` Chuck Lever III
2022-09-02 19:34 ` dai.ngo
2022-09-03 1:26 ` Chuck Lever III
2022-09-03 17:03 ` dai.ngo
2022-09-03 17:29 ` Chuck Lever III
2022-09-03 17:59 ` dai.ngo
2022-09-06 13:00 ` J. Bruce Fields
2022-09-06 19:04 ` dai.ngo
2022-08-31 10:00 ` [PATCH v4 0/2] NFSD: memory shrinker for NFSv4 clients Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B4F7A73D-3306-4D9F-9DF2-A964F95EEAFD@oracle.com \
--to=chuck.lever@oracle.com \
--cc=dai.ngo@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox