summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorPavan Sondur <pavan@gluster.com>2010-09-22 02:01:36 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-22 02:09:00 -0700
commit05fd7d004a307a1aba158df82a868e3d271fe966 (patch)
treebe6f285e0c10c82c93dbd54179cccb4efd52bc93 /xlators
parente6bdd4f642d5f4d0afbe76b21fdd644c326edb0e (diff)
mgmt/glusterd: Restart src brick and add pump when replace brick cmds are given.
Signed-off-by: Pavan Vilas Sondur <pavan@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1669 (pump xlator should be excluded by default) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1669
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c106
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c38
2 files changed, 129 insertions, 15 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 233ff73e9..e7a8c0d2c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1515,6 +1515,81 @@ out:
}
static int
+rb_regenerate_volfiles (glusterd_volinfo_t *volinfo, int32_t pump_needed)
+{
+ dict_t *dict = NULL;
+ int ret = 0;
+
+ dict = volinfo->dict;
+
+ gf_log ("", GF_LOG_DEBUG,
+ "attempting to set pump value=%d", pump_needed);
+
+ ret = dict_set_int32 (dict, "enable-pump", pump_needed);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "could not dict_set enable-pump");
+ goto out;
+ }
+
+ ret = glusterd_create_volfiles (volinfo);
+
+out:
+ return ret;
+}
+
+static int
+rb_src_brick_restart (glusterd_volinfo_t *volinfo,
+ glusterd_brickinfo_t *src_brickinfo,
+ int activate_pump)
+{
+ int ret = 0;
+
+ gf_log ("", GF_LOG_DEBUG,
+ "Attempting to kill src");
+
+ ret = glusterd_volume_stop_glusterfs
+ (volinfo, src_brickinfo, 0);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to stop "
+ "glusterfs, ret: %d", ret);
+ goto out;
+ }
+
+ glusterd_delete_volfile (volinfo, src_brickinfo);
+ glusterd_store_delete_brick (volinfo, src_brickinfo);
+
+ if (activate_pump) {
+ ret = rb_regenerate_volfiles (volinfo, 1);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Could not regenerate volfiles with pump");
+ goto out;
+ }
+ } else {
+ ret = rb_regenerate_volfiles (volinfo, 0);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Could not regenerate volfiles without pump");
+ goto out;
+ }
+
+ }
+
+ ret = glusterd_volume_start_glusterfs
+ (volinfo, src_brickinfo, 0);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to start "
+ "glusterfs, ret: %d", ret);
+ goto out;
+ }
+
+
+out:
+ return ret;
+}
+
+static int
rb_send_xattr_command (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *src_brickinfo,
glusterd_brickinfo_t *dst_brickinfo,
@@ -1922,7 +1997,15 @@ rb_do_operation_start (glusterd_volinfo_t *volinfo,
char start_value[8192] = {0,};
int ret = -1;
- gf_log ("", GF_LOG_NORMAL,
+ ret = rb_src_brick_restart (volinfo, src_brickinfo,
+ 1);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Could not restart src-brick");
+ goto out;
+ }
+
+ gf_log ("", GF_LOG_DEBUG,
"replace-brick sending start xattr");
ret = rb_spawn_maintainence_client (volinfo, src_brickinfo);
@@ -2035,6 +2118,14 @@ rb_do_operation_abort (glusterd_volinfo_t *volinfo,
{
int ret = -1;
+ ret = rb_src_brick_restart (volinfo, src_brickinfo,
+ 0);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Could not restart src-brick");
+ goto out;
+ }
+
gf_log ("", GF_LOG_DEBUG,
"replace-brick sending abort xattr");
@@ -2079,6 +2170,15 @@ rb_do_operation_commit (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *src_brickinfo,
glusterd_brickinfo_t *dst_brickinfo)
{
+ int ret = 0;
+
+ ret = rb_src_brick_restart (volinfo, src_brickinfo,
+ 0);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Could not restart src-brick");
+ goto out;
+ }
gf_log ("", GF_LOG_DEBUG,
"received commit on %s:%s to %s:%s "
@@ -2088,8 +2188,8 @@ rb_do_operation_commit (glusterd_volinfo_t *volinfo,
dst_brickinfo->hostname,
dst_brickinfo->path,
volinfo->volname);
-
- return 0;
+out:
+ return ret;
}
static int
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index f40dbe13d..46a05d965 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -689,7 +689,7 @@ __write_access_control_xlator (FILE *file, dict_t *dict,
const char *ac_str = "volume %s-access-control\n"
" type features/access-control\n"
" subvolumes %s\n"
- "end-volume\n";
+ "end-volume\n\n";
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
@@ -1589,6 +1589,7 @@ generate_server_volfile (glusterd_brickinfo_t *brickinfo,
char subvol[2048] = {0,};
char *volname = NULL;
int ret = -1;
+ int activate_pump = 0;
GF_ASSERT (filename);
@@ -1635,23 +1636,36 @@ generate_server_volfile (glusterd_brickinfo_t *brickinfo,
goto out;
}
- VOLGEN_GENERATE_VOLNAME (subvol, volname, "locks");
-
- ret = __write_replace_brick_xlator (file, dict);
+ ret = dict_get_int32 (dict, "enable-pump", &activate_pump);
if (ret) {
gf_log ("", GF_LOG_DEBUG,
- "Could not write xlator");
- goto out;
+ "Pump is disabled");
}
- ret = __write_pump_xlator (file, dict, subvol);
- if (ret) {
+ if (activate_pump) {
gf_log ("", GF_LOG_DEBUG,
- "Could not write xlator");
- goto out;
- }
+ "Pump is enabled");
+
+ VOLGEN_GENERATE_VOLNAME (subvol, volname, "locks");
+
+ ret = __write_replace_brick_xlator (file, dict);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Could not write xlator");
+ goto out;
+ }
+
+ ret = __write_pump_xlator (file, dict, subvol);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Could not write xlator");
+ goto out;
+ }
+
+ VOLGEN_GENERATE_VOLNAME (subvol, volname, "pump");
+ } else
+ VOLGEN_GENERATE_VOLNAME (subvol, volname, "locks");
- VOLGEN_GENERATE_VOLNAME (subvol, volname, "pump");
ret = dict_set_str (dict, "export-path", brickinfo->path);
if (ret) {