nfsd4: introduce nfs4_client.cl_refcount
authorBenny Halevy <bhalevy@panasas.com>
Tue, 11 May 2010 21:13:29 +0000 (00:13 +0300)
committerJ. Bruce Fields <bfields@citi.umich.edu>
Thu, 13 May 2010 15:47:03 +0000 (11:47 -0400)
Currently just initialize the cl_refcount to 1
and decrement in expire_client(), conditionally freeing the
client when the refcount reaches 0.

To be used later by nfsv4.1 compounds to keep the client from
timing out while in use.

Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
fs/nfsd/nfs4state.c
fs/nfsd/state.h

index dede43c373361849bf5fa2194be7f33266e0fc05..e439a882e0c239342e7eee5a6c219764e5245bf0 100644 (file)
@@ -740,8 +740,9 @@ expire_client(struct nfs4_client *clp)
        list_del(&clp->cl_strhash);
        spin_lock(&client_lock);
        unhash_client_locked(clp);
+       if (atomic_read(&clp->cl_refcount) == 0)
+               free_client(clp);
        spin_unlock(&client_lock);
-       free_client(clp);
 }
 
 static void copy_verf(struct nfs4_client *target, nfs4_verifier *source)
@@ -827,6 +828,7 @@ static struct nfs4_client *create_client(struct xdr_netobj name, char *recdir,
        }
 
        memcpy(clp->cl_recdir, recdir, HEXDIR_LEN);
+       atomic_set(&clp->cl_refcount, 0);
        atomic_set(&clp->cl_cb_set, 0);
        INIT_LIST_HEAD(&clp->cl_idhash);
        INIT_LIST_HEAD(&clp->cl_strhash);
index 98836fd87f69b721c2c291d645e32527d576b997..ee42a0beecfa97ac167455de62fb72a66de0ab5c 100644 (file)
@@ -233,6 +233,8 @@ struct nfs4_client {
        struct nfsd4_clid_slot  cl_cs_slot;     /* create_session slot */
        u32                     cl_exchange_flags;
        struct nfs4_sessionid   cl_sessionid;
+       /* number of rpc's in progress over an associated session: */
+       atomic_t                cl_refcount;
 
        /* for nfs41 callbacks */
        /* We currently support a single back channel with a single slot */