summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2014-06-12 15:02:06 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2014-06-13 04:41:22 -0700
commita6585d9c5e536818e01f05df8e58c18bbe59e231 (patch)
tree86c7ab7b54e19b610726fc7e688b58e6d173b353 /xlators/mgmt/glusterd
parent5b0f65717f0d9489ca1c8750724cf9c8bfa11cbc (diff)
glusterd: More snapshot backward compatability fixes
Several volume operations, start, add-brick and replace-brick, expected the presence of a bricks mount directory, which is required for the snapshot feature. This should only be expected when snapshot is supported in the cluster. Change-Id: I92017bb5e069392352f9800cef1ddc80045fda35 BUG: 1101903 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.org/8046 Reviewed-by: Atin Mukherjee <amukherj@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')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c68
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c28
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c140
3 files changed, 144 insertions, 92 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index adbaf79aad8..452df759ad4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -1000,11 +1000,15 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
char key[PATH_MAX] = "";
char *brick_mount_dir = NULL;
xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
this = THIS;
GF_ASSERT (this);
GF_ASSERT (volinfo);
+ conf = this->private;
+ GF_ASSERT (conf);
+
if (bricks) {
brick_list = gf_strdup (bricks);
free_ptr1 = brick_list;
@@ -1040,17 +1044,22 @@ glusterd_op_perform_add_bricks (glusterd_volinfo_t *volinfo, int32_t count,
GLUSTERD_ASSIGN_BRICKID_TO_BRICKINFO (brickinfo, volinfo,
brickid++);
- brick_mount_dir = NULL;
+ /* A bricks mount dir is required only by snapshots which were
+ * introduced in gluster-3.6.0
+ */
+ if (conf->op_version >= GD_OP_VERSION_3_6_0) {
+ 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;
+ 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));
}
- strncpy (brickinfo->mount_dir, brick_mount_dir,
- sizeof(brickinfo->mount_dir));
ret = glusterd_resolve_brick (brickinfo);
if (ret)
@@ -1241,9 +1250,12 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
char *all_bricks = NULL;
char *str_ret = NULL;
gf_boolean_t is_force = _gf_false;
+ glusterd_conf_t *conf = NULL;
this = THIS;
GF_ASSERT (this);
+ conf = this->private;
+ GF_ASSERT (conf);
ret = dict_get_int32 (dict, "replica-count", &replica_count);
if (ret) {
@@ -1369,24 +1381,30 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
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;
- }
+ /* A bricks mount dir is required only by snapshots which were
+ * introduced in gluster-3.6.0
+ */
+ if (conf->op_version >= GD_OP_VERSION_3_6_0) {
+ 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;
+ 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;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index 151d41f4e49..d33dc7a32ee 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -544,7 +544,10 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
ret = -1;
goto out;
}
- } else {
+ } else if (priv->op_version >= GD_OP_VERSION_3_6_0) {
+ /* A bricks mount dir is required only by snapshots which were
+ * introduced in gluster-3.6.0
+ */
ret = glusterd_get_brick_mount_dir (dst_brickinfo->path,
dst_brickinfo->hostname,
dst_brickinfo->mount_dir);
@@ -1525,12 +1528,16 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *new_brickinfo = NULL;
int32_t ret = -1;
xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
this = THIS;
GF_ASSERT (this);
GF_ASSERT (dict);
GF_ASSERT (volinfo);
+ conf = this->private;
+ GF_ASSERT (conf);
+
ret = glusterd_brickinfo_new_from_brick (new_brick,
&new_brickinfo);
if (ret)
@@ -1549,14 +1556,19 @@ 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;
+ /* A bricks mount dir is required only by snapshots which were
+ * introduced in gluster-3.6.0
+ */
+ if (conf->op_version >= GD_OP_VERSION_3_6_0) {
+ 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));
}
- strncpy (new_brickinfo->mount_dir, brick_mount_dir,
- sizeof(new_brickinfo->mount_dir));
list_add_tail (&new_brickinfo->brick_list,
&old_brickinfo->brick_list);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index d885ab0a63f..76db3425dbe 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -850,24 +850,28 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr,
if (ret)
goto out;
- ret = glusterd_get_brick_mount_dir
- (brick_info->path,
- brick_info->hostname,
- brick_info->mount_dir);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to get brick mount_dir");
- goto out;
- }
+ /* A bricks mount dir is required only by snapshots which were
+ * introduced in gluster-3.6.0
+ */
+ if (priv->op_version >= GD_OP_VERSION_3_6_0) {
+ ret = glusterd_get_brick_mount_dir
+ (brick_info->path, brick_info->hostname,
+ brick_info->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);
- ret = dict_set_dynstr_with_alloc
- (rsp_dict, key,
- brick_info->mount_dir);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to set %s", key);
- goto out;
+ snprintf (key, sizeof(key), "brick%d.mount_dir",
+ i);
+ ret = dict_set_dynstr_with_alloc
+ (rsp_dict, key, brick_info->mount_dir);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to set %s", key);
+ goto out;
+ }
}
local_brick_count = i;
@@ -1072,29 +1076,33 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr,
goto out;
}
- if (strlen(brickinfo->mount_dir) < 1) {
- 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;
- }
+ /* A bricks mount dir is required only by snapshots which were
+ * introduced in gluster-3.6.0
+ */
+ if (priv->op_version >= GD_OP_VERSION_3_6_0) {
+ if (strlen(brickinfo->mount_dir) < 1) {
+ 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",
- brick_count);
- 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;
+ snprintf (key, sizeof(key), "brick%d.mount_dir",
+ brick_count);
+ 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 = brick_count;
}
- local_brick_count = brick_count;
}
+
#ifdef HAVE_BD_XLATOR
if (brickinfo->vg[0])
caps = CAPS_BD | CAPS_THIN |
@@ -1773,16 +1781,21 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
goto out;
}
- 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;
+ /* A bricks mount dir is required only by snapshots which were
+ * introduced in gluster-3.6.0
+ */
+ if (priv->op_version >= GD_OP_VERSION_3_6_0) {
+ 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));
}
- strncpy (brickinfo->mount_dir, brick_mount_dir,
- sizeof(brickinfo->mount_dir));
#ifdef HAVE_BD_XLATOR
if (!uuid_compare (brickinfo->uuid, MY_UUID)) {
@@ -1905,9 +1918,12 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr)
glusterd_volinfo_t *volinfo = NULL;
glusterd_brickinfo_t *brickinfo = NULL;
xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
this = THIS;
GF_ASSERT (this);
+ conf = this->private;
+ GF_ASSERT (conf);
ret = glusterd_op_start_volume_args_get (dict, &volname, &flags);
if (ret)
@@ -1920,20 +1936,26 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr)
goto out;
}
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- brick_count++;
- if (strlen(brickinfo->mount_dir) < 1) {
- brick_mount_dir = NULL;
- snprintf (key, sizeof(key), "brick%d.mount_dir",
- brick_count);
- ret = dict_get_str (dict, key, &brick_mount_dir);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "%s not present", key);
- goto out;
+ /* A bricks mount dir is required only by snapshots which were
+ * introduced in gluster-3.6.0
+ */
+ if (conf->op_version >= GD_OP_VERSION_3_6_0) {
+ list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ brick_count++;
+ if (strlen(brickinfo->mount_dir) < 1) {
+ brick_mount_dir = NULL;
+ snprintf (key, sizeof(key), "brick%d.mount_dir",
+ brick_count);
+ 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));
}
- strncpy (brickinfo->mount_dir, brick_mount_dir,
- sizeof(brickinfo->mount_dir));
}
}