summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavan Sondur <pavan@gluster.com>2010-08-16 02:37:34 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-16 01:49:04 -0700
commit5065b0824ed01cca59501d74c227b136a5b0e65e (patch)
treea42ab52185544e0144e095e1767d368b92763a32
parent659e2d938f4da023411114c13a14337c21083411 (diff)
mgmt/glusterd: cli: Various fixes for replace brick.
Signed-off-by: Pavan Vilas Sondur <pavan@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1304 (Free state info for replace brick) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1304
-rw-r--r--cli/src/cli3_1-cops.c12
-rw-r--r--extras/volgen/CreateVolfile.py2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c133
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h1
5 files changed, 120 insertions, 32 deletions
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index 8f81815e8..9d1b3c1f8 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -750,6 +750,16 @@ gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
+ snprintf (cmd_str, 4096, "gluster volume replace-brick %s %s %s abort >/dev/null",
+ local->u.replace_brick.volname, src_brick, dst_brick);
+
+ ret = system (cmd_str);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "add brick failed");
+ goto out;
+ }
+
snprintf (cmd_str, 4096, "gluster volume add-brick %s %s >/dev/null",
local->u.replace_brick.volname, dst_brick);
@@ -1362,7 +1372,7 @@ gf_cli3_1_replace_brick (call_frame_t *frame, xlator_t *this,
goto out;
}
- local->u.replace_brick.volname = strdup (req.volname);
+ local->u.replace_brick.volname = gf_strdup (req.volname);
if (!local->u.replace_brick.volname) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory");
diff --git a/extras/volgen/CreateVolfile.py b/extras/volgen/CreateVolfile.py
index fdcf60566..5519917fb 100644
--- a/extras/volgen/CreateVolfile.py
+++ b/extras/volgen/CreateVolfile.py
@@ -299,6 +299,8 @@ class CreateVolfile:
exp_fd.write (" type protocol/client\n")
if self.transport:
exp_fd.write (" option transport-type %s\n" % self.transport)
+ if self.gfs_port:
+ exp_fd.write (" option transport.remote-port 34034\n")
exp_fd.write (" option ping-timeout 42\n")
exp_fd.write ("end-volume\n\n")
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 8c7d75c64..0843bc25a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -606,6 +606,12 @@ glusterd_op_stage_replace_brick (gd1_mgmt_stage_op_req *req)
goto out;
}
+ ret = glusterd_volinfo_find (volname, &volinfo);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to allocate memory");
+ goto out;
+ }
+
ret = glusterd_brickinfo_get (src_brick, volinfo,
&src_brickinfo);
if (ret) {
@@ -1058,8 +1064,8 @@ static const char *client_volfile_str = "volume client/protocol\n"
"type protocol/client\n"
"option remote-host %s\n"
"option remote-subvolume %s\n"
- "option remote-port 34034\n"
- "echo end-volume\n";
+ "option remote-port %d\n"
+ "end-volume\n";
static int
rb_generate_client_volfile (glusterd_volinfo_t *volinfo,
@@ -1087,8 +1093,10 @@ rb_generate_client_volfile (glusterd_volinfo_t *volinfo,
goto out;
}
+ GF_ASSERT (src_brickinfo->port);
+
fprintf (file, client_volfile_str, src_brickinfo->hostname,
- src_brickinfo->path);
+ src_brickinfo->path, src_brickinfo->port);
fclose (file);
@@ -1152,6 +1160,58 @@ out:
}
static int
+rb_mountpoint_mkdir (glusterd_volinfo_t *volinfo,
+ glusterd_brickinfo_t *src_brickinfo)
+{
+ glusterd_conf_t *priv = NULL;
+ char mount_point_path[PATH_MAX] = {0,};
+ int ret = -1;
+
+ priv = THIS->private;
+
+ snprintf (mount_point_path, PATH_MAX, "%s/vols/%s/%s",
+ priv->workdir, volinfo->volname,
+ RB_CLIENT_MOUNTPOINT);
+
+ ret = mkdir (mount_point_path, 0777);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG, "mkdir failed");
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ return ret;
+}
+
+static int
+rb_mountpoint_rmdir (glusterd_volinfo_t *volinfo,
+ glusterd_brickinfo_t *src_brickinfo)
+{
+ glusterd_conf_t *priv = NULL;
+ char mount_point_path[PATH_MAX] = {0,};
+ int ret = -1;
+
+ priv = THIS->private;
+
+ snprintf (mount_point_path, PATH_MAX, "%s/vols/%s/%s",
+ priv->workdir, volinfo->volname,
+ RB_CLIENT_MOUNTPOINT);
+
+ ret = rmdir (mount_point_path);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG, "rmdir failed");
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ return ret;
+}
+
+static int
rb_destroy_maintainence_client (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *src_brickinfo)
{
@@ -1176,7 +1236,7 @@ rb_destroy_maintainence_client (glusterd_volinfo_t *volinfo,
goto out;
}
- snprintf (cmd_str, 8192, "umount %s/vols/%s/%s",
+ snprintf (cmd_str, 8192, "umount -f %s/vols/%s/%s",
priv->workdir, volinfo->volname,
RB_CLIENT_MOUNTPOINT);
@@ -1187,6 +1247,13 @@ rb_destroy_maintainence_client (glusterd_volinfo_t *volinfo,
goto out;
}
+ ret = rb_mountpoint_rmdir (volinfo, src_brickinfo);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "rmdir of mountpoint failed");
+ goto out;
+ }
+
snprintf (filename, PATH_MAX, "%s/vols/%s/%s",
priv->workdir, volinfo->volname,
RB_CLIENTVOL_FILENAME);
@@ -1217,6 +1284,13 @@ rb_spawn_maintainence_client (glusterd_volinfo_t *volinfo,
goto out;
}
+ ret = rb_mountpoint_mkdir (volinfo, src_brickinfo);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG, "Unable to mkdir "
+ "mountpoint");
+ goto out;
+ }
+
ret = rb_spawn_glusterfs_client (volinfo, src_brickinfo);
if (ret) {
gf_log ("", GF_LOG_DEBUG, "Unable to start glusterfs");
@@ -1231,6 +1305,7 @@ out:
static int
rb_spawn_destination_brick (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *dst_brickinfo)
+
{
int ret = -1;
@@ -1315,26 +1390,6 @@ out:
return ret;
}
-/* replace brick commit is handled by cli directly.
- * return success all the time.
- */
-static int
-rb_do_operation_commit (glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t *src_brickinfo,
- glusterd_brickinfo_t *dst_brickinfo)
-{
- gf_log ("", GF_LOG_DEBUG,
- "received commit on %s:%s to %s:%s "
- "on volume %s",
- src_brickinfo->hostname,
- src_brickinfo->path,
- dst_brickinfo->hostname,
- dst_brickinfo->path,
- volinfo->volname);
-
- return 0;
-}
-
static int
rb_do_operation_pause (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *src_brickinfo,
@@ -1381,17 +1436,17 @@ static int
rb_kill_destination_brick (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *dst_brickinfo)
{
- glusterd_conf_t *priv = NULL;
- int ret = -1;
- char *pidfile = NULL;
- pid_t pid = -1;
- FILE *file = NULL;
+ glusterd_conf_t *priv = NULL;
+ int ret = -1;
+ char pidfile[PATH_MAX] = {0,};
+ pid_t pid = -1;
+ FILE *file = NULL;
priv = THIS->private;
snprintf (pidfile, PATH_MAX, "%s/vols/%s/%s",
priv->workdir, volinfo->volname,
- RB_DSTBRICKVOL_FILENAME);
+ RB_DSTBRICK_PIDFILE);
file = fopen (pidfile, "r+");
if (!file) {
@@ -1481,6 +1536,24 @@ out:
}
static int
+rb_do_operation_commit (glusterd_volinfo_t *volinfo,
+ glusterd_brickinfo_t *src_brickinfo,
+ glusterd_brickinfo_t *dst_brickinfo)
+{
+
+ gf_log ("", GF_LOG_DEBUG,
+ "received commit on %s:%s to %s:%s "
+ "on volume %s",
+ src_brickinfo->hostname,
+ src_brickinfo->path,
+ dst_brickinfo->hostname,
+ dst_brickinfo->path,
+ volinfo->volname);
+
+ return 0;
+}
+
+static int
rb_get_xattr_command (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *src_brickinfo,
glusterd_brickinfo_t *dst_brickinfo,
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 959a9c999..ab9936a7d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -771,8 +771,10 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
port, volfile, pidfile);
ret = system (cmd_str);
- if (ret == 0)
+ if (ret == 0) {
pmap_registry_bind (THIS, port, brickinfo->path);
+ brickinfo->port = port;
+ }
out:
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index c0ac17c53..5e44ea453 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -77,6 +77,7 @@ struct glusterd_brickinfo {
char path[PATH_MAX];
struct list_head brick_list;
uuid_t uuid;
+ int port;
glusterd_store_handle_t *shandle;
};