From e2b2ac48e3c5e38fd980344ac52f1be8658e1418 Mon Sep 17 00:00:00 2001 From: Vishwanath S Bhat Date: Thu, 4 Aug 2011 12:56:58 +0530 Subject: Removes hardcoding of the transport type in replace-brick operations. Replace-brick didn't work in volume with rdma transport type. Change-Id: Ib4654bae8aa035050f7e4718c4d29174b7db74b3 BUG: 3092 Testcase: Replace-brick should succeed in volume with rdma transport type. Reviewed-on: http://review.gluster.com/133 Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 40 +++++++++++++++++------- xlators/mgmt/glusterd/src/glusterd-volgen.c | 48 +++++++++++++++++++++++------ xlators/mgmt/glusterd/src/glusterd-volgen.h | 2 ++ 3 files changed, 69 insertions(+), 21 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index e9cc4686f38..785736bcc7c 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -2973,6 +2973,7 @@ static const char *client_volfile_str = "volume mnt-client\n" " option remote-host %s\n" " option remote-subvolume %s\n" " option remote-port %d\n" + " option transport-type %s\n" "end-volume\n" "volume mnt-wb\n" " type performance/write-behind\n" @@ -2983,10 +2984,11 @@ static int rb_generate_client_volfile (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *src_brickinfo) { - glusterd_conf_t *priv = NULL; - FILE *file = NULL; - char filename[PATH_MAX]; - int ret = -1; + glusterd_conf_t *priv = NULL; + FILE *file = NULL; + char filename[PATH_MAX] = {0, }; + int ret = -1; + char *ttype = NULL; priv = THIS->private; @@ -3007,10 +3009,17 @@ rb_generate_client_volfile (glusterd_volinfo_t *volinfo, GF_ASSERT (src_brickinfo->port); + ttype = glusterd_get_trans_type_rb (volinfo->transport_type); + if (NULL == ttype){ + ret = -1; + goto out; + } + fprintf (file, client_volfile_str, src_brickinfo->hostname, - src_brickinfo->path, src_brickinfo->port); + src_brickinfo->path, src_brickinfo->port, ttype); fclose (file); + GF_FREE (ttype); ret = 0; @@ -3029,7 +3038,7 @@ static const char *dst_brick_volfile_str = "volume src-posix\n" "volume src-server\n" " type protocol/server\n" " option auth.addr.%s.allow *\n" - " option transport-type tcp\n" + " option transport-type %s\n" " subvolumes %s\n" "end-volume\n"; @@ -3037,10 +3046,11 @@ static int rb_generate_dst_brick_volfile (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *dst_brickinfo) { - glusterd_conf_t *priv = NULL; - FILE *file = NULL; - char filename[PATH_MAX]; - int ret = -1; + glusterd_conf_t *priv = NULL; + FILE *file = NULL; + char filename[PATH_MAX] = {0, }; + int ret = -1; + char *ttype = NULL; priv = THIS->private; @@ -3059,9 +3069,17 @@ rb_generate_dst_brick_volfile (glusterd_volinfo_t *volinfo, goto out; } + ttype = glusterd_get_trans_type_rb (volinfo->transport_type); + if (NULL == ttype){ + ret = -1; + goto out; + } + fprintf (file, dst_brick_volfile_str, dst_brickinfo->path, dst_brickinfo->path, dst_brickinfo->path, - dst_brickinfo->path); + ttype, dst_brickinfo->path); + + GF_FREE (ttype); fclose (file); diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index f9c42a4618c..cc4512d821d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1012,6 +1012,27 @@ glusterd_check_option_exists (char *key, char **completion) return ret; } +char* +glusterd_get_trans_type_rb (gf_transport_type ttype) +{ + char *trans_type = NULL; + + switch (ttype) { + case GF_TRANSPORT_RDMA: + gf_asprintf (&trans_type, "rdma"); + break; + case GF_TRANSPORT_TCP: + case GF_TRANSPORT_BOTH_TCP_RDMA: + gf_asprintf (&trans_type, "tcp"); + break; + default: + gf_log (THIS->name, GF_LOG_ERROR, "Unknown " + "transport type"); + } + + return trans_type; +} + static int volgen_graph_merge_sub (volgen_graph_t *dgraph, volgen_graph_t *sgraph) { @@ -1310,16 +1331,17 @@ static int server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, dict_t *set_dict, void *param) { - char *volname = NULL; - char *path = NULL; - int pump = 0; - xlator_t *xl = NULL; - xlator_t *txl = NULL; - xlator_t *rbxl = NULL; - char transt[16] = {0,}; - char volume_id[64] = {0,}; + char *volname = NULL; + char *path = NULL; + int pump = 0; + xlator_t *xl = NULL; + xlator_t *txl = NULL; + xlator_t *rbxl = NULL; + char transt[16] = {0,}; + char *ptranst = NULL; + char volume_id[64] = {0,}; char tstamp_file[PATH_MAX] = {0,}; - int ret = 0; + int ret = 0; path = param; volname = volinfo->volname; @@ -1357,7 +1379,13 @@ server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, "%s-replace-brick", volname); if (!rbxl) return -1; - ret = xlator_set_option (rbxl, "transport-type", transt); + + ptranst = glusterd_get_trans_type_rb (volinfo->transport_type); + if (NULL == ptranst) + return -1; + + ret = xlator_set_option (rbxl, "transport-type", ptranst); + GF_FREE (ptranst); if (ret) return -1; xl = volgen_graph_add_nolink (graph, "cluster/pump", "%s-pump", diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h index 3cf2e87b9bb..30245414588 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.h +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h @@ -64,4 +64,6 @@ gf_boolean_t glusterd_check_voloption_flags (char *key, int32_t flags); int generate_brick_volfiles (glusterd_volinfo_t *volinfo); +char* +glusterd_get_trans_type_rb (gf_transport_type ttype); #endif -- cgit