summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2014-09-25 16:27:52 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2014-09-26 03:06:35 -0700
commit5123949bebc3520ed3d64986420c139801013c60 (patch)
treef2c80727f1dddcc9bb5a1c83655f38fec1060992 /xlators/cluster
parentc3101c66ba09a8e80eefeb68cf5ca1ab78dd8cae (diff)
cluster/afr: More dict_t leak fixes
Change-Id: I6618b7b2df0f88a3e6252f9136135cf402147a37 BUG: 1134221 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/8852 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-metadata.c16
-rw-r--r--xlators/cluster/afr/src/afr-self-heald.c85
2 files changed, 68 insertions, 33 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c
index 5b9e290e49a..b4714fe9e05 100644
--- a/xlators/cluster/afr/src/afr-self-heal-metadata.c
+++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c
@@ -42,14 +42,19 @@ __afr_selfheal_metadata_do (call_frame_t *frame, xlator_t *this, inode_t *inode,
ret = syncop_getxattr (priv->children[source], &loc, &xattr, NULL);
if (ret < 0) {
- loc_wipe (&loc);
- return -EIO;
+ ret = -EIO;
+ goto out;
}
afr_filter_xattrs (xattr);
dict_del (xattr, GF_SELINUX_XATTR_KEY);
for (i = 0; i < priv->child_count; i++) {
+ if (old_xattr) {
+ dict_unref (old_xattr);
+ old_xattr = NULL;
+ }
+
if (!healed_sinks[i])
continue;
@@ -59,7 +64,6 @@ __afr_selfheal_metadata_do (call_frame_t *frame, xlator_t *this, inode_t *inode,
if (ret)
healed_sinks[i] = 0;
- old_xattr = NULL;
ret = syncop_getxattr (priv->children[i], &loc, &old_xattr, 0);
if (old_xattr) {
dict_del (old_xattr, GF_SELINUX_XATTR_KEY);
@@ -72,12 +76,16 @@ __afr_selfheal_metadata_do (call_frame_t *frame, xlator_t *this, inode_t *inode,
if (ret)
healed_sinks[i] = 0;
}
+ ret = 0;
+out:
loc_wipe (&loc);
if (xattr)
dict_unref (xattr);
+ if (old_xattr)
+ dict_unref (old_xattr);
- return 0;
+ return ret;
}
diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
index 9dc785c967c..9627b906b56 100644
--- a/xlators/cluster/afr/src/afr-self-heald.c
+++ b/xlators/cluster/afr/src/afr-self-heald.c
@@ -92,20 +92,31 @@ afr_shd_is_subvol_local (xlator_t *this, int subvol)
ret = syncop_getxattr (priv->children[subvol], &loc, &xattr,
GF_XATTR_PATHINFO_KEY);
- if (ret)
- return _gf_false;
- if (!xattr)
- return _gf_false;
+ if (ret) {
+ is_local = _gf_false;
+ goto out;
+ }
+
+ if (!xattr) {
+ is_local = _gf_false;
+ goto out;
+ }
ret = dict_get_str (xattr, GF_XATTR_PATHINFO_KEY, &pathinfo);
- if (ret)
- return _gf_false;
+ if (ret) {
+ is_local = _gf_false;
+ goto out;
+ }
afr_local_pathinfo (pathinfo, &is_local);
gf_log (this->name, GF_LOG_DEBUG, "subvol %s is %slocal",
priv->children[subvol]->name, is_local? "" : "not ");
+out:
+ if (xattr)
+ dict_unref (xattr);
+
return is_local;
}
@@ -864,27 +875,38 @@ out:
int
afr_shd_gfid_to_path (xlator_t *this, xlator_t *subvol, uuid_t gfid, char **path_p)
{
- loc_t loc = {0,};
- char *path = NULL;
- dict_t *xattr = NULL;
- int ret = 0;
+ int ret = 0;
+ char *path = NULL;
+ loc_t loc = {0,};
+ dict_t *xattr = NULL;
uuid_copy (loc.gfid, gfid);
loc.inode = inode_new (this->itable);
ret = syncop_getxattr (subvol, &loc, &xattr, GFID_TO_PATH_KEY);
- loc_wipe (&loc);
if (ret)
- return ret;
+ goto out;
ret = dict_get_str (xattr, GFID_TO_PATH_KEY, &path);
- if (ret || !path)
- return -EINVAL;
+ if (ret || !path) {
+ ret = -EINVAL;
+ goto out;
+ }
*path_p = gf_strdup (path);
- if (!*path_p)
- return -ENOMEM;
- return 0;
+ if (!*path_p) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ if (xattr)
+ dict_unref (xattr);
+ loc_wipe (&loc);
+
+ return ret;
}
@@ -1089,12 +1111,11 @@ afr_selfheal_childup (xlator_t *this, int subvol)
}
-int64_t
-afr_shd_get_index_count (xlator_t *this, int i)
+int
+afr_shd_get_index_count (xlator_t *this, int i, uint64_t *count)
{
afr_private_t *priv = NULL;
xlator_t *subvol = NULL;
- uint64_t count = 0;
loc_t rootloc = {0, };
dict_t *xattr = NULL;
int ret = -1;
@@ -1107,15 +1128,21 @@ afr_shd_get_index_count (xlator_t *this, int i)
ret = syncop_getxattr (subvol, &rootloc, &xattr,
GF_XATTROP_INDEX_COUNT);
- loc_wipe (&rootloc);
-
if (ret < 0)
- return -1;
+ goto out;
- ret = dict_get_uint64 (xattr, GF_XATTROP_INDEX_COUNT, &count);
+ ret = dict_get_uint64 (xattr, GF_XATTROP_INDEX_COUNT, count);
if (ret)
- return -1;
- return count;
+ goto out;
+
+ ret = 0;
+
+out:
+ if (xattr)
+ dict_unref (xattr);
+ loc_wipe (&rootloc);
+
+ return ret;
}
@@ -1131,7 +1158,7 @@ afr_xl_op (xlator_t *this, dict_t *input, dict_t *output)
int i = 0;
char key[64];
int op_ret = 0;
- int64_t cnt = 0;
+ uint64_t cnt = 0;
priv = this->private;
shd = &priv->shd;
@@ -1239,8 +1266,8 @@ afr_xl_op (xlator_t *this, dict_t *input, dict_t *output)
} else {
snprintf (key, sizeof (key), "%d-%d-hardlinks",
xl_id, i);
- cnt = afr_shd_get_index_count (this, i);
- if (cnt >= 0) {
+ ret = afr_shd_get_index_count (this, i, &cnt);
+ if (ret == 0) {
ret = dict_set_uint64 (output, key, cnt);
}
op_ret = 0;