NFSD: limit the number of v4 clients to 1024 per 1GB of system memory
authorDai Ngo <dai.ngo@oracle.com>
Fri, 15 Jul 2022 23:54:53 +0000 (16:54 -0700)
committerChuck Lever <chuck.lever@oracle.com>
Sat, 30 Jul 2022 00:16:56 +0000 (20:16 -0400)
commit4271c2c0887562318a0afef97d32d8a71cbe0743
tree6e09d77bfaa2cfe8c2da92ce7722ce02f5ddb711
parent0926c39515aa065a296e97dfc8790026f1e53f86
NFSD: limit the number of v4 clients to 1024 per 1GB of system memory

Currently there is no limit on how many v4 clients are supported
by the system. This can be a problem in systems with small memory
configuration to function properly when a very large number of
clients exist that creates memory shortage conditions.

This patch enforces a limit of 1024 NFSv4 clients, including courtesy
clients, per 1GB of system memory.  When the number of the clients
reaches the limit, requests that create new clients are returned
with NFS4ERR_DELAY and the laundromat is kicked start to trim old
clients. Due to the overhead of the upcall to remove the client
record, the maximun number of clients the laundromat removes on
each run is limited to 128. This is done to ensure the laundromat
can still process the other tasks in a timely manner.

Since there is now a limit of the number of clients, the 24-hr
idle time limit of courtesy client is no longer needed and was
removed.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/netns.h
fs/nfsd/nfs4state.c
fs/nfsd/nfsd.h