From 692dd7e83cc8a1c85581dda3f752d5ea3b184f8c Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Mon, 24 Nov 2014 17:07:02 +0530 Subject: cli: volume status for tcp,rdma type volume display only tcp port For tcp,rdma type voumes, there will be two ports, one for tcp and one for rdma. But volume status command only display tcp port. By this change, adding an extra column for rdma port and changing the port to tcp port. Eg: >gluster volume status pathy >For tcp,rdma type volume Status of volume: patchy Gluster process TCP Port RDMA Port Online Pid ------------------------------------------------------------------------------ Brick brickname 49152 49153 Y 14158 >For rdma type volume Status of volume: patchy Gluster process TCP Port RDMA Port Online Pid ------------------------------------------------------------------------------ Brick brickname 0 49153 Y 14158 For tcp type volume Status of volume: patchy Gluster process TCP Port RDMA Port Online Pid ------------------------------------------------------------------------------ Brick brickname 49152 0 Y 14158 >gluster volume status patchy detail Status of volume: xcube2 ------------------------------------------------------------------------------ Brick : Brick brickname TCP Port : 49152 RDMA Port : 49153 Online : Y Pid : 14158 File System : ext4 Device : /dev/mapper/luks-2099dd4a-0050-4cae-ad7b-c6a0498c4e88 Mount Options : rw,seclabel,relatime,data=ordered Inode Size : 256 Disk Space Free : 31.1GB Total Disk Space : 47.9GB Inode Count : 3203072 Free Inodes : 2926789 >gluster volume status xcube --xml 0 0 (null) xcube 2 hostname /home/brick1 2d7bcb95-3d26-4d4f-b3c6-e2ee01b71662 1 49152 49152 N/A 5657 NFS Server localhost 2d7bcb95-3d26-4d4f-b3c6-e2ee01b71662 1 2049 2049 N/A 5665 Change-Id: I81aab226edbd400d29cd3f510af4f344dd99ba51 BUG: 1164079 Signed-off-by: Mohammed Rafi KC Reviewed-on: http://review.gluster.org/9191 Reviewed-by: Atin Mukherjee Tested-by: Gluster Build System Reviewed-by: Kaushal M --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 57 ++++++++++++++++++++++++++++++ xlators/mgmt/glusterd/src/glusterd-utils.c | 16 ++++++++- 2 files changed, 72 insertions(+), 1 deletion(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 9352b9accab..93585e3db0c 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -3752,6 +3752,42 @@ glusterd_is_volume_status_modify_op_ctx (uint32_t cmd) return _gf_false; } +int +glusterd_op_modify_port_key (dict_t *op_ctx, int brick_index_max) +{ + char *port = NULL; + int i = 0; + int ret = -1; + char key[1024] = {0}; + char old_key[1024] = {0}; + + for (i = 0; i <= brick_index_max; i++) { + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "brick%d.rdma_port", i); + ret = dict_get_str (op_ctx, key, &port); + + if (ret) { + + memset (old_key, 0, sizeof (old_key)); + snprintf (old_key, sizeof (old_key), + "brick%d.port", i); + ret = dict_get_str (op_ctx, old_key, &port); + if (ret) + goto out; + + ret = dict_set_str (op_ctx, key, port); + if (ret) + goto out; + ret = dict_set_str (op_ctx, old_key, "\0"); + if (ret) + goto out; + } + } +out: + return ret; +} + /* This function is used to modify the op_ctx dict before sending it back * to cli. This is useful in situations like changing the peer uuids to * hostnames etc. @@ -3766,9 +3802,13 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) int count = 0; uint32_t cmd = GF_CLI_STATUS_NONE; xlator_t *this = NULL; + glusterd_conf_t *conf = NULL; + char *volname = NULL; + glusterd_volinfo_t *volinfo = NULL; this = THIS; GF_ASSERT (this); + conf = this->private; if (ctx) op_ctx = ctx; @@ -3814,6 +3854,23 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) count = brick_index_max + other_count + 1; + /* + * a glusterd lesser than version 3.7 will be sending the + * rdma port in older key. Changing that value from here + * to support backward compatibility + */ + ret = dict_get_str (op_ctx, "volname", &volname); + if (ret) + goto out; + + glusterd_volinfo_find (volname, &volinfo); + if (conf->op_version < GD_OP_VERSION_3_7_0 && + volinfo->transport_type == GF_TRANSPORT_RDMA) { + ret = glusterd_op_modify_port_key (op_ctx, + brick_index_max); + if (ret) + goto out; + } /* add 'brick%d.peerid' into op_ctx with value of 'brick%d.path'. nfs/sshd like services have this additional uuid */ { diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 9ff7bf2347b..5d28dc24e45 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -6112,10 +6112,24 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo, memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.port", base_key); - ret = dict_set_int32 (dict, key, brickinfo->port); + ret = dict_set_int32 (dict, key, (volinfo->transport_type == + GF_TRANSPORT_RDMA) ? 0 : brickinfo->port); if (ret) goto out; + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s.rdma_port", base_key); + if (volinfo->transport_type == GF_TRANSPORT_RDMA) { + ret = dict_set_int32 (dict, key, brickinfo->port); + } else if (volinfo->transport_type == GF_TRANSPORT_BOTH_TCP_RDMA) { + ret = dict_set_int32 (dict, key, brickinfo->rdma_port); + } else + ret = dict_set_int32 (dict, key, 0); + + if (ret) + goto out; + + GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv); brick_online = gf_is_service_running (pidfile, &pid); -- cgit