summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2015-08-20 12:19:51 +0530
committerDan Lambright <dlambrig@redhat.com>2015-10-12 11:24:15 -0700
commit0f5c3e88f145005f963172e3ada10dbf6d6a607c (patch)
tree77548705a0547766067b88eb666c1feb1f4e09bb /xlators/mgmt/glusterd/src/glusterd-utils.c
parent2def6bbfc72f9dd7ae6a16befdaf45ac1076b648 (diff)
tier/shd: create shd volfile for tiering
Currently shd graph will only start if it is replicate or disperse volume. But in case of tiering, volume type will be tier. So we need to start shd if any of the cold or hot is compatible with shd volume. Back port of> >Change-Id: Ic689746ac7d2fc6a9eccdabd8518dc9139829de2 >BUG: 1261276 >Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> >Reviewed-on: http://review.gluster.org/11962 >Tested-by: Gluster Build System <jenkins@build.gluster.com> >Tested-by: NetBSD Build System <jenkins@build.gluster.org> >Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> (cherry picked from commit fdff192b918ca9cd237f3f784c627102377e3661) Change-Id: I236a31e7dcefb3dad64881e0b007144bd826b840 BUG: 1261744 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: http://review.gluster.org/12333 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Dan Lambright <dlambrig@redhat.com> Tested-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c98
1 files changed, 96 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index cde6ad1f20a..1994e74b655 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -630,6 +630,84 @@ glusterd_brickinfo_dup (glusterd_brickinfo_t *brickinfo,
out:
return ret;
}
+int32_t
+glusterd_create_sub_tier_volinfo (glusterd_volinfo_t *volinfo,
+ glusterd_volinfo_t **dup_volinfo,
+ gf_boolean_t is_hot_tier,
+ const char *new_volname)
+{
+ glusterd_brickinfo_t *brickinfo = NULL;
+ glusterd_brickinfo_t *brickinfo_dup = NULL;
+ gd_tier_info_t *tier_info = NULL;
+ int i = 0;
+ int ret = -1;
+
+ tier_info = &(volinfo->tier_info);
+
+ ret = glusterd_volinfo_dup (volinfo, dup_volinfo, _gf_true);
+ if (ret) {
+ gf_msg ("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOL_OP_FAILED,
+ "Failed to create volinfo");
+ return ret;
+ }
+
+ (*dup_volinfo)->is_snap_volume = volinfo->is_snap_volume;
+ (*dup_volinfo)->status = volinfo->status;
+ memcpy (&(*dup_volinfo)->tier_info, &volinfo->tier_info,
+ sizeof (volinfo->tier_info));
+
+ strcpy ((*dup_volinfo)->volname, new_volname);
+
+ cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
+ i++;
+
+ if (is_hot_tier) {
+ if (i > volinfo->tier_info.hot_brick_count)
+ break;
+ } else {
+ if (i <= volinfo->tier_info.hot_brick_count)
+ continue;
+ }
+
+ ret = glusterd_brickinfo_new (&brickinfo_dup);
+ if (ret) {
+ gf_msg ("glusterd", GF_LOG_ERROR, 0,
+ GD_MSG_BRICK_NEW_INFO_FAIL, "Failed to create "
+ "new brickinfo");
+ goto out;
+ }
+
+
+ glusterd_brickinfo_dup (brickinfo, brickinfo_dup);
+ cds_list_add_tail (&brickinfo_dup->brick_list,
+ &((*dup_volinfo)->bricks));
+ }
+
+ if (is_hot_tier) {
+ (*dup_volinfo)->type = tier_info->hot_type;
+ (*dup_volinfo)->replica_count = tier_info->hot_replica_count;
+ (*dup_volinfo)->brick_count = tier_info->hot_brick_count;
+ (*dup_volinfo)->dist_leaf_count =
+ glusterd_get_dist_leaf_count(*dup_volinfo);
+
+ } else {
+ (*dup_volinfo)->type = tier_info->cold_type;
+ (*dup_volinfo)->replica_count = tier_info->cold_replica_count;
+ (*dup_volinfo)->disperse_count = tier_info->cold_disperse_count;
+ (*dup_volinfo)->redundancy_count = tier_info->cold_redundancy_count;
+ (*dup_volinfo)->dist_leaf_count = tier_info->cold_dist_leaf_count;
+ (*dup_volinfo)->brick_count = tier_info->cold_brick_count;
+ }
+out:
+ if (ret && *dup_volinfo) {
+ glusterd_volinfo_delete (*dup_volinfo);
+ *dup_volinfo = NULL;
+ }
+
+ return ret;
+
+}
+
/*
* gd_vol_is_geo_rep_active:
* This function checks for any running geo-rep session for
@@ -6305,9 +6383,9 @@ glusterd_is_volume_replicate (glusterd_volinfo_t *volinfo)
}
gf_boolean_t
-glusterd_is_shd_compatible_volume (glusterd_volinfo_t *volinfo)
+glusterd_is_shd_compatible_type (int type)
{
- switch (volinfo->type) {
+ switch (type) {
case GF_CLUSTER_TYPE_REPLICATE:
case GF_CLUSTER_TYPE_STRIPE_REPLICATE:
case GF_CLUSTER_TYPE_DISPERSE:
@@ -6317,6 +6395,22 @@ glusterd_is_shd_compatible_volume (glusterd_volinfo_t *volinfo)
return _gf_false;
}
+gf_boolean_t
+glusterd_is_shd_compatible_volume (glusterd_volinfo_t *volinfo)
+{
+
+ int ret = 0;
+
+ if (volinfo->type == GF_CLUSTER_TYPE_TIER) {
+ ret = glusterd_is_shd_compatible_type
+ (volinfo->tier_info.cold_type) |
+ glusterd_is_shd_compatible_type
+ (volinfo->tier_info.hot_type);
+ return ret;
+ }
+ return glusterd_is_shd_compatible_type (volinfo->type);
+}
+
int
glusterd_set_dump_options (char *dumpoptions_path, char *options,
int option_cnt)