summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2014-04-23 04:26:24 +0000
committerKrishnan Parthasarathi <kparthas@redhat.com>2014-05-06 00:24:39 -0700
commitf846e54b8844decbc8bd73840e7d35b2dcaed2e0 (patch)
treee0f7be12df60b59c42651cd50bd683510e7cce24 /xlators/mgmt/glusterd/src/glusterd-replace-brick.c
parenta05c579f1c3695c4ddead0a5cfc2c92422bd4f8f (diff)
glusterd: Fetch brick mount_dirs during brick create.
Fetch the mount directory path for a brick, during volume create, add-brick, and replace-brick. When a snap-create is missed, use this mount directory information to create the brick path for the missed snap brick. Change-Id: Iad3eec96a32cf340f26bdf3f28e2f529e4b77e31 BUG: 1061685 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/7550 Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-replace-brick.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index ed6d7fd57d5..929c86b718c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -544,6 +544,30 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
ret = -1;
goto out;
}
+ } else {
+ ret = glusterd_get_brick_mount_dir (dst_brickinfo->path,
+ dst_brickinfo->hostname,
+ dst_brickinfo->mount_dir);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to get brick mount_dir");
+ goto out;
+ }
+
+ ret = dict_set_dynstr_with_alloc (rsp_dict, "brick1.mount_dir",
+ dst_brickinfo->mount_dir);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to set brick1.mount_dir");
+ goto out;
+ }
+
+ ret = dict_set_int32 (rsp_dict, "brick_count", 1);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to set local_brick_count");
+ goto out;
+ }
}
if (replace_op == GF_REPLACE_OP_START &&
@@ -1493,12 +1517,18 @@ out:
static int
glusterd_op_perform_replace_brick (glusterd_volinfo_t *volinfo,
- char *old_brick, char *new_brick)
+ char *old_brick, char *new_brick,
+ dict_t *dict)
{
+ char *brick_mount_dir = NULL;
glusterd_brickinfo_t *old_brickinfo = NULL;
glusterd_brickinfo_t *new_brickinfo = NULL;
int32_t ret = -1;
+ xlator_t *this = NULL;
+ this = THIS;
+ GF_ASSERT (this);
+ GF_ASSERT (dict);
GF_ASSERT (volinfo);
ret = glusterd_brickinfo_new_from_brick (new_brick,
@@ -1519,6 +1549,15 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t *volinfo,
strncpy (new_brickinfo->brick_id, old_brickinfo->brick_id,
sizeof (new_brickinfo->brick_id));
+ ret = dict_get_str (dict, "brick1.mount_dir", &brick_mount_dir);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "brick1.mount_dir not present");
+ goto out;
+ }
+ strncpy (new_brickinfo->mount_dir, brick_mount_dir,
+ sizeof(new_brickinfo->mount_dir));
+
list_add_tail (&new_brickinfo->brick_list,
&old_brickinfo->brick_list);
@@ -1629,7 +1668,6 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
if (ret)
goto out;
-
if ((GF_REPLACE_OP_START != replace_op)) {
/* Set task-id, if available, in op_ctx dict for operations
@@ -1753,7 +1791,7 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
}
ret = glusterd_op_perform_replace_brick (volinfo, src_brick,
- dst_brick);
+ dst_brick, dict);
if (ret) {
gf_log (this->name, GF_LOG_CRITICAL, "Unable to add "
"dst-brick: %s to volume: %s", dst_brick,