]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
NFSv4: Be less aggressive about returning delegations for open files
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 3 Apr 2013 18:33:49 +0000 (14:33 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 3 Apr 2013 18:48:56 +0000 (14:48 -0400)
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 <Trond.Myklebust@netapp.com>
fs/nfs/delegation.c

index fc8a213497a1d60f9341983a4ee1a244de474114..5e647cdc1532f1cc99cb550dc53a8733ee97591b 100644 (file)
@@ -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);
        }
 }