diff options
author | Vijay Bellur <vijay@gluster.com> | 2010-11-18 06:26:26 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-11-18 05:55:55 -0800 |
commit | 99134d33f85e38e5c37227ecb8fdfbe03bd521d0 (patch) | |
tree | 507ca320d6068623fa508c903d00372294a39797 /xlators | |
parent | f0cdfd03051cee8d25f03103ed467438c6479e47 (diff) |
mgmt/glusterd: Avoid creating multiple destination brickinfo during replace-brick
Signed-off-by: Vijay Bellur <vijay@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 2084 ([3.1.1qa5] : replace-brick fails to migrate data when migration from same hostname)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2084
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 25df32ae77a..13227b61052 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -872,6 +872,23 @@ out: } static int +glusterd_get_rb_dst_brickinfo (glusterd_volinfo_t *volinfo, + glusterd_brickinfo_t **brickinfo) +{ + int32_t ret = -1; + + if (!volinfo || !brickinfo) + goto out; + + *brickinfo = volinfo->dst_brick; + + ret = 0; + +out: + return ret; +} + +static int glusterd_op_stage_replace_brick (gd1_mgmt_stage_op_req *req, char **op_errstr, dict_t *rsp_dict) { @@ -1060,11 +1077,13 @@ glusterd_op_stage_replace_brick (gd1_mgmt_stage_op_req *req, char **op_errstr, goto out; } - ret = glusterd_brickinfo_from_brick (dst_brick, &dst_brickinfo); if ((volinfo->rb_status ==GF_RB_STATUS_NONE) && (replace_op == GF_REPLACE_OP_START)) { + ret = glusterd_brickinfo_from_brick (dst_brick, &dst_brickinfo); volinfo->src_brick = src_brickinfo; volinfo->dst_brick = dst_brickinfo; + } else { + ret = glusterd_get_rb_dst_brickinfo (volinfo, &dst_brickinfo); } if (glusterd_rb_check_bricks (volinfo, src_brickinfo, dst_brickinfo)) { @@ -2912,6 +2931,8 @@ out: return ret; } + + static int glusterd_op_replace_brick (gd1_mgmt_stage_op_req *req, dict_t *rsp_dict) { @@ -2990,9 +3011,11 @@ glusterd_op_replace_brick (gd1_mgmt_stage_op_req *req, dict_t *rsp_dict) goto out; } - ret = glusterd_brickinfo_from_brick (dst_brick, &dst_brickinfo); + + ret = glusterd_get_rb_dst_brickinfo (volinfo, &dst_brickinfo); if (ret) { - gf_log ("", GF_LOG_DEBUG, "Unable to get dst-brickinfo"); + gf_log ("", GF_LOG_ERROR, "Unable to get " + "replace brick destination brickinfo"); goto out; } @@ -3121,6 +3144,7 @@ glusterd_op_replace_brick (gd1_mgmt_stage_op_req *req, dict_t *rsp_dict) ret = glusterd_fetchspec_notify (THIS); glusterd_set_rb_status (volinfo, GF_RB_STATUS_NONE); + glusterd_brickinfo_delete (volinfo->dst_brick); volinfo->src_brick = volinfo->dst_brick = NULL; } break; @@ -3172,6 +3196,7 @@ glusterd_op_replace_brick (gd1_mgmt_stage_op_req *req, dict_t *rsp_dict) } } glusterd_set_rb_status (volinfo, GF_RB_STATUS_NONE); + glusterd_brickinfo_delete (volinfo->dst_brick); volinfo->src_brick = volinfo->dst_brick = NULL; } break; @@ -4350,8 +4375,8 @@ glusterd_do_replace_brick (void *data) goto out; } - ret = glusterd_brickinfo_from_brick (dst_brick, &dst_brickinfo); - if (ret) { + ret = glusterd_get_rb_dst_brickinfo (volinfo, &dst_brickinfo); + if (!dst_brickinfo) { gf_log ("", GF_LOG_DEBUG, "Unable to get dst-brickinfo"); goto out; } @@ -4406,6 +4431,9 @@ out: else ret = glusterd_op_sm_inject_event (GD_OP_EVENT_COMMIT_ACC, NULL); + if (dict) + dict_unref (dict); + glusterd_op_sm (); } |