From 0e1679aee746040cdd509c5cd4004a4641c4c203 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Fri, 13 Jan 2012 18:21:39 +0530 Subject: cli,glusterd: Display volume UUID in the output of 'volume info' Cleaned up some leaks along the way. Change-Id: Ibc76c539eee935c0630f9580d0d914814b1a6fe1 BUG: 781445 Signed-off-by: Vijay Bellur Reviewed-on: http://review.gluster.com/2643 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- cli/src/cli-cmd-volume.c | 3 +++ cli/src/cli-rpc-ops.c | 20 ++++++++++++++++++++ xlators/mgmt/glusterd/src/glusterd-handler.c | 10 ++++++++++ 3 files changed, 33 insertions(+) diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 38c16797ea1..a572bdc3f48 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -105,6 +105,9 @@ out: cli_out ("Getting Volume information failed!"); } + if (frame) + FRAME_DESTROY (frame); + return ret; } diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 06c52dac186..a01eb6f3678 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -408,6 +408,7 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov, int opt_count = 0; int k = 0; char err_str[2048] = {0}; + char *volume_id_str = NULL; snprintf (err_str, sizeof (err_str), "Volume info unsuccessful"); if (-1 == req->rpc_status) { @@ -462,6 +463,7 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov, if (!count && (local->get_vol.flags == GF_CLI_GET_NEXT_VOLUME)) { + GF_FREE (local->get_vol.volname); local->get_vol.volname = NULL; ret = 0; goto out; @@ -516,6 +518,11 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov, if (ret) goto out; + snprintf (key, 256, "volume%d.volume_id", i); + ret = dict_get_str (dict, key, &volume_id_str); + if (ret) + goto out; + vol_type = type; // Distributed (stripe/replicate/stripe-replica) setups @@ -524,6 +531,7 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov, cli_out ("Volume Name: %s", volname); cli_out ("Type: %s", cli_volume_type[vol_type]); + cli_out ("Volume ID: %s", volume_id_str); cli_out ("Status: %s", cli_volume_status[status]); if (type == GF_CLUSTER_TYPE_STRIPE_REPLICATE) @@ -621,6 +629,12 @@ out: if (dict) dict_destroy (dict); + if (rsp.dict.dict_val) + free (rsp.dict.dict_val); + + if (rsp.op_errstr) + free (rsp.op_errstr); + gf_log ("", GF_LOG_INFO, "Returning: %d", ret); return ret; } @@ -1987,6 +2001,12 @@ gf_cli3_1_get_volume (call_frame_t *frame, xlator_t *this, (xdrproc_t) xdr_gf_cli_req); out: + if (dict) + dict_unref (dict); + + if (req.dict.dict_val) + GF_FREE (req.dict.dict_val); + gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 7817e1dd653..4766aa19a6c 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -287,6 +287,7 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, data_t *value = NULL; int opt_count = 0; glusterd_conf_t *priv = NULL; + char *volume_id_str = NULL; GF_ASSERT (volinfo); @@ -336,6 +337,15 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; + volume_id_str = gf_strdup (uuid_utoa (volinfo->volume_id)); + if (!volume_id_str) + goto out; + + snprintf (key, sizeof (key), "volume%d.volume_id", count); + ret = dict_set_dynstr (volumes, key, volume_id_str); + if (ret) + goto out; + list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { char brick[1024] = {0,}; snprintf (key, 256, "volume%d.brick%d", count, i); -- cgit