summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2012-03-25 22:48:09 +0530
committerVijay Bellur <vijay@gluster.com>2012-03-29 07:54:34 -0700
commitdb501c73701b620be67b4c33ea16cac983dcd9b1 (patch)
tree5aa40283902d47a826fee41e0a9b312b0da95290
parent2dea3b34755d9af1d1c1ffe517c6a087cf44512a (diff)
core: fix all the iobuf related refs and unrefs
reviewed the code against all the possible places where iobuf/iobref ref unref are present, and hopefully fixed most of the issues around memory leaks with respect to iobuf Change-Id: I9aa30326962991f8e23acedd389a0e962e097885 Signed-off-by: Amar Tumballi <amarts@redhat.com> BUG: 797875 Reviewed-on: http://review.gluster.com/2994 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--glusterfsd/src/glusterfsd-mgmt.c8
-rw-r--r--xlators/nfs/server/src/nlm4.c12
-rw-r--r--xlators/protocol/client/src/client-helpers.c2
-rw-r--r--xlators/protocol/client/src/client.c8
-rw-r--r--xlators/protocol/client/src/client3_1-fops.c129
5 files changed, 101 insertions, 58 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index 058236427b2..e2622d35d66 100644
--- a/glusterfsd/src/glusterfsd-mgmt.c
+++ b/glusterfsd/src/glusterfsd-mgmt.c
@@ -101,7 +101,6 @@ glusterfs_serialize_reply (rpcsvc_request_t *req, void *arg,
outmsg->iov_len = retlen;
ret:
if (retlen == -1) {
- iobuf_unref (iob);
iob = NULL;
}
@@ -123,7 +122,6 @@ glusterfs_submit_reply (rpcsvc_request_t *req, void *arg,
goto out;
}
-
if (!iobref) {
iobref = iobref_new ();
if (!iobref) {
@@ -149,7 +147,6 @@ glusterfs_submit_reply (rpcsvc_request_t *req, void *arg,
* we can safely unref the iob in the hope that RPC layer must have
* ref'ed the iob on receiving into the txlist.
*/
- iobuf_unref (iob);
if (ret == -1) {
gf_log (THIS->name, GF_LOG_ERROR, "Reply submission failed");
goto out;
@@ -157,10 +154,11 @@ glusterfs_submit_reply (rpcsvc_request_t *req, void *arg,
ret = 0;
out:
+ if (iob)
+ iobuf_unref (iob);
- if (new_iobref) {
+ if (new_iobref && iobref)
iobref_unref (iobref);
- }
return ret;
}
diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c
index 0aa1fc14489..d73d1bce41a 100644
--- a/xlators/nfs/server/src/nlm4.c
+++ b/xlators/nfs/server/src/nlm4.c
@@ -432,8 +432,6 @@ nlm4svc_submit_reply (rpcsvc_request_t *req, void *arg, nlm4_serializer sfunc)
/* Then, submit the message for transmission. */
ret = rpcsvc_submit_message (req, &outmsg, 1, NULL, 0, iobref);
- iobuf_unref (iob);
- iobref_unref (iobref);
if (ret == -1) {
gf_log (GF_NLM, GF_LOG_ERROR, "Reply submission failed");
goto ret;
@@ -441,6 +439,11 @@ nlm4svc_submit_reply (rpcsvc_request_t *req, void *arg, nlm4_serializer sfunc)
ret = 0;
ret:
+ if (iob)
+ iobuf_unref (iob);
+ if (iobref)
+ iobref_unref (iobref);
+
return ret;
}
@@ -1040,6 +1043,11 @@ nlm4svc_send_granted (nfs3_call_state_t *cs)
goto ret;
}
ret:
+ if (iobref)
+ iobref_unref (iobref);
+ if (iobuf)
+ iobuf_unref (iobuf);
+
rpc_clnt_unref (rpc_clnt);
nfs3_call_state_wipe (cs);
return;
diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c
index 8cf83fe3094..3ee3bba53a1 100644
--- a/xlators/protocol/client/src/client-helpers.c
+++ b/xlators/protocol/client/src/client-helpers.c
@@ -141,7 +141,7 @@ client_local_wipe (clnt_local_t *local)
iobref_unref (local->iobref);
}
- mem_put (local);
+ mem_put (local);
}
return 0;
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index 45d473fdbe7..9ce86b50900 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -258,7 +258,7 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame,
ret = 0;
- if (new_iobref != NULL)
+ if (new_iobref)
iobref_unref (new_iobref);
if (iobuf)
@@ -271,11 +271,11 @@ out:
cbkfn (&rpcreq, NULL, 0, frame);
- if (new_iobref != NULL) {
+ if (new_iobref)
iobref_unref (new_iobref);
- }
- iobuf_unref (iobuf);
+ if (iobuf)
+ iobuf_unref (iobuf);
return 0;
}
diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c
index e1c144a8a04..2cfa201ce65 100644
--- a/xlators/protocol/client/src/client3_1-fops.c
+++ b/xlators/protocol/client/src/client3_1-fops.c
@@ -117,11 +117,11 @@ client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame,
if (start_ping)
client_start_ping ((void *) this);
- if (new_iobref != NULL) {
+ if (new_iobref)
iobref_unref (new_iobref);
- }
- iobuf_unref (iobuf);
+ if (iobuf)
+ iobuf_unref (iobuf);
return ret;
@@ -129,11 +129,11 @@ unwind:
rpcreq.rpc_status = -1;
cbkfn (&rpcreq, NULL, 0, frame);
- if (new_iobref != NULL) {
+ if (new_iobref)
iobref_unref (new_iobref);
- }
- iobuf_unref (iobuf);
+ if (iobuf)
+ iobuf_unref (iobuf);
return ret;
}
@@ -2941,8 +2941,8 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this,
rsphdr->iov_base = iobuf_ptr (rsp_iobuf);
rsphdr->iov_len = iobuf_pagesize (rsp_iobuf);
count = 1;
- rsp_iobuf = NULL;
local->iobref = rsp_iobref;
+ rsp_iobuf = NULL;
rsp_iobref = NULL;
}
@@ -2967,13 +2967,14 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this,
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val) {
+ if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
- }
- if (rsp_iobref != NULL) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
+
+ if (rsp_iobuf)
+ iobuf_unref (rsp_iobuf);
return 0;
@@ -2984,13 +2985,11 @@ unwind:
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
- if (rsp_iobref != NULL) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
- if (rsp_iobuf != NULL) {
+ if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- }
return 0;
}
@@ -3900,6 +3899,7 @@ client3_1_readv (call_frame_t *frame, xlator_t *this,
iobref_add (rsp_iobref, rsp_iobuf);
iobuf_unref (rsp_iobuf);
+
rsp_vec.iov_base = iobuf_ptr (rsp_iobuf);
rsp_vec.iov_len = iobuf_pagesize (rsp_iobuf);
@@ -3939,15 +3939,19 @@ client3_1_readv (call_frame_t *frame, xlator_t *this,
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
+ if (rsp_iobuf)
+ iobuf_unref (rsp_iobuf);
+
+ if (rsp_iobref)
+ iobref_unref (rsp_iobref);
+
return 0;
unwind:
- if (rsp_iobuf) {
+ if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- }
- if (rsp_iobref) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
CLIENT_STACK_UNWIND (readv, frame, -1, op_errno, NULL, 0, NULL, NULL, NULL);
if (req.xdata.xdata_val)
@@ -4516,12 +4520,13 @@ client3_1_fgetxattr (call_frame_t *frame, xlator_t *this,
iobref_add (rsp_iobref, rsp_iobuf);
iobuf_unref (rsp_iobuf);
+
rsphdr = &vector[0];
rsphdr->iov_base = iobuf_ptr (rsp_iobuf);
rsphdr->iov_len = iobuf_pagesize (rsp_iobuf);;
count = 1;
- rsp_iobuf = NULL;
local->iobref = rsp_iobref;
+ rsp_iobuf = NULL;
rsp_iobref = NULL;
req.namelen = 1; /* Use it as a flag */
@@ -4549,17 +4554,22 @@ client3_1_fgetxattr (call_frame_t *frame, xlator_t *this,
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
+ if (rsp_iobuf)
+ iobuf_unref (rsp_iobuf);
+
+ if (rsp_iobref)
+ iobref_unref (rsp_iobref);
+
return 0;
unwind:
CLIENT_STACK_UNWIND (fgetxattr, frame, -1, op_errno, NULL, NULL);
- if (rsp_iobuf) {
+ if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- }
- if (rsp_iobref) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
+
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
@@ -4619,12 +4629,13 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
iobref_add (rsp_iobref, rsp_iobuf);
iobuf_unref (rsp_iobuf);
+
rsphdr = &vector[0];
rsphdr->iov_base = iobuf_ptr (rsp_iobuf);
rsphdr->iov_len = iobuf_pagesize (rsp_iobuf);
count = 1;
- rsp_iobuf = NULL;
local->iobref = rsp_iobref;
+ rsp_iobuf = NULL;
rsp_iobref = NULL;
if (!uuid_is_null (args->loc->inode->gfid))
@@ -4680,15 +4691,19 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
+ if (rsp_iobuf)
+ iobuf_unref (rsp_iobuf);
+
+ if (rsp_iobref)
+ iobref_unref (rsp_iobref);
+
return 0;
unwind:
- if (rsp_iobuf) {
+ if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- }
- if (rsp_iobref) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
CLIENT_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, NULL);
@@ -4746,12 +4761,13 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this,
iobref_add (rsp_iobref, rsp_iobuf);
iobuf_unref (rsp_iobuf);
+
rsphdr = &vector[0];
rsphdr->iov_base = iobuf_ptr (rsp_iobuf);
rsphdr->iov_len = iobuf_pagesize (rsp_iobuf);
count = 1;
- rsp_iobuf = NULL;
local->iobref = rsp_iobref;
+ rsp_iobuf = NULL;
rsp_iobref = NULL;
if (!uuid_is_null (args->loc->inode->gfid))
@@ -4792,6 +4808,12 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this,
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
+ if (rsp_iobuf)
+ iobuf_unref (rsp_iobuf);
+
+ if (rsp_iobref)
+ iobref_unref (rsp_iobref);
+
return 0;
unwind:
CLIENT_STACK_UNWIND (xattrop, frame, -1, op_errno, NULL, NULL);
@@ -4800,13 +4822,12 @@ unwind:
GF_FREE (req.dict.dict_val);
}
- if (rsp_iobuf) {
+ if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- }
- if (rsp_iobref) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
+
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
@@ -4870,8 +4891,8 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this,
rsphdr->iov_base = iobuf_ptr (rsp_iobuf);
rsphdr->iov_len = iobuf_pagesize (rsp_iobuf);
count = 1;
- rsp_iobuf = NULL;
local->iobref = rsp_iobref;
+ rsp_iobuf = NULL;
rsp_iobref = NULL;
if (args->xattr) {
@@ -4900,6 +4921,12 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this,
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
+ if (rsp_iobuf)
+ iobuf_unref (rsp_iobuf);
+
+ if (rsp_iobref)
+ iobref_unref (rsp_iobref);
+
return 0;
unwind:
CLIENT_STACK_UNWIND (fxattrop, frame, -1, op_errno, NULL, NULL);
@@ -5488,12 +5515,14 @@ client3_1_readdir (call_frame_t *frame, xlator_t *this,
iobref_add (rsp_iobref, rsp_iobuf);
iobuf_unref (rsp_iobuf);
+
rsphdr = &vector[0];
rsphdr->iov_base = iobuf_ptr (rsp_iobuf);
rsphdr->iov_len = iobuf_pagesize (rsp_iobuf);
count = 1;
- rsp_iobuf = NULL;
local->iobref = rsp_iobref;
+ rsp_iobuf = NULL;
+ rsp_iobref = NULL;
}
req.size = args->size;
@@ -5512,7 +5541,6 @@ client3_1_readdir (call_frame_t *frame, xlator_t *this,
rsphdr, count,
NULL, 0, rsp_iobref,
(xdrproc_t)xdr_gfs3_readdir_req);
- rsp_iobref = NULL;
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
@@ -5521,16 +5549,20 @@ client3_1_readdir (call_frame_t *frame, xlator_t *this,
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
+ if (rsp_iobuf)
+ iobuf_unref (rsp_iobuf);
+
+ if (rsp_iobref)
+ iobref_unref (rsp_iobref);
+
return 0;
unwind:
- if (rsp_iobref != NULL) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
- if (rsp_iobuf != NULL) {
+ if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- }
CLIENT_STACK_UNWIND (readdir, frame, -1, op_errno, NULL, NULL);
if (req.xdata.xdata_val)
@@ -5595,12 +5627,13 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this,
iobref_add (rsp_iobref, rsp_iobuf);
iobuf_unref (rsp_iobuf);
+
rsphdr = &vector[0];
rsphdr->iov_base = iobuf_ptr (rsp_iobuf);
rsphdr->iov_len = iobuf_pagesize (rsp_iobuf);
count = 1;
- rsp_iobuf = NULL;
local->iobref = rsp_iobref;
+ rsp_iobuf = NULL;
rsp_iobref = NULL;
}
@@ -5628,15 +5661,19 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this,
if (req.dict.dict_val)
GF_FREE (req.dict.dict_val);
+ if (rsp_iobuf)
+ iobuf_unref (rsp_iobuf);
+
+ if (rsp_iobref)
+ iobref_unref (rsp_iobref);
+
return 0;
unwind:
- if (rsp_iobref) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
- if (rsp_iobuf) {
+ if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- }
if (req.dict.dict_val)
GF_FREE (req.dict.dict_val);