From f19c019cef4abfdb065d72c088fabf7d3d7805ff Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Wed, 22 Apr 2015 20:07:11 +0530 Subject: cli/tiering: volume info should display details about tier Back port of http://review.gluster.org/#/c/10339/ >> gluster volume info patchy Volume Name: patchy Type: Tier Volume ID: 8bf1a1ca-6417-484f-821f-18973a7502a8 Status: Created Number of Bricks: 8 Transport-type: tcp Hot Tier : Hot Tier Type : Replicate Number of Bricks: 1 x 2 = 2 Brick1: hostname:/home/brick30 Brick2: hostname:/home/brick31 Cold Bricks: Cold Tier Type : Disperse Number of Bricks: 1 x (4 + 2) = 6 Brick3: hostname:/home/brick20 Brick4: hostname:/home/brick21 Brick5: hostname:/home/brick23 Brick6: hostname:/home/brick24 Brick7: hostname:/home/brick25 Brick8: hostname:/home/brick26 Change-Id: I7b9025af81263ebecd641b4b6897b20db8b67195 BUG: 1219842 Signed-off-by: Mohammed Rafi KC Reviewed-on: http://review.gluster.org/10676 Reviewed-by: Dan Lambright Tested-by: NetBSD Build System Tested-by: Gluster Build System --- xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 9 ++- xlators/mgmt/glusterd/src/glusterd-handler.c | 80 ++++++++++++++++++++++++++ xlators/mgmt/glusterd/src/glusterd-store.c | 11 ++++ xlators/mgmt/glusterd/src/glusterd-store.h | 1 + xlators/mgmt/glusterd/src/glusterd-volgen.c | 1 + xlators/mgmt/glusterd/src/glusterd.h | 5 ++ 6 files changed, 104 insertions(+), 3 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index c2f06ef1cbe..92d15c615be 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -1882,6 +1882,7 @@ glusterd_op_perform_attach_tier (dict_t *dict, volinfo->tier_info.cold_brick_count = volinfo->brick_count; volinfo->tier_info.cold_replica_count = volinfo->replica_count; volinfo->tier_info.cold_disperse_count = volinfo->disperse_count; + volinfo->tier_info.cold_redundancy_count = volinfo->redundancy_count; ret = dict_get_int32 (dict, "replica-count", &replica_count); if (!ret) @@ -1966,9 +1967,11 @@ out: static void glusterd_op_perform_detach_tier (glusterd_volinfo_t *volinfo) { - volinfo->type = volinfo->tier_info.cold_type; - volinfo->replica_count = volinfo->tier_info.cold_replica_count; - volinfo->disperse_count = volinfo->tier_info.cold_disperse_count; + volinfo->type = volinfo->tier_info.cold_type; + volinfo->replica_count = volinfo->tier_info.cold_replica_count; + volinfo->disperse_count = volinfo->tier_info.cold_disperse_count; + volinfo->redundancy_count = volinfo->tier_info.cold_redundancy_count; + volinfo->dist_leaf_count = volinfo->tier_info.cold_dist_leaf_count; } int diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index a6cf1319784..83fa799c2a5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -310,6 +310,79 @@ _build_option_key (dict_t *d, char *k, data_t *v, void *tmp) return 0; } +int +glusterd_add_tier_volume_detail_to_dict (glusterd_volinfo_t *volinfo, + dict_t *dict, int count) +{ + int ret = -1; + char key[256] = {0,}; + + GF_ASSERT (volinfo); + GF_ASSERT (dict); + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.cold_type", count); + ret = dict_set_int32 (dict, key, volinfo->tier_info.cold_type); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.cold_brick_count", count); + ret = dict_set_int32 (dict, key, volinfo->tier_info.cold_brick_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.cold_dist_count", count); + ret = dict_set_int32 (dict, key, + volinfo->tier_info.cold_dist_leaf_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.cold_replica_count", count); + ret = dict_set_int32 (dict, key, + volinfo->tier_info.cold_replica_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.cold_disperse_count", count); + ret = dict_set_int32 (dict, key, + volinfo->tier_info.cold_disperse_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.cold_redundancy_count", count); + ret = dict_set_int32 (dict, key, + volinfo->tier_info.cold_redundancy_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.hot_type", count); + ret = dict_set_int32 (dict, key, volinfo->tier_info.hot_type); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.hot_brick_count", count); + ret = dict_set_int32 (dict, key, volinfo->tier_info.hot_brick_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.hot_replica_count", count); + ret = dict_set_int32 (dict, key, volinfo->tier_info.hot_replica_count); + if (ret) + goto out; + +out: + return ret; + +} + int glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, dict_t *volumes, int count) @@ -360,6 +433,13 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, if (ret) goto out; + if (volinfo->type == GF_CLUSTER_TYPE_TIER) { + ret = glusterd_add_tier_volume_detail_to_dict (volinfo, + volumes, count); + if (ret) + goto out; + } + snprintf (key, 256, "volume%d.dist_count", count); ret = dict_set_int32 (volumes, key, volinfo->dist_leaf_count); if (ret) diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index f6e31b24943..c3cb4e490d9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -843,6 +843,13 @@ glusterd_volume_write_tier_details (int fd, glusterd_volinfo_t *volinfo) if (ret) goto out; + snprintf (buf, sizeof (buf), "%d", + volinfo->tier_info.cold_redundancy_count); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_COLD_REDUNDANCY_COUNT, + buf); + if (ret) + goto out; + snprintf (buf, sizeof (buf), "%d", volinfo->tier_info.hot_brick_count); ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_HOT_COUNT, buf); @@ -2567,6 +2574,10 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo) } else if (!strncmp (key, GLUSTERD_STORE_KEY_COLD_DISPERSE_COUNT, strlen (key))) { volinfo->tier_info.cold_disperse_count = atoi (value); + } else if (!strncmp (key, + GLUSTERD_STORE_KEY_COLD_REDUNDANCY_COUNT, + strlen (key))) { + volinfo->tier_info.cold_redundancy_count = atoi (value); } else if (!strncmp (key, GLUSTERD_STORE_KEY_HOT_COUNT, strlen (key))) { volinfo->tier_info.hot_brick_count = atoi (value); diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h index 7dbd811803a..0a243d399a1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.h +++ b/xlators/mgmt/glusterd/src/glusterd-store.h @@ -68,6 +68,7 @@ typedef enum glusterd_store_ver_ac_{ #define GLUSTERD_STORE_KEY_COLD_COUNT "cold_count" #define GLUSTERD_STORE_KEY_COLD_REPLICA_COUNT "cold_replica_count" #define GLUSTERD_STORE_KEY_COLD_DISPERSE_COUNT "cold_disperse_count" +#define GLUSTERD_STORE_KEY_COLD_REDUNDANCY_COUNT "cold_redundancy_count" #define GLUSTERD_STORE_KEY_HOT_TYPE "hot_type" #define GLUSTERD_STORE_KEY_HOT_COUNT "hot_count" #define GLUSTERD_STORE_KEY_HOT_REPLICA_COUNT "hot_replica_count" diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 3b6a8c03b43..019a87e982c 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -3355,6 +3355,7 @@ volume_volgen_graph_build_clusters_tier (volgen_graph_t *graph, volinfo->brick_count = volinfo->tier_info.cold_brick_count; volinfo->replica_count = volinfo->tier_info.cold_replica_count; volinfo->disperse_count = volinfo->tier_info.cold_disperse_count; + volinfo->redundancy_count = volinfo->tier_info.cold_redundancy_count; volinfo->type = volinfo->tier_info.cold_type; sprintf (volinfo->volname, "%s-cold", st_volname); diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index 812a4434415..3f2ff45f1a1 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -309,6 +309,7 @@ typedef struct tier_info_ { int cold_replica_count; int cold_disperse_count; int cold_dist_leaf_count; + int cold_redundancy_count; int hot_type; int hot_brick_count; int hot_replica_count; @@ -896,6 +897,10 @@ glusterd_fetchspec_notify (xlator_t *this); int glusterd_fetchsnap_notify (xlator_t *this); +int +glusterd_add_tier_volume_detail_to_dict (glusterd_volinfo_t *volinfo, + dict_t *volumes, int count); + int glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, dict_t *volumes, int count); -- cgit