summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-op-sm.c
diff options
context:
space:
mode:
authorKrishnan P <kp@gluster.com>2011-06-16 01:28:28 +0000
committerAnand Avati <avati@gluster.com>2011-06-16 09:15:16 -0700
commit1d4378e0e78309682c13d0fc0c97c3c3bb6674b7 (patch)
tree741e3da57f0cebcc00b54c9cd097662e2bafd669 /xlators/mgmt/glusterd/src/glusterd-op-sm.c
parent4e6f6408b0e177dcdc0b19561bbaab6b7e26c23a (diff)
pump: cleanup xattrs on both commit and abort path.
This change makes glusterd to send a setxattr command for replace-brick commit operation similar to abort. Earlier we could commit even before the 'migration' of data was complete, with this change we fail that operation. Signed-off-by: Krishnan Parthasarathi <kp@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 3033 (Changes to replace-brick and syntask interface.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3033
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index a802149212e..6df894ca740 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -3475,6 +3475,53 @@ rb_kill_destination_brick (glusterd_volinfo_t *volinfo,
}
static int
+rb_do_operation_commit (glusterd_volinfo_t *volinfo,
+ glusterd_brickinfo_t *src_brickinfo,
+ glusterd_brickinfo_t *dst_brickinfo)
+{
+ int ret = -1;
+ int cmd_ret = -1;
+
+ gf_log ("", GF_LOG_DEBUG,
+ "replace-brick sending commit xattr");
+
+ ret = rb_spawn_maintenance_client (volinfo, src_brickinfo);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Could not spawn maintenance "
+ "client");
+ goto out;
+ }
+
+ gf_log ("", GF_LOG_DEBUG,
+ "mounted the replace brick client");
+
+ cmd_ret = rb_send_xattr_command (volinfo, src_brickinfo,
+ dst_brickinfo, RB_PUMP_COMMIT_CMD,
+ "jargon");
+ if (cmd_ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Failed to send command to pump");
+ }
+
+ ret = rb_destroy_maintenance_client (volinfo, src_brickinfo);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG,
+ "Failed to destroy maintenance "
+ "client");
+ goto out;
+ }
+
+ gf_log ("", GF_LOG_DEBUG,
+ "unmounted the replace brick client");
+
+ ret = 0;
+
+out:
+ return cmd_ret || ret;
+}
+
+static int
rb_do_operation_abort (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *src_brickinfo,
glusterd_brickinfo_t *dst_brickinfo)
@@ -3894,6 +3941,16 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
case GF_REPLACE_OP_COMMIT:
case GF_REPLACE_OP_COMMIT_FORCE:
{
+ ctx = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK);
+ if (ctx) {
+ ret = rb_do_operation_commit (volinfo, src_brickinfo, dst_brickinfo);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR,
+ "Commit operation failed");
+ goto out;
+ }
+ }
+
ret = dict_set_int32 (volinfo->dict, "enable-pump", 0);
gf_log ("", GF_LOG_DEBUG,
"Received commit - will be adding dst brick and "