NFSv4.1: Ensure state manager thread dies on last umount
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 15 Apr 2011 21:34:18 +0000 (17:34 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 15 Apr 2011 22:28:22 +0000 (18:28 -0400)
Currently, the state manager may continue to try recovering state forever
even after the last filesystem to reference that nfs_client has umounted.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org
fs/nfs/nfs4state.c

index a6804f7..4dfb34b 100644 (file)
@@ -1607,7 +1607,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
        int status = 0;
 
        /* Ensure exclusive access to NFSv4 state */
-       for(;;) {
+       do {
                if (test_and_clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) {
                        /* We're going to have to re-establish a clientid */
                        status = nfs4_reclaim_lease(clp);
@@ -1691,7 +1691,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
                        break;
                if (test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) != 0)
                        break;
-       }
+       } while (atomic_read(&clp->cl_count) > 1);
        return;
 out_error:
        printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s"