Whamcloud - gitweb
LU-1046 ldlm: hold ldlm_cb_set_arg until the last user exit
[fs/lustre-release.git] / lustre / ldlm / ldlm_internal.h
index f6bb70e..aa0faef 100644 (file)
@@ -108,9 +108,19 @@ struct ldlm_cb_set_arg {
         unsigned int threshold; /* threshold to wake up the waiting proc */
         cfs_atomic_t rpcs;      /* # of inflight rpcs in set */
         cfs_atomic_t restart;
+        cfs_atomic_t refcount;
         cfs_waitq_t  waitq;
 };
 
+static inline void ldlm_csa_put(struct ldlm_cb_set_arg *arg)
+{
+        if (cfs_atomic_dec_and_test(&arg->refcount)) {
+                LASSERT(cfs_atomic_read(&arg->rpcs) == 0);
+
+                OBD_FREE_PTR(arg);
+        }
+}
+
 typedef enum {
         LDLM_WORK_BL_AST,
         LDLM_WORK_CP_AST,