From 29dbc93e2855a9fb734dd299807b6e02ca6b74ff Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Wed, 3 Apr 2013 14:33:49 -0400 Subject: [PATCH] NFSv4: Be less aggressive about returning delegations for open files Currently, if the application that holds the file open isn't doing I/O, we may end up returning the delegation. This means that we can no longer cache the file as aggressively, and often also that we multiply the state that both the server and the client needs to track. This patch adds a check for open files to the routine that scans for delegations that are unreferenced. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index fc8a213497a1..5e647cdc1532 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -570,11 +570,16 @@ void nfs_expire_all_delegations(struct nfs_client *clp) static void nfs_mark_return_unreferenced_delegations(struct nfs_server *server) { struct nfs_delegation *delegation; + struct inode *inode; list_for_each_entry_rcu(delegation, &server->delegations, super_list) { if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags)) continue; - nfs_mark_return_delegation(server, delegation); + spin_lock(&delegation->lock); + inode = delegation->inode; + if (inode != NULL && list_empty(&NFS_I(inode)->open_files)) + nfs_mark_return_delegation(server, delegation); + spin_unlock(&delegation->lock); } } -- 2.39.5