summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-brick-ops.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-brick-ops.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-brick-ops.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c50
1 files changed, 48 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index e2e01672893..b14d3606d81 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -996,7 +996,12 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
char msg[1024] __attribute__((unused)) = {0, };
int caps = 0;
int brickid = 0;
+ char key[PATH_MAX] = "";
+ char *brick_mount_dir = NULL;
+ xlator_t *this = NULL;
+ this = THIS;
+ GF_ASSERT (this);
GF_ASSERT (volinfo);
if (bricks) {
@@ -1034,6 +1039,18 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
GLUSTERD_ASSIGN_BRICKID_TO_BRICKINFO (brickinfo, volinfo,
brickid++);
+ brick_mount_dir = NULL;
+
+ snprintf (key, sizeof(key), "brick%d.mount_dir", i);
+ ret = dict_get_str (dict, key, &brick_mount_dir);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "%s not present", key);
+ goto out;
+ }
+ strncpy (brickinfo->mount_dir, brick_mount_dir,
+ sizeof(brickinfo->mount_dir));
+
ret = glusterd_resolve_brick (brickinfo);
if (ret)
goto out;
@@ -1049,7 +1066,6 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
}
-
/* Gets changed only if the options are given in add-brick cli */
if (type)
volinfo->type = type;
@@ -1202,13 +1218,14 @@ out:
}
int
-glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr)
+glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
{
int ret = 0;
char *volname = NULL;
int count = 0;
int replica_count = 0;
int i = 0;
+ int32_t local_brick_count = 0;
char *bricks = NULL;
char *brick_list = NULL;
char *saveptr = NULL;
@@ -1218,6 +1235,7 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr)
glusterd_volinfo_t *volinfo = NULL;
xlator_t *this = NULL;
char msg[2048] = {0,};
+ char key[PATH_MAX] = "";
gf_boolean_t brick_alloc = _gf_false;
char *all_bricks = NULL;
char *str_ret = NULL;
@@ -1349,6 +1367,26 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr)
op_errstr, is_force);
if (ret)
goto out;
+
+ ret = glusterd_get_brick_mount_dir
+ (brickinfo->path,
+ brickinfo->hostname,
+ brickinfo->mount_dir);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to get brick mount_dir");
+ goto out;
+ }
+
+ snprintf (key, sizeof(key), "brick%d.mount_dir", i + 1);
+ ret = dict_set_dynstr_with_alloc (rsp_dict, key,
+ brickinfo->mount_dir);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to set %s", key);
+ goto out;
+ }
+ local_brick_count = i + 1;
}
glusterd_brickinfo_delete (brickinfo);
@@ -1358,6 +1396,14 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr)
i++;
}
+ ret = dict_set_int32 (rsp_dict, "brick_count",
+ local_brick_count);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to set local_brick_count");
+ goto out;
+ }
+
out:
GF_FREE (free_ptr);
if (brick_alloc && brickinfo)