Blob Blame History Raw
From 72d7042b1ab15f05aa89b22a497527abd3f94d96 Mon Sep 17 00:00:00 2001
From: Krutika Dhananjay <kdhananj@redhat.com>
Date: Sat, 3 Dec 2016 09:09:15 +0530
Subject: [PATCH 226/227] afr, client: More mem-leak fixes in COMPOUND fop cbk

Bugs found and fixed:
1. Use correct subvolume index in pre-op-writev compound cbk
2. Prevent use-after-free of local->compound_args members in
   compound fops cbk in protocol/client
3. Fix xdata and xattr leaks in client_process_response
4. Fix possible leak of xdata in client_pre_writev() in
   test mode.
5. Free req->compound_req_array.compound_req_array_val as well
   after freeing its members
6. Free tmp_rsp->flock.lk_owner.lk_owner_val in LK fop.

 >Change-Id: I15b646d7d4e0e5cd4ea3d2d6452c815cf2eaf68f
 >BUG: 1401218
 >Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
 >Reviewed-on: http://review.gluster.org/16020
 >Smoke: Gluster Build System <jenkins@build.gluster.org>
 >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
 >Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
 >CentOS-regression: Gluster Build System <jenkins@build.gluster.org>

BUG: 1401380
Change-Id: Ia02c9b143bdb32371e14d0a09d45bd33ff4613e1
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/92061
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/cluster/afr/src/afr-common.c          |  12 -
 xlators/cluster/afr/src/afr-transaction.c     |  25 +-
 xlators/cluster/afr/src/afr.h                 |   5 +-
 xlators/protocol/client/src/client-common.c   |  10 +-
 xlators/protocol/client/src/client-common.h   |   2 +-
 xlators/protocol/client/src/client-helpers.c  | 426 ++++++++++----------------
 xlators/protocol/client/src/client-rpc-fops.c |   2 +-
 7 files changed, 190 insertions(+), 292 deletions(-)

diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index 8098c1c..a87428a 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -5836,18 +5836,6 @@ afr_pack_fop_args (call_frame_t *frame, compound_args_t *args,
         return NULL;
 }
 
-void
-afr_compound_cleanup (compound_args_t *args, dict_t *xdata,
-                      dict_t *newloc_xdata)
-{
-        if (args)
-                compound_args_cleanup (args);
-	if (xdata)
-		dict_unref (xdata);
-        if (newloc_xdata)
-                dict_unref (newloc_xdata);
-}
-
 int
 afr_fav_child_reset_sink_xattrs_cbk (int ret, call_frame_t *heal_frame,
                                      void *opaque)
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index 62b680c..4a551d1 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -1254,7 +1254,7 @@ afr_pre_op_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
                                        NULL, NULL, NULL);
         } else {
                 write_args_cbk = &args_cbk->rsp_list[1];
-                afr_inode_write_fill  (frame, this, (long) i,
+                afr_inode_write_fill  (frame, this, (long) child_index,
                                        write_args_cbk->op_ret,
                                        write_args_cbk->op_errno,
                                        &write_args_cbk->prestat,
@@ -1265,6 +1265,8 @@ afr_pre_op_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
 	call_count = afr_frame_return (frame);
 
         if (call_count == 0) {
+                compound_args_cleanup (local->c_args);
+                local->c_args = NULL;
                 afr_process_post_writev (frame, this);
                 if (!afr_txn_nothing_failed (frame, this)) {
                         /* Don't unwind until post-op is complete */
@@ -1356,6 +1358,8 @@ afr_pre_op_fop_do (call_frame_t *frame, xlator_t *this, dict_t *xattr,
          */
         compound_cbk = afr_pack_fop_args (frame, args, local->op, i);
 
+        local->c_args = args;
+
         for (i = 0; i < priv->child_count; i++) {
                 /* Means lock did not succeed on this brick */
                 if (!local->transaction.pre_op[i])
@@ -1371,7 +1375,10 @@ afr_pre_op_fop_do (call_frame_t *frame, xlator_t *this, dict_t *xattr,
                         break;
         }
 
-        afr_compound_cleanup (args, xdata, newloc_xdata);
+        if (xdata)
+                dict_unref (xdata);
+        if (newloc_xdata)
+                dict_unref (newloc_xdata);
         return 0;
 err:
 	local->internal_lock.lock_cbk = local->transaction.done;
@@ -1381,7 +1388,10 @@ err:
         afr_restore_lk_owner (frame);
 	afr_unlock (frame, this);
 
-        afr_compound_cleanup (args, xdata, newloc_xdata);
+        if (xdata)
+                dict_unref (xdata);
+        if (newloc_xdata)
+                dict_unref (newloc_xdata);
 	return 0;
 }
 
@@ -1415,6 +1425,8 @@ afr_post_op_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
         UNLOCK (&frame->lock);
 
         if (call_count == 0) {
+                compound_args_cleanup (local->c_args);
+                local->c_args = NULL;
                 if (local->transaction.resume_stub) {
                         call_resume (local->transaction.resume_stub);
                         local->transaction.resume_stub = NULL;
@@ -1496,6 +1508,8 @@ afr_post_op_unlock_do (call_frame_t *frame, xlator_t *this, dict_t *xattr,
                 }
         }
 
+        local->c_args = args;
+
         for (i = 0; i < priv->child_count; i++) {
                 /* pre_op[i] has to be true for all nodes that were
                  * successfully locked. */
@@ -1511,7 +1525,10 @@ afr_post_op_unlock_do (call_frame_t *frame, xlator_t *this, dict_t *xattr,
                         break;
         }
 out:
-        afr_compound_cleanup (args, xdata, newloc_xdata);
+        if (xdata)
+                dict_unref (xdata);
+        if (newloc_xdata)
+                dict_unref (newloc_xdata);
         return 0;
 }
 
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index c84c3af..63002cd 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -806,6 +806,7 @@ typedef struct _afr_local {
         gf_boolean_t need_full_crawl;
         gf_boolean_t compound;
         afr_fop_lock_state_t fop_lock_state;
+        compound_args_t *c_args;
 } afr_local_t;
 
 
@@ -1215,10 +1216,6 @@ afr_is_inodelk_transaction(afr_local_t *local);
 afr_fd_ctx_t *
 __afr_fd_ctx_get (fd_t *fd, xlator_t *this);
 
-void
-afr_compound_cleanup (compound_args_t *args, dict_t *xdata,
-                      dict_t *newloc_xdata);
-
 int32_t
 afr_quorum_errno (afr_private_t *priv);
 
diff --git a/xlators/protocol/client/src/client-common.c b/xlators/protocol/client/src/client-common.c
index 4fff7e6..f34788b 100644
--- a/xlators/protocol/client/src/client-common.c
+++ b/xlators/protocol/client/src/client-common.c
@@ -367,7 +367,7 @@ out:
 int
 client_pre_writev (xlator_t *this, gfs3_write_req *req,
                    fd_t *fd, size_t size, off_t offset, int32_t flags,
-                   dict_t *xdata)
+                   dict_t **xdata)
 {
         int64_t         remote_fd = -1;
         int             op_errno = ESTALE;
@@ -383,14 +383,14 @@ client_pre_writev (xlator_t *this, gfs3_write_req *req,
         memcpy (req->gfid, fd->inode->gfid, 16);
 
 #ifdef GF_TESTING_IO_XDATA
-        if (!xdata)
-                xdata = dict_new ();
+        if (!*xdata)
+                *xdata = dict_new ();
 
-        ret = dict_set_str (xdata, "testing-the-xdata-key",
+        ret = dict_set_str (*xdata, "testing-the-xdata-key",
                             "testing-the-xdata-value");
 #endif
 
-        GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+        GF_PROTOCOL_DICT_SERIALIZE (this, *xdata, (&req->xdata.xdata_val),
                                     req->xdata.xdata_len, op_errno, out);
 
         return 0;
diff --git a/xlators/protocol/client/src/client-common.h b/xlators/protocol/client/src/client-common.h
index 2298fa4..fd3fba8 100644
--- a/xlators/protocol/client/src/client-common.h
+++ b/xlators/protocol/client/src/client-common.h
@@ -70,7 +70,7 @@ client_pre_readv (xlator_t *this, gfs3_read_req *req, fd_t *fd, size_t size,
 int
 client_pre_writev (xlator_t *this, gfs3_write_req *req,
                    fd_t *fd, size_t size, off_t offset, int32_t flags,
-                   dict_t *xdata);
+                   dict_t **xdata);
 
 int
 client_pre_statfs (xlator_t *this, gfs3_statfs_req *req, loc_t *loc,
diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c
index a7e46b5..d3e6a90 100644
--- a/xlators/protocol/client/src/client-helpers.c
+++ b/xlators/protocol/client/src/client-helpers.c
@@ -136,9 +136,7 @@ client_local_wipe (clnt_local_t *local)
                 }
 
                 GF_FREE (local->name);
-
                 local->compound_args = NULL;
-
                 mem_put (local);
         }
 
@@ -372,6 +370,10 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                          int index)
 {
         int                      ret            = 0;
+        dict_t                  *xdata          = NULL;
+        dict_t                  *xattr          = NULL;
+        struct iovec             vector[MAX_IOVEC] = {{0}, };
+        gf_dirent_t              entries;
         default_args_cbk_t      *this_args_cbk  = &args_cbk->rsp_list[index];
         clnt_local_t            *local          = frame->local;
         compound_rsp            *this_rsp       = NULL;
@@ -381,6 +383,8 @@ client_process_response (call_frame_t *frame, xlator_t *this,
         this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[index];
         args_cbk->enum_list[index] = this_rsp->fop_enum;
 
+        INIT_LIST_HEAD (&entries.list);
+
         switch (args_cbk->enum_list[index]) {
 
         case GF_FOP_STAT:
@@ -388,12 +392,10 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_stat_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_stat_rsp;
 
-                client_post_stat (this, tmp_rsp,
-                                  &this_args_cbk->stat, &this_args_cbk->xdata);
+                client_post_stat (this, tmp_rsp, &this_args_cbk->stat, &xdata);
 
                 CLIENT_POST_FOP_TYPE (stat, this_rsp, this_args_cbk,
-                                      &this_args_cbk->stat,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->stat, xdata);
                 break;
         }
         case GF_FOP_READLINK:
@@ -401,12 +403,11 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_readlink_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_readlink_rsp;
 
-                client_post_readlink (this, tmp_rsp,
-                                      &this_args_cbk->stat, &this_args_cbk->xdata);
+                client_post_readlink (this, tmp_rsp, &this_args_cbk->stat,
+                                      &xdata);
                 CLIENT_POST_FOP_TYPE (readlink, this_rsp, this_args_cbk,
-                                      tmp_rsp->path,
-                                      &this_args_cbk->stat,
-                                      this_args_cbk->xdata);
+                                      tmp_rsp->path, &this_args_cbk->stat,
+                                      xdata);
                 break;
         }
         case GF_FOP_MKNOD:
@@ -414,17 +415,13 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_mknod_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_mknod_rsp;
 
-                client_post_mknod (this, tmp_rsp,
-                                   &this_args_cbk->stat,
+                client_post_mknod (this, tmp_rsp, &this_args_cbk->stat,
                                    &this_args_cbk->preparent,
-                                   &this_args_cbk->postparent,
-                                   &this_args_cbk->xdata);
+                                   &this_args_cbk->postparent, &xdata);
                 CLIENT_POST_FOP_TYPE (mknod, this_rsp, this_args_cbk,
-                                      local->loc.inode,
-                                      &this_args_cbk->stat,
+                                      local->loc.inode, &this_args_cbk->stat,
                                       &this_args_cbk->preparent,
-                                      &this_args_cbk->postparent,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->postparent, xdata);
                 break;
         }
         case GF_FOP_MKDIR:
@@ -432,18 +429,13 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_mkdir_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_mkdir_rsp;
 
-                client_post_mkdir (this,
-                                   tmp_rsp,
-                                   &this_args_cbk->stat,
+                client_post_mkdir (this, tmp_rsp, &this_args_cbk->stat,
                                    &this_args_cbk->preparent,
-                                   &this_args_cbk->postparent,
-                                   &this_args_cbk->xdata);
+                                   &this_args_cbk->postparent, &xdata);
                 CLIENT_POST_FOP_TYPE (mkdir, this_rsp, this_args_cbk,
-                                      local->loc.inode,
-                                      &this_args_cbk->stat,
+                                      local->loc.inode, &this_args_cbk->stat,
                                       &this_args_cbk->preparent,
-                                      &this_args_cbk->postparent,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->postparent, xdata);
                 break;
         }
         case GF_FOP_UNLINK:
@@ -451,15 +443,11 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_unlink_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_unlink_rsp;
 
-                client_post_unlink (this,
-                                    tmp_rsp,
-                                    &this_args_cbk->preparent,
-                                    &this_args_cbk->postparent,
-                                    &this_args_cbk->xdata);
+                client_post_unlink (this, tmp_rsp, &this_args_cbk->preparent,
+                                    &this_args_cbk->postparent, &xdata);
                 CLIENT_POST_FOP_TYPE (unlink, this_rsp, this_args_cbk,
                                       &this_args_cbk->preparent,
-                                      &this_args_cbk->postparent,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->postparent, xdata);
                 break;
         }
         case GF_FOP_RMDIR:
@@ -467,14 +455,11 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_rmdir_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_rmdir_rsp;
 
-                client_post_rmdir (this, tmp_rsp,
-                                   &this_args_cbk->preparent,
-                                   &this_args_cbk->postparent,
-                                   &this_args_cbk->xdata);
+                client_post_rmdir (this, tmp_rsp, &this_args_cbk->preparent,
+                                   &this_args_cbk->postparent, &xdata);
                 CLIENT_POST_FOP_TYPE (rmdir, this_rsp, this_args_cbk,
                                       &this_args_cbk->preparent,
-                                      &this_args_cbk->postparent,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->postparent, xdata);
                 break;
         }
         case GF_FOP_SYMLINK:
@@ -482,16 +467,13 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_symlink_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_symlink_rsp;
 
-                client_post_symlink (this, tmp_rsp,
-                                     &this_args_cbk->stat,
+                client_post_symlink (this, tmp_rsp, &this_args_cbk->stat,
                                      &this_args_cbk->preparent,
-                                     &this_args_cbk->postparent,
-                                     &this_args_cbk->xdata);
+                                     &this_args_cbk->postparent, &xdata);
                 CLIENT_POST_FOP_TYPE (symlink, this_rsp, this_args_cbk, NULL,
                                       &this_args_cbk->stat,
                                       &this_args_cbk->preparent,
-                                      &this_args_cbk->postparent,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->postparent, xdata);
                 break;
         }
         case GF_FOP_RENAME:
@@ -499,20 +481,17 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_rename_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_rename_rsp;
 
-                client_post_rename (this, tmp_rsp,
-                                    &this_args_cbk->stat,
+                client_post_rename (this, tmp_rsp, &this_args_cbk->stat,
                                     &this_args_cbk->preparent,
                                     &this_args_cbk->postparent,
                                     &this_args_cbk->preparent2,
-                                    &this_args_cbk->postparent2,
-                                    &this_args_cbk->xdata);
+                                    &this_args_cbk->postparent2, &xdata);
                 CLIENT_POST_FOP_TYPE (rename, this_rsp, this_args_cbk,
                                       &this_args_cbk->stat,
                                       &this_args_cbk->preparent,
                                       &this_args_cbk->postparent,
                                       &this_args_cbk->preparent2,
-                                      &this_args_cbk->postparent2,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->postparent2, xdata);
                 break;
         }
         case GF_FOP_LINK:
@@ -520,16 +499,13 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_link_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_link_rsp;
 
-                client_post_link (this, tmp_rsp,
-                                  &this_args_cbk->stat,
+                client_post_link (this, tmp_rsp, &this_args_cbk->stat,
                                   &this_args_cbk->preparent,
-                                  &this_args_cbk->postparent,
-                                  &this_args_cbk->xdata);
+                                  &this_args_cbk->postparent, &xdata);
                 CLIENT_POST_FOP_TYPE (link, this_rsp, this_args_cbk, NULL,
                                       &this_args_cbk->stat,
                                       &this_args_cbk->preparent,
-                                      &this_args_cbk->postparent,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->postparent, xdata);
                 break;
         }
         case GF_FOP_TRUNCATE:
@@ -537,14 +513,11 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_truncate_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_truncate_rsp;
 
-                client_post_truncate (this, tmp_rsp,
-                                      &this_args_cbk->prestat,
-                                      &this_args_cbk->poststat,
-                                      &this_args_cbk->xdata);
+                client_post_truncate (this, tmp_rsp, &this_args_cbk->prestat,
+                                      &this_args_cbk->poststat, &xdata);
                 CLIENT_POST_FOP_TYPE (truncate, this_rsp, this_args_cbk,
                                       &this_args_cbk->prestat,
-                                      &this_args_cbk->poststat,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->poststat, xdata);
                 break;
         }
         case GF_FOP_OPEN:
@@ -552,11 +525,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_open_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_open_rsp;
 
-                client_post_open (this, tmp_rsp,
-                                  &this_args_cbk->xdata);
-                CLIENT_POST_FOP_TYPE (open, this_rsp, this_args_cbk,
-                                      local->fd,
-                                      this_args_cbk->xdata);
+                client_post_open (this, tmp_rsp, &xdata);
+                CLIENT_POST_FOP_TYPE (open, this_rsp, this_args_cbk, local->fd,
+                                      xdata);
                 if (-1 != this_args_cbk->op_ret)
                         ret = client_add_fd_to_saved_fds (this, local->fd,
                                                           &local->loc,
@@ -571,11 +542,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_read_rsp;
 
                 client_post_readv (this, tmp_rsp, &this_args_cbk->iobref,
-                                  req->rsp_iobref,
-                                  &this_args_cbk->stat,
-                                  this_args_cbk->vector, &req->rsp[1],
-                                  &this_args_cbk->count,
-                                  &this_args_cbk->xdata);
+                                  req->rsp_iobref, &this_args_cbk->stat,
+                                  vector, &req->rsp[1], &this_args_cbk->count,
+                                  &xdata);
 
                 /* Each read should be given read response that only
                  * corresponds to its request.
@@ -584,7 +553,7 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                  * so that the next ones can continue from there.
                  */
                 if (local->read_length) {
-                        this_args_cbk->vector[0].iov_base += local->read_length;
+                        vector[0].iov_base += local->read_length;
                         local->read_length += tmp_rsp->op_ret;
                 } else {
                         local->read_length = tmp_rsp->op_ret;
@@ -592,11 +561,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
 
                 args_readv_cbk_store (this_args_cbk, tmp_rsp->op_ret,
                                       gf_error_to_errno (tmp_rsp->op_errno),
-                                      this_args_cbk->vector,
-                                      this_args_cbk->count,
+                                      vector, this_args_cbk->count,
                                       &this_args_cbk->stat,
-                                      this_args_cbk->iobref,
-                                      this_args_cbk->xdata);
+                                      this_args_cbk->iobref, xdata);
 
                 if (tmp_rsp->op_ret >= 0)
                         if (local->attempt_reopen)
@@ -610,13 +577,11 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_write_rsp;
 
                 client_post_writev (this, tmp_rsp, &this_args_cbk->prestat,
-                                   &this_args_cbk->poststat,
-                                   &this_args_cbk->xdata);
+                                   &this_args_cbk->poststat, &xdata);
                 args_writev_cbk_store (this_args_cbk, tmp_rsp->op_ret,
                                        gf_error_to_errno (tmp_rsp->op_errno),
                                        &this_args_cbk->prestat,
-                                       &this_args_cbk->poststat,
-                                       this_args_cbk->xdata);
+                                       &this_args_cbk->poststat, xdata);
 
                 if (tmp_rsp->op_ret == 0)
                         if (local->attempt_reopen)
@@ -628,13 +593,11 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_statfs_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_statfs_rsp;
 
-                client_post_statfs (this, tmp_rsp,
-                                    &this_args_cbk->statvfs,
-                                    &this_args_cbk->xdata);
+                client_post_statfs (this, tmp_rsp, &this_args_cbk->statvfs,
+                                    &xdata);
 
                 CLIENT_POST_FOP_TYPE (statfs, this_rsp, this_args_cbk,
-                                      &this_args_cbk->statvfs,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->statvfs, xdata);
                 break;
          }
         case GF_FOP_FLUSH:
@@ -642,11 +605,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gf_common_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_flush_rsp;
 
-                client_post_flush (this, tmp_rsp,
-                                    &this_args_cbk->xdata);
+                client_post_flush (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP (flush, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP (flush, this_rsp, this_args_cbk, xdata);
                 if (this_args_cbk->op_ret >= 0 && !fd_is_anonymous (local->fd)) {
                         /* Delete all saved locks of the owner issuing flush */
                         ret = delete_granted_locks_owner (local->fd, &local->owner);
@@ -661,15 +622,12 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_fsync_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_fsync_rsp;
 
-                client_post_fsync (this, tmp_rsp,
-                                   &this_args_cbk->prestat,
-                                   &this_args_cbk->poststat,
-                                   &this_args_cbk->xdata);
+                client_post_fsync (this, tmp_rsp, &this_args_cbk->prestat,
+                                   &this_args_cbk->poststat, &xdata);
 
                 CLIENT_POST_FOP_TYPE (fsync, this_rsp, this_args_cbk,
                                       &this_args_cbk->prestat,
-                                      &this_args_cbk->poststat,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->poststat, xdata);
                 break;
         }
         case GF_FOP_SETXATTR:
@@ -677,11 +635,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gf_common_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_setxattr_rsp;
 
-                client_post_setxattr (this, tmp_rsp,
-                                      &this_args_cbk->xdata);
+                client_post_setxattr (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP (setxattr, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP (setxattr, this_rsp, this_args_cbk, xdata);
                 break;
         }
         case GF_FOP_GETXATTR:
@@ -689,13 +645,10 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_getxattr_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_getxattr_rsp;
 
-                client_post_getxattr (this, tmp_rsp,
-                                      &this_args_cbk->xattr,
-                                      &this_args_cbk->xdata);
+                client_post_getxattr (this, tmp_rsp, &xattr, &xdata);
 
-                CLIENT_POST_FOP_TYPE (getxattr, this_rsp, this_args_cbk,
-                                      this_args_cbk->xattr,
-                                      this_args_cbk->xdata);
+                CLIENT_POST_FOP_TYPE (getxattr, this_rsp, this_args_cbk, xattr,
+                                      xdata);
                 break;
         }
         case GF_FOP_REMOVEXATTR:
@@ -703,11 +656,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gf_common_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_removexattr_rsp;
 
-                client_post_removexattr (this, tmp_rsp,
-                                         &this_args_cbk->xdata);
+                client_post_removexattr (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP (removexattr, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP (removexattr, this_rsp, this_args_cbk, xdata);
                 break;
         }
         case GF_FOP_OPENDIR:
@@ -715,12 +666,10 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_opendir_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_opendir_rsp;
 
-                client_post_opendir (this, tmp_rsp,
-                                     &this_args_cbk->xdata);
+                client_post_opendir (this, tmp_rsp, &xdata);
 
                 CLIENT_POST_FOP_TYPE (opendir, this_rsp, this_args_cbk,
-                                      local->fd,
-                                      this_args_cbk->xdata);
+                                      local->fd, xdata);
                 if (-1 != this_args_cbk->op_ret)
                         ret = client_add_fd_to_saved_fds (this, local->fd,
                                                           &local->loc,
@@ -733,11 +682,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gf_common_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_fsyncdir_rsp;
 
-                client_post_fsyncdir (this, tmp_rsp,
-                                      &this_args_cbk->xdata);
+                client_post_fsyncdir (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP (fsyncdir, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP (fsyncdir, this_rsp, this_args_cbk, xdata);
                 break;
         }
         case GF_FOP_ACCESS:
@@ -745,11 +692,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gf_common_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_access_rsp;
 
-                client_post_access (this, tmp_rsp,
-                                      &this_args_cbk->xdata);
+                client_post_access (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP (access, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP (access, this_rsp, this_args_cbk, xdata);
                 break;
         }
         case GF_FOP_CREATE:
@@ -757,19 +702,15 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_create_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_create_rsp;
 
-                client_post_create (this, tmp_rsp,
-                                   &this_args_cbk->stat,
+                client_post_create (this, tmp_rsp, &this_args_cbk->stat,
                                    &this_args_cbk->preparent,
-                                   &this_args_cbk->postparent,
-                                   local,
-                                   &this_args_cbk->xdata);
+                                   &this_args_cbk->postparent, local, &xdata);
+
                 CLIENT_POST_FOP_TYPE (create, this_rsp, this_args_cbk,
-                                      local->fd,
-                                      local->loc.inode,
+                                      local->fd, local->loc.inode,
                                       &this_args_cbk->stat,
                                       &this_args_cbk->preparent,
-                                      &this_args_cbk->postparent,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->postparent, xdata);
                 if (-1 != this_args_cbk->op_ret)
                         ret = client_add_fd_to_saved_fds (this, local->fd,
                                                           &local->loc,
@@ -782,14 +723,11 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_ftruncate_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_ftruncate_rsp;
 
-                client_post_ftruncate (this, tmp_rsp,
-                                      &this_args_cbk->prestat,
-                                      &this_args_cbk->poststat,
-                                      &this_args_cbk->xdata);
+                client_post_ftruncate (this, tmp_rsp, &this_args_cbk->prestat,
+                                      &this_args_cbk->poststat, &xdata);
                 CLIENT_POST_FOP_TYPE (ftruncate, this_rsp, this_args_cbk,
                                       &this_args_cbk->prestat,
-                                      &this_args_cbk->poststat,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->poststat, xdata);
                 break;
         }
         case GF_FOP_FSTAT:
@@ -797,12 +735,10 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_fstat_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_fstat_rsp;
 
-                client_post_fstat (this, tmp_rsp,
-                                  &this_args_cbk->stat, &this_args_cbk->xdata);
+                client_post_fstat (this, tmp_rsp, &this_args_cbk->stat, &xdata);
 
                 CLIENT_POST_FOP_TYPE (fstat, this_rsp, this_args_cbk,
-                                      &this_args_cbk->stat,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->stat, xdata);
                 break;
         }
         case GF_FOP_LK:
@@ -810,13 +746,10 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_lk_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_lk_rsp;
 
-                client_post_lk (this, tmp_rsp,
-                               &this_args_cbk->lock,
-                               &this_args_cbk->xdata);
+                client_post_lk (this, tmp_rsp, &this_args_cbk->lock, &xdata);
 
                 CLIENT_POST_FOP_TYPE (lk, this_rsp, this_args_cbk,
-                                      &this_args_cbk->lock,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->lock, xdata);
                 break;
         }
         case GF_FOP_LOOKUP:
@@ -824,15 +757,11 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_lookup_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_lookup_rsp;
 
-                client_post_lookup (this, tmp_rsp,
-                                   &this_args_cbk->stat,
-                                   &this_args_cbk->postparent,
-                                   &this_args_cbk->xdata);
+                client_post_lookup (this, tmp_rsp, &this_args_cbk->stat,
+                                    &this_args_cbk->postparent, &xdata);
                 CLIENT_POST_FOP_TYPE (lookup, this_rsp, this_args_cbk,
-                                      local->loc.inode,
-                                      &this_args_cbk->stat,
-                                      this_args_cbk->xdata,
-                                      &this_args_cbk->postparent);
+                                      local->loc.inode, &this_args_cbk->stat,
+                                      xdata, &this_args_cbk->postparent);
                 break;
         }
         case GF_FOP_READDIR:
@@ -840,11 +769,10 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_readdir_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_readdir_rsp;
 
-                client_post_readdir (this, tmp_rsp,
-                                   &this_args_cbk->entries, &this_args_cbk->xdata);
+                client_post_readdir (this, tmp_rsp, &entries, &xdata);
 
                 CLIENT_POST_FOP_TYPE (readdir, this_rsp, this_args_cbk,
-                                   &this_args_cbk->entries, this_args_cbk->xdata);
+                                      &entries, xdata);
                 break;
         }
         case GF_FOP_INODELK:
@@ -852,11 +780,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gf_common_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_inodelk_rsp;
 
-                client_post_inodelk (this, tmp_rsp,
-                                      &this_args_cbk->xdata);
+                client_post_inodelk (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP (inodelk, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP (inodelk, this_rsp, this_args_cbk, xdata);
                 break;
         }
         case GF_FOP_FINODELK:
@@ -864,11 +790,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gf_common_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_finodelk_rsp;
 
-                client_post_finodelk (this, tmp_rsp,
-                                      &this_args_cbk->xdata);
+                client_post_finodelk (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP (finodelk, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP (finodelk, this_rsp, this_args_cbk, xdata);
                 if (tmp_rsp->op_ret == 0)
                         if (local->attempt_reopen)
                                 client_attempt_reopen (local->fd, this);
@@ -879,11 +803,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gf_common_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_entrylk_rsp;
 
-                client_post_entrylk (this, tmp_rsp,
-                                      &this_args_cbk->xdata);
+                client_post_entrylk (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP (entrylk, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP (entrylk, this_rsp, this_args_cbk, xdata);
                 break;
         }
         case GF_FOP_FENTRYLK:
@@ -891,11 +813,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gf_common_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_fentrylk_rsp;
 
-                client_post_fentrylk (this, tmp_rsp,
-                                      &this_args_cbk->xdata);
+                client_post_fentrylk (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP (fentrylk, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP (fentrylk, this_rsp, this_args_cbk, xdata);
                 break;
         }
         case GF_FOP_XATTROP:
@@ -903,13 +823,10 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_xattrop_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_xattrop_rsp;
 
-                client_post_xattrop (this, tmp_rsp,
-                                     &this_args_cbk->xattr,
-                                     &this_args_cbk->xdata);
+                client_post_xattrop (this, tmp_rsp, &xattr, &xdata);
 
-                CLIENT_POST_FOP_TYPE (xattrop, this_rsp, this_args_cbk,
-                                      this_args_cbk->xattr,
-                                      this_args_cbk->xdata);
+                CLIENT_POST_FOP_TYPE (xattrop, this_rsp, this_args_cbk, xattr,
+                                      xdata);
                 break;
         }
         case GF_FOP_FXATTROP:
@@ -917,13 +834,10 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_fxattrop_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_fxattrop_rsp;
 
-                client_post_fxattrop (this, tmp_rsp,
-                                      &this_args_cbk->xattr,
-                                      &this_args_cbk->xdata);
+                client_post_fxattrop (this, tmp_rsp, &xattr, &xdata);
 
-                CLIENT_POST_FOP_TYPE (fxattrop, this_rsp, this_args_cbk,
-                                      this_args_cbk->xattr,
-                                      this_args_cbk->xdata);
+                CLIENT_POST_FOP_TYPE (fxattrop, this_rsp, this_args_cbk, xattr,
+                                      xdata);
                 if (rsp->op_ret == 0)
                         if (local->attempt_reopen)
                                 client_attempt_reopen (local->fd, this);
@@ -934,13 +848,10 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_fgetxattr_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_fgetxattr_rsp;
 
-                client_post_fgetxattr (this, tmp_rsp,
-                                      &this_args_cbk->xattr,
-                                      &this_args_cbk->xdata);
+                client_post_fgetxattr (this, tmp_rsp, &xattr, &xdata);
 
-                CLIENT_POST_FOP_TYPE (fgetxattr, this_rsp, this_args_cbk,
-                                      this_args_cbk->xattr,
-                                      this_args_cbk->xdata);
+                CLIENT_POST_FOP_TYPE (fgetxattr, this_rsp, this_args_cbk, xattr,
+                                      xdata);
                 break;
         }
         case GF_FOP_FSETXATTR:
@@ -948,11 +859,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gf_common_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_fsetxattr_rsp;
 
-                client_post_fsetxattr (this, tmp_rsp,
-                                      &this_args_cbk->xdata);
+                client_post_fsetxattr (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP (fsetxattr, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP (fsetxattr, this_rsp, this_args_cbk, xdata);
                 break;
         }
         case GF_FOP_RCHECKSUM:
@@ -960,14 +869,13 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_rchecksum_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_rchecksum_rsp;
 
-                client_post_rchecksum (this, tmp_rsp,
-                                      &this_args_cbk->xdata);
+                client_post_rchecksum (this, tmp_rsp, &xdata);
 
                 break;
                 CLIENT_POST_FOP_TYPE (rchecksum, this_rsp, this_args_cbk,
                                       tmp_rsp->weak_checksum,
                                       (uint8_t*)tmp_rsp->strong_checksum.strong_checksum_val,
-                                      this_args_cbk->xdata);
+                                      xdata);
                 break;
         }
         case GF_FOP_SETATTR:
@@ -975,15 +883,12 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_setattr_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_setattr_rsp;
 
-                client_post_setattr (this, tmp_rsp,
-                                    &this_args_cbk->prestat,
-                                    &this_args_cbk->poststat,
-                                    &this_args_cbk->xdata);
+                client_post_setattr (this, tmp_rsp, &this_args_cbk->prestat,
+                                    &this_args_cbk->poststat, &xdata);
 
                 CLIENT_POST_FOP_TYPE (setattr, this_rsp, this_args_cbk,
                                       &this_args_cbk->prestat,
-                                      &this_args_cbk->poststat,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->poststat, xdata);
                 break;
         }
         case GF_FOP_FSETATTR:
@@ -991,15 +896,12 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_fsetattr_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_fsetattr_rsp;
 
-                client_post_fsetattr (this, tmp_rsp,
-                                    &this_args_cbk->prestat,
-                                    &this_args_cbk->poststat,
-                                    &this_args_cbk->xdata);
+                client_post_fsetattr (this, tmp_rsp, &this_args_cbk->prestat,
+                                      &this_args_cbk->poststat, &xdata);
 
                 CLIENT_POST_FOP_TYPE (fsetattr, this_rsp, this_args_cbk,
                                       &this_args_cbk->prestat,
-                                      &this_args_cbk->poststat,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->poststat, xdata);
                 break;
         }
         case GF_FOP_READDIRP:
@@ -1007,13 +909,11 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_readdirp_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_readdirp_rsp;
 
-                client_post_readdirp (this, tmp_rsp, local->fd,
-                                      &this_args_cbk->entries,
-                                      &this_args_cbk->xdata);
+                client_post_readdirp (this, tmp_rsp, local->fd, &entries,
+                                      &xdata);
 
                 CLIENT_POST_FOP_TYPE (readdirp, this_rsp, this_args_cbk,
-                                      &this_args_cbk->entries,
-                                      this_args_cbk->xdata);
+                                      &entries, xdata);
                 break;
         }
         case GF_FOP_FREMOVEXATTR:
@@ -1021,11 +921,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gf_common_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_fremovexattr_rsp;
 
-                client_post_fremovexattr (this, tmp_rsp,
-                                         &this_args_cbk->xdata);
+                client_post_fremovexattr (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP (fremovexattr, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP (fremovexattr, this_rsp, this_args_cbk, xdata);
                 break;
         }
         case GF_FOP_FALLOCATE:
@@ -1033,15 +931,12 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_fallocate_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_fallocate_rsp;
 
-                client_post_fallocate (this, tmp_rsp,
-                                    &this_args_cbk->prestat,
-                                    &this_args_cbk->poststat,
-                                    &this_args_cbk->xdata);
+                client_post_fallocate (this, tmp_rsp, &this_args_cbk->prestat,
+                                       &this_args_cbk->poststat, &xdata);
 
                 CLIENT_POST_FOP_TYPE (fallocate, this_rsp, this_args_cbk,
                                       &this_args_cbk->prestat,
-                                      &this_args_cbk->poststat,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->poststat, xdata);
                 break;
         }
         case GF_FOP_DISCARD:
@@ -1049,15 +944,12 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_discard_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_discard_rsp;
 
-                client_post_discard (this, tmp_rsp,
-                                    &this_args_cbk->prestat,
-                                    &this_args_cbk->poststat,
-                                    &this_args_cbk->xdata);
+                client_post_discard (this, tmp_rsp, &this_args_cbk->prestat,
+                                     &this_args_cbk->poststat, &xdata);
 
                 CLIENT_POST_FOP_TYPE (discard, this_rsp, this_args_cbk,
                                       &this_args_cbk->prestat,
-                                      &this_args_cbk->poststat,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->poststat, xdata);
                 break;
         }
         case GF_FOP_ZEROFILL:
@@ -1065,15 +957,12 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_zerofill_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_zerofill_rsp;
 
-                client_post_zerofill (this, tmp_rsp,
-                                    &this_args_cbk->prestat,
-                                    &this_args_cbk->poststat,
-                                    &this_args_cbk->xdata);
+                client_post_zerofill (this, tmp_rsp, &this_args_cbk->prestat,
+                                      &this_args_cbk->poststat, &xdata);
 
                 CLIENT_POST_FOP_TYPE (zerofill, this_rsp, this_args_cbk,
                                       &this_args_cbk->prestat,
-                                      &this_args_cbk->poststat,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->poststat, xdata);
                 break;
         }
         case GF_FOP_IPC:
@@ -1081,10 +970,9 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_ipc_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_ipc_rsp;
 
-                client_post_ipc (this, tmp_rsp, &this_args_cbk->xdata);
+                client_post_ipc (this, tmp_rsp, &xdata);
 
-                CLIENT_POST_FOP_TYPE (ipc, this_rsp, this_args_cbk,
-                                 this_args_cbk->xdata);
+                CLIENT_POST_FOP_TYPE (ipc, this_rsp, this_args_cbk, xdata);
                 break;
         }
         case GF_FOP_SEEK:
@@ -1092,11 +980,10 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 gfs3_seek_rsp *tmp_rsp = NULL;
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_seek_rsp;
 
-                client_post_seek (this, tmp_rsp, &this_args_cbk->xdata);
+                client_post_seek (this, tmp_rsp, &xdata);
 
                 CLIENT_POST_FOP_TYPE (seek, this_rsp, this_args_cbk,
-                                 tmp_rsp->offset,
-                                 this_args_cbk->xdata);
+                                      tmp_rsp->offset, xdata);
                 break;
         }
         case GF_FOP_LEASE:
@@ -1105,16 +992,21 @@ client_process_response (call_frame_t *frame, xlator_t *this,
                 tmp_rsp = &this_rsp->compound_rsp_u.compound_lease_rsp;
 
                 client_post_lease (this, tmp_rsp, &this_args_cbk->lease,
-                                   &this_args_cbk->xdata);
+                                   &xdata);
 
                 CLIENT_POST_FOP_TYPE (lease, this_rsp, this_args_cbk,
-                                      &this_args_cbk->lease,
-                                      this_args_cbk->xdata);
+                                      &this_args_cbk->lease, xdata);
                 break;
         }
         default:
                 return -ENOTSUP;
         }
+
+        if (xdata)
+                dict_unref (xdata);
+        if (xattr)
+                dict_unref (xattr);
+        gf_dirent_free (&entries);
         return 0;
 }
 
@@ -1271,8 +1163,7 @@ client_handle_fop_requirements (xlator_t *this, call_frame_t *frame,
                 op_errno = client_pre_writev (this,
                            &this_req->compound_req_u.compound_write_req,
                            args->fd, iov_length (args->vector, args->count),
-                           args->offset,
-                           args->flags, args->xdata);
+                           args->offset, args->flags, &args->xdata);
 
                 if (op_errno) {
                         op_errno = -op_errno;
@@ -1739,6 +1630,7 @@ compound_request_cleanup (gfs3_compound_req *req)
                 }
         }
 
+        GF_FREE (req->compound_req_array.compound_req_array_val);
         return;
 }
 
@@ -1943,9 +1835,6 @@ client_compound_rsp_cleanup (gfs3_compound_rsp *rsp, int len)
                 case GF_FOP_FSTAT:
                         CLIENT_FOP_RSP_CLEANUP (rsp, fstat, i);
                         break;
-                case GF_FOP_LK:
-                        CLIENT_FOP_RSP_CLEANUP (rsp, lk, i);
-                        break;
                 case GF_FOP_LOOKUP:
                         CLIENT_FOP_RSP_CLEANUP (rsp, lookup, i);
                         break;
@@ -2008,27 +1897,34 @@ client_compound_rsp_cleanup (gfs3_compound_rsp *rsp, int len)
                         CLIENT_COMMON_RSP_CLEANUP (rsp, fentrylk, i);
                         break;
                 /* fops that need extra cleanup */
+                case GF_FOP_LK:
+                {
+                        CLIENT_FOP_RSP_CLEANUP (rsp, lk, i);
+                        gfs3_lk_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, lk);
+                        free (tmp_rsp->flock.lk_owner.lk_owner_val);
+                        break;
+                }
                 case GF_FOP_READLINK:
                 {
                         CLIENT_FOP_RSP_CLEANUP (rsp, readlink, i);
                         gfs3_readlink_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp,
-                                                     readlink);
+                                                                    readlink);
                         free (tmp_rsp->path);
                         break;
                 }
                 case GF_FOP_XATTROP:
                 {
-                        gfs3_xattrop_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp,
-                                                    xattrop);
                         CLIENT_FOP_RSP_CLEANUP (rsp, xattrop, i);
+                        gfs3_xattrop_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp,
+                                                                   xattrop);
                         free (tmp_rsp->dict.dict_val);
                         break;
                 }
                 case GF_FOP_FXATTROP:
                 {
-                        gfs3_fxattrop_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp,
-                                                     fxattrop);
                         CLIENT_FOP_RSP_CLEANUP (rsp, fxattrop, i);
+                        gfs3_fxattrop_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp,
+                                                                    fxattrop);
                         free (tmp_rsp->dict.dict_val);
                         break;
                 }
@@ -2036,7 +1932,7 @@ client_compound_rsp_cleanup (gfs3_compound_rsp *rsp, int len)
                 {
                         CLIENT_FOP_RSP_CLEANUP (rsp, readdir, i);
                         gfs3_readdir_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp,
-                                                    readdir);
+                                                                   readdir);
                         clnt_readdir_rsp_cleanup (tmp_rsp);
                         break;
                 }
@@ -2044,31 +1940,31 @@ client_compound_rsp_cleanup (gfs3_compound_rsp *rsp, int len)
                 {
                         CLIENT_FOP_RSP_CLEANUP (rsp, readdirp, i);
                         gfs3_readdirp_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp,
-                                                     readdirp);
+                                                                    readdirp);
                         clnt_readdirp_rsp_cleanup (tmp_rsp);
                         break;
                 }
                 case GF_FOP_GETXATTR:
                 {
-                        gfs3_getxattr_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp,
-                                                     getxattr);
                         CLIENT_FOP_RSP_CLEANUP (rsp, getxattr, i);
+                        gfs3_getxattr_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp,
+                                                                    getxattr);
                         free (tmp_rsp->dict.dict_val);
                         break;
                 }
                 case GF_FOP_FGETXATTR:
                 {
+                        CLIENT_FOP_RSP_CLEANUP (rsp, fgetxattr, i);
                         gfs3_fgetxattr_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp,
                                                       fgetxattr);
-                        CLIENT_FOP_RSP_CLEANUP (rsp, fgetxattr, i);
                         free (tmp_rsp->dict.dict_val);
                         break;
                 }
                 case GF_FOP_RCHECKSUM:
                 {
+                        CLIENT_FOP_RSP_CLEANUP (rsp, rchecksum, i);
                         gfs3_rchecksum_rsp *rck = &CPD_RSP_FIELD(this_rsp,
                                                   rchecksum);
-                        CLIENT_FOP_RSP_CLEANUP (rsp, rchecksum, i);
                         if (rck->strong_checksum.strong_checksum_val) {
                                 free (rck->strong_checksum.strong_checksum_val);
                         }
diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c
index a7b88ba..c2dadac 100644
--- a/xlators/protocol/client/src/client-rpc-fops.c
+++ b/xlators/protocol/client/src/client-rpc-fops.c
@@ -4342,7 +4342,7 @@ client3_3_writev (call_frame_t *frame, xlator_t *this, void *data)
         conf = this->private;
 
         ret = client_pre_writev (this, &req, args->fd, args->size,
-                                 args->offset, args->flags, args->xdata);
+                                 args->offset, args->flags, &args->xdata);
 
         if (ret) {
                 op_errno = -ret;
-- 
2.9.3