diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 57 |
1 files changed, 57 insertions, 0 deletions
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 */ { |