Commit 10717f45 authored by Trond Myklebust's avatar Trond Myklebust Committed by Anna Schumaker

NFSv4: Limit the total number of cached delegations

Delegations can be expensive to return, and can cause scalability issues
for the server. Let's therefore try to limit the number of inactive
delegations we hold.
Once the number of delegations is above a certain threshold, start
to return them on close.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent d2269ea1
...@@ -25,7 +25,10 @@ ...@@ -25,7 +25,10 @@
#include "internal.h" #include "internal.h"
#include "nfs4trace.h" #include "nfs4trace.h"
#define NFS_DEFAULT_DELEGATION_WATERMARK (5000U)
static atomic_long_t nfs_active_delegations; static atomic_long_t nfs_active_delegations;
static unsigned nfs_delegation_watermark = NFS_DEFAULT_DELEGATION_WATERMARK;
static void __nfs_free_delegation(struct nfs_delegation *delegation) static void __nfs_free_delegation(struct nfs_delegation *delegation)
{ {
...@@ -676,7 +679,8 @@ void nfs4_inode_return_delegation_on_close(struct inode *inode) ...@@ -676,7 +679,8 @@ void nfs4_inode_return_delegation_on_close(struct inode *inode)
delegation = nfs4_get_valid_delegation(inode); delegation = nfs4_get_valid_delegation(inode);
if (!delegation) if (!delegation)
goto out; goto out;
if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags)) { if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags) ||
atomic_long_read(&nfs_active_delegations) >= nfs_delegation_watermark) {
spin_lock(&delegation->lock); spin_lock(&delegation->lock);
if (delegation->inode && if (delegation->inode &&
list_empty(&NFS_I(inode)->open_files) && list_empty(&NFS_I(inode)->open_files) &&
...@@ -1365,3 +1369,5 @@ bool nfs4_delegation_flush_on_close(const struct inode *inode) ...@@ -1365,3 +1369,5 @@ bool nfs4_delegation_flush_on_close(const struct inode *inode)
rcu_read_unlock(); rcu_read_unlock();
return ret; return ret;
} }
module_param_named(delegation_watermark, nfs_delegation_watermark, uint, 0644);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment