NLM/lockd: Add a reference counter to struct nlm_rqst
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 1 Apr 2008 22:58:49 +0000 (18:58 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Sat, 19 Apr 2008 20:53:36 +0000 (16:53 -0400)
When we replace the existing synchronous RPC calls with asynchronous calls,
the reference count will be needed in order to allow us to examine the
result of the RPC call.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/lockd/clntproc.c
include/linux/lockd/lockd.h

index 4e1c0123b45d0e1ecee1a1641fb51c252c426a6a..749eb5328cb0cf0e51d3a3530a3eac01d60e7fe7 100644 (file)
@@ -221,6 +221,7 @@ struct nlm_rqst *nlm_alloc_call(struct nlm_host *host)
        for(;;) {
                call = kzalloc(sizeof(*call), GFP_KERNEL);
                if (call != NULL) {
+                       atomic_set(&call->a_count, 1);
                        locks_init_lock(&call->a_args.lock.fl);
                        locks_init_lock(&call->a_res.lock.fl);
                        call->a_host = host;
@@ -237,6 +238,8 @@ struct nlm_rqst *nlm_alloc_call(struct nlm_host *host)
 
 void nlm_release_call(struct nlm_rqst *call)
 {
+       if (!atomic_dec_and_test(&call->a_count))
+               return;
        nlm_release_host(call->a_host);
        nlmclnt_release_lockargs(call);
        kfree(call);
index acf39e1e3a3dfa09dc32f70ea96422c49aac4b2c..94649a8da01403975c0c24e657f8062b9ec5dc80 100644 (file)
@@ -91,6 +91,7 @@ struct nlm_wait;
  */
 #define NLMCLNT_OHSIZE         ((__NEW_UTS_LEN) + 10u)
 struct nlm_rqst {
+       atomic_t                a_count;
        unsigned int            a_flags;        /* initial RPC task flags */
        struct nlm_host *       a_host;         /* host handle */
        struct nlm_args         a_args;         /* arguments */