From 1d4378e0e78309682c13d0fc0c97c3c3bb6674b7 Mon Sep 17 00:00:00 2001 From: Krishnan P Date: Thu, 16 Jun 2011 01:28:28 +0000 Subject: 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 Signed-off-by: Anand Avati BUG: 3033 (Changes to replace-brick and syntask interface.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3033 --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 57 ++++++++++++++++++++++++++++++ xlators/mgmt/glusterd/src/glusterd.h | 1 + 2 files changed, 58 insertions(+) (limited to 'xlators/mgmt') 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 @@ -3474,6 +3474,53 @@ rb_kill_destination_brick (glusterd_volinfo_t *volinfo, return glusterd_service_stop ("brick", pidfile, SIGTERM, _gf_true); } +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, @@ -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 " diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index 2ddd830f847..b1027c1714c 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -245,6 +245,7 @@ enum glusterd_vol_comp_status_ { /*All definitions related to replace brick */ #define RB_PUMP_START_CMD "trusted.glusterfs.pump.start" #define RB_PUMP_PAUSE_CMD "trusted.glusterfs.pump.pause" +#define RB_PUMP_COMMIT_CMD "trusted.glusterfs.pump.commit" #define RB_PUMP_ABORT_CMD "trusted.glusterfs.pump.abort" #define RB_PUMP_STATUS_CMD "trusted.glusterfs.pump.status" #define RB_CLIENT_MOUNTPOINT "rb_mount" -- cgit