summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kp@gluster.com>2012-05-03 16:29:06 +0530
committerVijay Bellur <vbellur@redhat.com>2013-01-04 08:49:43 -0800
commitd3cc5862faa9ebda4d8d80f6b3e7a45c0df85c0c (patch)
tree0f646a3c2167eda09aa2c6ce699e7e42ac3b2326 /xlators/mgmt/glusterd/src/glusterd-replace-brick.c
parent129728f257bead0ce0c28b98d3989fabaebe21cd (diff)
glusterd: Made dst brick's port info available to all peers
Change-Id: I1f65743a31d95013fdf22cded91c314e9934a3a9 BUG: 816915 Signed-off-by: Krishnan Parthasarathi <kp@gluster.com> Reviewed-on: http://review.gluster.org/3275 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-replace-brick.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c62
1 files changed, 40 insertions, 22 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index 94f498d33bc..5948251201a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -193,6 +193,7 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
dict_t *rsp_dict)
{
int ret = 0;
+ int32_t port = 0;
char *src_brick = NULL;
char *dst_brick = NULL;
char *volname = NULL;
@@ -350,6 +351,7 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
}
}
break;
+
case GF_REPLACE_OP_PAUSE:
if (glusterd_is_rb_paused (volinfo)) {
gf_log (this->name, GF_LOG_ERROR, "Replace brick is "
@@ -540,6 +542,28 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
goto out;
}
}
+
+ if (replace_op == GF_REPLACE_OP_START &&
+ !glusterd_is_local_addr (volinfo->rep_brick.dst_brick->hostname)) {
+ port = pmap_registry_alloc (THIS);
+ if (!port) {
+ gf_log (THIS->name, GF_LOG_CRITICAL,
+ "No free ports available");
+ ret = -1;
+ goto out;
+ }
+
+ ctx = glusterd_op_get_ctx();
+ ret = dict_set_int32 ((ctx)?ctx:rsp_dict, "dst-brick-port",
+ port);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "Failed to set dst "
+ "brick port");
+ goto out;
+ }
+ volinfo->rep_brick.dst_brick->port = port;
+ }
+
ret = 0;
out:
@@ -708,9 +732,7 @@ rb_spawn_dst_brick (glusterd_volinfo_t *volinfo,
priv = THIS->private;
- port = pmap_registry_alloc (THIS);
- brickinfo->port = port;
-
+ port = brickinfo->port;
GF_ASSERT (port);
runinit (&runner);
@@ -726,6 +748,8 @@ rb_spawn_dst_brick (glusterd_volinfo_t *volinfo,
ret = runner_run (&runner);
if (ret) {
+ pmap_registry_remove (THIS, 0, brickinfo->path,
+ GF_PMAP_PORT_BRICKSERVER, NULL);
gf_log ("", GF_LOG_DEBUG,
"Could not start glusterfs");
goto out;
@@ -1002,7 +1026,7 @@ rb_mountpoint_rmdir (glusterd_volinfo_t *volinfo,
GLUSTERD_GET_RB_MNTPT (mntpt, sizeof (mntpt), volinfo);
ret = rmdir (mntpt);
if (ret) {
- gf_log ("", GF_LOG_DEBUG, "rmdir failed, due to %s",
+ gf_log ("", GF_LOG_DEBUG, "rmdir failed, reason: %s",
strerror (errno));
goto out;
}
@@ -1049,8 +1073,8 @@ rb_destroy_maintenance_client (glusterd_volinfo_t *volinfo,
ret = unlink (volfile);
if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, "unlink of volfile %s "
- "failed", volfile);
+ gf_log ("", GF_LOG_DEBUG, "unlink of %s failed, reason: %s",
+ volfile, strerror (errno));
goto out;
}
@@ -1375,12 +1399,9 @@ rb_update_srcbrick_port (glusterd_brickinfo_t *src_brickinfo, dict_t *rsp_dict,
this = THIS;
- ctx = glusterd_op_get_ctx ();
- if (ctx) {
- dict_ret = dict_get_int32 (req_dict, "src-brick-port", &src_port);
- if (src_port)
- src_brickinfo->port = src_port;
- }
+ dict_ret = dict_get_int32 (req_dict, "src-brick-port", &src_port);
+ if (src_port)
+ src_brickinfo->port = src_port;
if (!glusterd_is_local_addr (src_brickinfo->hostname)) {
gf_log ("", GF_LOG_INFO,
@@ -1431,13 +1452,10 @@ rb_update_dstbrick_port (glusterd_brickinfo_t *dst_brickinfo, dict_t *rsp_dict,
int dict_ret = 0;
int dst_port = 0;
- ctx = glusterd_op_get_ctx ();
- if (ctx) {
- dict_ret = dict_get_int32 (req_dict, "dst-brick-port", &dst_port);
- if (dst_port)
- dst_brickinfo->port = dst_port;
+ dict_ret = dict_get_int32 (req_dict, "dst-brick-port", &dst_port);
+ if (!dict_ret)
+ dst_brickinfo->port = dst_port;
- }
if (!glusterd_is_local_addr (dst_brickinfo->hostname)) {
gf_log ("", GF_LOG_INFO,
@@ -1611,10 +1629,6 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
}
if ((GF_REPLACE_OP_START != replace_op)) {
- ret = rb_update_dstbrick_port (dst_brickinfo, rsp_dict,
- dict, replace_op);
- if (ret)
- goto out;
/* Set task-id, if available, in op_ctx dict for operations
* other than start
@@ -1630,6 +1644,10 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
}
}
}
+ ret = rb_update_dstbrick_port (dst_brickinfo, rsp_dict,
+ dict, replace_op);
+ if (ret)
+ goto out;
switch (replace_op) {
case GF_REPLACE_OP_START: