summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavan Sondur <pavan@gluster.com>2010-10-04 08:18:19 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-04 07:18:22 -0700
commit6a244f2e95b09603507782061ac08b7e0c28fd64 (patch)
treec801b560b515d58e609ce25557ce3a5d02537c72
parent14d6a7023fc1abc985675e9ee3e5fee4cd519210 (diff)
cluster/pump: mgmt/glusterd: Misc fixes for replace-brick
Signed-off-by: Pavan Vilas Sondur <pavan@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1235 (Bug for all pump/migrate commits) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1235
-rw-r--r--xlators/cluster/afr/src/afr-common.c3
-rw-r--r--xlators/cluster/afr/src/pump.c77
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c99
-rw-r--r--xlators/protocol/client/src/client-handshake.c13
-rw-r--r--xlators/protocol/client/src/client.c31
5 files changed, 189 insertions, 34 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index ee5fa3a606e..53b5ca1995e 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -2539,6 +2539,9 @@ afr_notify (xlator_t *this, int32_t event,
case GF_EVENT_CHILD_UP:
i = find_child_index (this, data);
+ gf_log (this->name, GF_LOG_DEBUG,
+ "child=%d up", i);
+
afr_attempt_lock_recovery (this, i);
child_up[i] = 1;
diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c
index 39de7cbb9ba..dc21855770c 100644
--- a/xlators/cluster/afr/src/pump.c
+++ b/xlators/cluster/afr/src/pump.c
@@ -620,6 +620,53 @@ pump_complete_migration (xlator_t *this)
}
static int
+pump_set_root_gfid (dict_t *dict)
+{
+ uuid_t gfid;
+ int ret = 0;
+
+ memset (gfid, 0, 16);
+ gfid[15] = 1;
+
+ ret = afr_set_dict_gfid (dict, gfid);
+
+ return ret;
+}
+
+static int
+pump_lookup_sink (loc_t *loc)
+{
+ xlator_t *this = NULL;
+ struct iatt iatt, parent;
+ dict_t *xattr_rsp;
+ dict_t *xattr_req = NULL;
+ int ret = 0;
+
+ this = THIS;
+
+ xattr_req = dict_new ();
+
+ ret = pump_set_root_gfid (xattr_req);
+ if (ret)
+ goto out;
+
+ ret = syncop_lookup (PUMP_SINK_CHILD (this), loc,
+ xattr_req, &iatt, &xattr_rsp, &parent);
+
+ if (ret) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Lookup on sink child failed");
+ goto out;
+ }
+
+out:
+ if (xattr_req)
+ dict_unref (xattr_req);
+
+ return ret;
+}
+
+static int
pump_task (void *data)
{
xlator_t *this = NULL;
@@ -628,7 +675,8 @@ pump_task (void *data)
loc_t loc;
struct iatt iatt, parent;
- dict_t *xattr_rsp;
+ dict_t *xattr_rsp = NULL;
+ dict_t *xattr_req = NULL;
int ret = -1;
@@ -638,8 +686,16 @@ pump_task (void *data)
assert (priv->root_inode);
build_root_loc (priv->root_inode, &loc);
+ xattr_req = dict_new ();
+ if (!xattr_req) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Out of memory");
+ ret = -1;
+ goto out;
+ }
- ret = syncop_lookup (this, &loc, NULL,
+ pump_set_root_gfid (xattr_req);
+ ret = syncop_lookup (this, &loc, xattr_req,
&iatt, &xattr_rsp, &parent);
gf_log (this->name, GF_LOG_TRACE,
@@ -654,10 +710,20 @@ pump_task (void *data)
pump_update_resume_path (this);
+ pump_set_root_gfid (xattr_req);
+ ret = pump_lookup_sink (&loc);
+ if (ret) {
+ pump_update_resume_path (this);
+ goto out;
+ }
+
gf_pump_traverse_directory (&loc);
pump_complete_migration (this);
out:
+ if (xattr_req)
+ dict_unref (xattr_req);
+
return 0;
}
@@ -698,7 +764,8 @@ pump_start (call_frame_t *pump_frame, xlator_t *this)
if (!pump_frame->root->lk_owner)
pump_frame->root->lk_owner = PUMP_LK_OWNER;
- ret = synctask_new (pump_priv->env, pump_task, pump_task_completion,
+ ret = synctask_new (pump_priv->env, pump_task,
+ pump_task_completion,
pump_frame);
if (ret == -1) {
gf_log (this->name, GF_LOG_DEBUG,
@@ -891,6 +958,8 @@ pump_cmd_start_getxattr_cbk (call_frame_t *frame,
else {
/* We're re-starting pump from a previous
pause */
+ gf_log (this->name, GF_LOG_DEBUG,
+ "about to start synctask");
ret = pump_start_synctask (this);
need_unwind = 1;
}
@@ -2210,6 +2279,8 @@ notify (xlator_t *this, int32_t event,
case GF_EVENT_CHILD_UP:
if (is_xlator_pump_sink (child_xl))
if (is_pump_start_pending (this)) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "about to start synctask");
ret = pump_start_synctask (this);
if (ret < 0)
gf_log (this->name, GF_LOG_DEBUG,
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 7a69d2c9e66..52ebd1b2cda 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1865,7 +1865,7 @@ rb_send_xattr_command (glusterd_volinfo_t *volinfo,
ret = lsetxattr (mount_point_path, xattr_key,
value,
- strlen (value),
+ strlen (value) + 1,
0);
if (ret) {
@@ -1887,15 +1887,23 @@ rb_spawn_dst_brick (glusterd_volinfo_t *volinfo,
glusterd_conf_t *priv = NULL;
char cmd_str[8192] = {0,};
int ret = -1;
+ int32_t port = 0;
priv = THIS->private;
+ port = pmap_registry_alloc (THIS);
+ brickinfo->port = port;
+
+ GF_ASSERT (port);
+
snprintf (cmd_str, 8192,
- "%s/sbin/glusterfs -f %s/vols/%s/%s -p %s/vols/%s/%s",
+ "%s/sbin/glusterfs -f %s/vols/%s/%s -p %s/vols/%s/%s "
+ "--xlator-option src-server.listen-port=%d",
GFS_PREFIX, priv->workdir, volinfo->volname,
RB_DSTBRICKVOL_FILENAME,
priv->workdir, volinfo->volname,
- RB_DSTBRICK_PIDFILE);
+ RB_DSTBRICK_PIDFILE,
+ port);
ret = gf_system (cmd_str);
if (ret) {
@@ -2016,19 +2024,18 @@ out:
}
static const char *dst_brick_volfile_str = "volume src-posix\n"
- "type storage/posix\n"
- "option directory %s\n"
+ " type storage/posix\n"
+ " option directory %s\n"
"end-volume\n"
"volume %s\n"
- "type features/locks\n"
- "subvolumes src-posix\n"
+ " type features/locks\n"
+ " subvolumes src-posix\n"
"end-volume\n"
"volume src-server\n"
- "type protocol/server\n"
- "option auth.addr.%s.allow *\n"
- "option listen-port 34034\n"
- "option transport-type tcp\n"
- "subvolumes %s\n"
+ " type protocol/server\n"
+ " option auth.addr.%s.allow *\n"
+ " option transport-type tcp\n"
+ " subvolumes %s\n"
"end-volume\n";
static int
@@ -2260,9 +2267,10 @@ rb_do_operation_start (glusterd_volinfo_t *volinfo,
gf_log ("", GF_LOG_DEBUG,
"mounted the replace brick client");
- snprintf (start_value, 8192, "%s:%s:",
+ snprintf (start_value, 8192, "%s:%s:%d",
dst_brickinfo->hostname,
- dst_brickinfo->path);
+ dst_brickinfo->path,
+ dst_brickinfo->port);
ret = rb_send_xattr_command (volinfo, src_brickinfo,
@@ -2404,6 +2412,14 @@ rb_do_operation_abort (glusterd_volinfo_t *volinfo,
ret = 0;
out:
+ if (!glusterd_is_local_addr (src_brickinfo->hostname)) {
+ ret = rb_src_brick_restart (volinfo, src_brickinfo,
+ 0);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Could not restart src-brick");
+ }
+ }
return ret;
}
@@ -2663,6 +2679,33 @@ glusterd_op_replace_brick (gd1_mgmt_stage_op_req *req, dict_t *rsp_dict)
"Failed to spawn destination brick");
goto out;
}
+
+ if (!glusterd_is_local_addr (dst_brickinfo->hostname)) {
+ gf_log ("", GF_LOG_NORMAL,
+ "adding dst-brick port no");
+
+ if (rsp_dict) {
+ ret = dict_set_int32 (rsp_dict, "dst-brick-port",
+ dst_brickinfo->port);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Could not set dst-brick port no");
+ goto out;
+ }
+ } else {
+ ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ GF_ASSERT (ctx);
+
+ ret = dict_set_int32 (ctx, "dst-brick-port",
+ dst_brickinfo->port);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Could not set dst-brick port no");
+ goto out;
+ }
+ }
+
+ }
}
if (!glusterd_is_local_addr (src_brickinfo->hostname)) {
@@ -2739,11 +2782,28 @@ glusterd_op_replace_brick (gd1_mgmt_stage_op_req *req, dict_t *rsp_dict)
{
gf_log ("", GF_LOG_DEBUG,
"Recieved pause - doing nothing");
+ ret = rb_do_operation_pause (volinfo, src_brickinfo, dst_brickinfo);
+ if (!glusterd_is_local_addr (dst_brickinfo->hostname)) {
+ gf_log ("", GF_LOG_NORMAL,
+ "I AM THE DESTINATION HOST");
+ ret = rb_kill_destination_brick (volinfo, dst_brickinfo);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Failed to kill destination brick");
+ goto out;
+ }
+ }
}
break;
case GF_REPLACE_OP_ABORT:
{
+ ret = dict_set_int32 (volinfo->dict, "enable-pump", 0);
+ if (ret) {
+ gf_log ("", GF_LOG_CRITICAL, "Unable to disable pump");
+ }
+
+ ret = rb_do_operation_abort (volinfo, src_brickinfo, dst_brickinfo);
if (!glusterd_is_local_addr (dst_brickinfo->hostname)) {
gf_log ("", GF_LOG_NORMAL,
"I AM THE DESTINATION HOST");
@@ -3845,6 +3905,7 @@ glusterd_do_replace_brick (void *data)
glusterd_volinfo_t *volinfo = NULL;
int32_t op = 0;
int32_t src_port = 0;
+ int32_t dst_port = 0;
dict_t *dict = NULL;
char *src_brick = NULL;
char *dst_brick = NULL;
@@ -3933,6 +3994,13 @@ glusterd_do_replace_brick (void *data)
goto out;
}
+ ret = dict_get_int32 (dict, "dst-brick-port", &dst_port);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to get dst-brick port");
+ goto out;
+ }
+
+ dst_brickinfo->port = dst_port;
src_brickinfo->port = src_port;
brick_signin = rb_check_brick_signin (src_brickinfo);
@@ -3949,10 +4017,7 @@ glusterd_do_replace_brick (void *data)
ret = rb_do_operation_start (volinfo, src_brickinfo, dst_brickinfo);
break;
case GF_REPLACE_OP_PAUSE:
- ret = rb_do_operation_pause (volinfo, src_brickinfo, dst_brickinfo);
- break;
case GF_REPLACE_OP_ABORT:
- ret = rb_do_operation_abort (volinfo, src_brickinfo, dst_brickinfo);
break;
case GF_REPLACE_OP_COMMIT:
case GF_REPLACE_OP_STATUS:
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c
index 101b62eecd7..19cd0f5d008 100644
--- a/xlators/protocol/client/src/client-handshake.c
+++ b/xlators/protocol/client/src/client-handshake.c
@@ -353,13 +353,14 @@ client_notify_parents_child_up (xlator_t *this)
/* send notify to 'ctx->master' if it exists */
xlator_notify (this->ctx->master, GF_EVENT_CHILD_UP,
this->graph);
- }
+ } else {
- parent = this->parents;
- while (parent) {
- xlator_notify (parent->xlator, GF_EVENT_CHILD_UP,
- this);
- parent = parent->next;
+ parent = this->parents;
+ while (parent) {
+ xlator_notify (parent->xlator, GF_EVENT_CHILD_UP,
+ this);
+ parent = parent->next;
+ }
}
return 0;
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index e64d8135fff..23d84ba0d84 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -888,20 +888,24 @@ out:
static gf_boolean_t
client_set_remote_options (char *value, xlator_t *this)
{
- clnt_conf_t *conf = NULL;
- char *dup_value = NULL;
- char *host = NULL;
- char *subvol = NULL;
- char *host_dup = NULL;
- char *subvol_dup = NULL;
- char *tmp = NULL;
- gf_boolean_t ret = _gf_false;
+ clnt_conf_t *conf = NULL;
+ char *dup_value = NULL;
+ char *host = NULL;
+ char *subvol = NULL;
+ char *host_dup = NULL;
+ char *subvol_dup = NULL;
+ char *remote_port_str = NULL;
+ char *tmp = NULL;
+ int remote_port = 0;
+ gf_boolean_t ret = _gf_false;
conf = this->private;
dup_value = gf_strdup (value);
host = strtok_r (dup_value, ":", &tmp);
subvol = strtok_r (NULL, ":", &tmp);
+ remote_port_str = strtok_r (NULL, ":", &tmp);
+
if (!subvol) {
gf_log (this->name, GF_LOG_WARNING,
"proper value not passed as subvolume");
@@ -936,6 +940,17 @@ client_set_remote_options (char *value, xlator_t *this)
goto out;
}
+ remote_port = atoi (remote_port_str);
+ GF_ASSERT (remote_port);
+
+ ret = dict_set_int32 (this->options, "remote-port",
+ remote_port);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to set remote-port to %d", remote_port);
+ goto out;
+ }
+
ret = _gf_true;
out:
if (dup_value)