diff options
author | Avra Sengupta <asengupt@redhat.com> | 2016-10-18 12:52:36 +0530 |
---|---|---|
committer | Rajesh Joseph <rjoseph@redhat.com> | 2016-11-03 23:05:16 -0700 |
commit | 2328a1ca2cab00711efe8f256e532952280f6570 (patch) | |
tree | 82c3969eadb0ad63ae38db185aa90435d117f32c /xlators | |
parent | b0f4fc9d05a1e5169205b88e81ca0fbdd28b3dd2 (diff) |
snapshot: Fix for memory leaks in snapshot code path
> Reviewed-on: http://review.gluster.org/15668
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
(cherry picked from commit 48a4c4e525665115f7e8c478d3bf51764427378d)
Change-Id: Idc2cb16574d166e3c0ee1f7c3a485f1acb19fc8c
BUG: 1388354
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-on: http://review.gluster.org/15720
Smoke: Gluster Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-mgmt.c | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 38 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 17 |
3 files changed, 47 insertions, 12 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c index 092283a7daf..6d90ecae3b1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c @@ -1321,6 +1321,10 @@ out: gd_mgmt_v3_collate_errors (args, op_ret, op_errno, rsp.op_errstr, GLUSTERD_MGMT_V3_COMMIT, *peerid, rsp.uuid); GF_FREE (peerid); + + if (rsp.op_errstr) + free (rsp.op_errstr); + /* req->rpc_status set to -1 means, STACK_DESTROY will be called from * the caller function. */ diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 6e4894b7344..05112763b88 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -2105,6 +2105,7 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, int clone, uint32_t *op_errno) { char *device = NULL; + char *orig_device = NULL; char key[PATH_MAX] = ""; int ret = -1; int64_t i = 1; @@ -2170,9 +2171,9 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, } - device = glusterd_get_brick_mount_device - (brickinfo->path); - if (!device) { + orig_device = glusterd_get_brick_mount_device + (brickinfo->path); + if (!orig_device) { snprintf (err_str, PATH_MAX, "getting device name for the brick " "%s:%s failed", brickinfo->hostname, @@ -2181,7 +2182,7 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, goto out; } if (!clone) { - if (!glusterd_is_thinp_brick (device, op_errno)) { + if (!glusterd_is_thinp_brick (orig_device, op_errno)) { snprintf (err_str, PATH_MAX, "Snapshot is supported only for " "thin provisioned LV. Ensure that " @@ -2189,10 +2190,10 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, "provisioned LV.", volinfo->volname); ret = -1; goto out; - } + } } - device = glusterd_build_snap_device_path (device, + device = glusterd_build_snap_device_path (orig_device, snap_volname, brick_count); if (!device) { @@ -2205,18 +2206,19 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, goto out; } + GF_FREE(orig_device); + orig_device = NULL; + snprintf (key, sizeof(key), "vol%"PRId64".brick_snapdevice%"PRId64, i, brick_count); - ret = dict_set_dynstr (rsp_dict, key, device); + ret = dict_set_dynstr_with_alloc (rsp_dict, key, device); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, "Failed to set %s", key); - GF_FREE (device); goto out; } - device = NULL; ret = glusterd_update_mntopts (brickinfo->path, brickinfo); @@ -2286,6 +2288,10 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, } brick_count++; brick_order++; + if (device) { + GF_FREE(device); + device = NULL; + } } snprintf (key, sizeof(key) - 1, "vol%"PRId64"_brickcount", volcount); ret = dict_set_int64 (rsp_dict, key, brick_count); @@ -2297,8 +2303,11 @@ glusterd_snap_create_clone_common_prevalidate (dict_t *rsp_dict, int flags, } ret = 0; out: + if (orig_device) + GF_FREE(orig_device); + if (device) - GF_FREE (device); + GF_FREE (device); return ret; @@ -2831,6 +2840,9 @@ glusterd_do_lvm_snapshot_remove (glusterd_volinfo_t *snap_vol, } out: + if (mnt_pt) + GF_FREE(mnt_pt); + return ret; } @@ -4725,6 +4737,9 @@ glusterd_take_lvm_snapshot (glusterd_brickinfo_t *brickinfo, } out: + if (origin_device) + GF_FREE (origin_device); + return ret; } @@ -7391,6 +7406,9 @@ out: GF_FREE (value); } + if (device) + GF_FREE (device); + return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 5bfa809b053..e89ed1102fe 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -865,6 +865,8 @@ glusterd_brickinfo_delete (glusterd_brickinfo_t *brickinfo) cds_list_del_init (&brickinfo->brick_list); + (void) gf_store_handle_destroy (brickinfo->shandle); + GF_FREE (brickinfo->logfile); GF_FREE (brickinfo); @@ -926,6 +928,9 @@ glusterd_volinfo_delete (glusterd_volinfo_t *volinfo) dict_unref (volinfo->rebal.dict); gf_store_handle_destroy (volinfo->quota_conf_shandle); + gf_store_handle_destroy (volinfo->shandle); + gf_store_handle_destroy (volinfo->node_state_shandle); + gf_store_handle_destroy (volinfo->snapd.handle); glusterd_auth_cleanup (volinfo); @@ -1054,6 +1059,9 @@ glusterd_get_brick_mount_dir (char *brickpath, char *hostname, char *mount_dir) } out: + if (mnt_pt) + GF_FREE(mnt_pt); + gf_msg_trace (this->name, 0, "Returning %d", ret); return ret; } @@ -5601,7 +5609,8 @@ glusterd_add_brick_mount_details (glusterd_brickinfo_t *brickinfo, ret = dict_set_dynstr_with_alloc (dict, key, entry->mnt_opts); out: - GF_FREE (mnt_pt); + if (mnt_pt) + GF_FREE (mnt_pt); return ret; } @@ -5644,6 +5653,9 @@ glusterd_get_brick_mount_device (char *brick_path) device = gf_strdup (entry->mnt_fsname); out: + if (mnt_pt) + GF_FREE(mnt_pt); + return device; } @@ -10848,7 +10860,8 @@ glusterd_update_mntopts (char *brick_path, glusterd_brickinfo_t *brickinfo) ret = 0; out: - GF_FREE (mnt_pt); + if (mnt_pt) + GF_FREE (mnt_pt); return ret; } |