diff options
-rw-r--r-- | cli/src/cli-rpc-ops.c | 182 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 9 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 80 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 11 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.h | 1 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 1 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 5 |
7 files changed, 252 insertions, 37 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index e81e8b0828f..f3ed8adfdc2 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -581,6 +581,150 @@ print_brick_details (dict_t *dict, int volcount, int start_index, out: return ret; } +void +gf_cli_print_number_of_bricks (int type, int brick_count, int dist_count, + int stripe_count, int replica_count, + int disperse_count, int redundancy_count) +{ + if (type == GF_CLUSTER_TYPE_STRIPE_REPLICATE) { + cli_out ("Number of Bricks: %d x %d x %d = %d", + (brick_count / dist_count), + stripe_count, + replica_count, + brick_count); + } else if (type == GF_CLUSTER_TYPE_NONE || + type == GF_CLUSTER_TYPE_TIER) { + cli_out ("Number of Bricks: %d", brick_count); + } else if (type == GF_CLUSTER_TYPE_DISPERSE) { + cli_out ("Number of Bricks: %d x (%d + %d) = %d", + (brick_count / dist_count), + disperse_count - redundancy_count, + redundancy_count, brick_count); + } else { + /* For both replicate and stripe, dist_count is + good enough */ + cli_out ("Number of Bricks: %d x %d = %d", + (brick_count / dist_count), + dist_count, brick_count); + } + +} + +int +gf_cli_print_tier_info (dict_t *dict, int i, int brick_count) +{ + + int hot_brick_count = -1; + int cold_type = 0; + int cold_brick_count = 0; + int cold_replica_count = 0; + int cold_disperse_count = 0; + int cold_redundancy_count = 0; + int cold_dist_count = 0; + int hot_type = 0; + int hot_replica_count = 0; + int hot_dist_count = 0; + int ret = -1; + int vol_type = -1; + char key[256] = {0,}; + + GF_ASSERT (dict); + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.cold_brick_count", i); + ret = dict_get_int32 (dict, key, &cold_brick_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.cold_type", i); + ret = dict_get_int32 (dict, key, &cold_type); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.cold_dist_count", i); + ret = dict_get_int32 (dict, key, &cold_dist_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.cold_replica_count", i); + ret = dict_get_int32 (dict, key, &cold_replica_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.cold_disperse_count", i); + ret = dict_get_int32 (dict, key, &cold_disperse_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, + "volume%d.cold_redundancy_count", i); + ret = dict_get_int32 (dict, key, + &cold_redundancy_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.hot_brick_count", i); + ret = dict_get_int32 (dict, key, &hot_brick_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.hot_type", i); + ret = dict_get_int32 (dict, key, &hot_type); + if (ret) + goto out; + memset (key, 0, sizeof (key)); + snprintf (key, 256, "volume%d.hot_replica_count", i); + ret = dict_get_int32 (dict, key, &hot_replica_count); + if (ret) + goto out; + + cli_out ("Hot Tier :"); + vol_type = hot_type; + hot_dist_count = (hot_replica_count ? + hot_replica_count : 1); + if ((hot_type != GF_CLUSTER_TYPE_TIER) && + (hot_type > 0) && + (hot_dist_count < hot_brick_count)) + vol_type = hot_type + GF_CLUSTER_TYPE_MAX - 1; + + cli_out ("Hot Tier Type : %s", + cli_vol_type_str[vol_type]); + gf_cli_print_number_of_bricks (hot_type, + hot_brick_count, hot_dist_count, 0, + hot_replica_count, 0, 0); + + ret = print_brick_details (dict, i, 1, hot_brick_count); + if (ret) + goto out; + + cli_out ("Cold Bricks:"); + vol_type = cold_type; + if ((cold_type != GF_CLUSTER_TYPE_TIER) && + (cold_type > 0) && + (cold_dist_count < cold_brick_count)) + vol_type = cold_type + GF_CLUSTER_TYPE_MAX - 1; + + cli_out ("Cold Tier Type : %s", + cli_vol_type_str[vol_type]); + gf_cli_print_number_of_bricks (cold_type, + cold_brick_count, + cold_dist_count, 0, cold_replica_count, + cold_disperse_count, cold_redundancy_count); + + ret = print_brick_details (dict, i, hot_brick_count+1, + brick_count); + if (ret) + goto out; +out: + return ret; +} int gf_cli_get_volume_cbk (struct rpc_req *req, struct iovec *iov, @@ -593,7 +737,6 @@ gf_cli_get_volume_cbk (struct rpc_req *req, struct iovec *iov, int32_t status = 0; int32_t type = 0; int32_t brick_count = 0; - int32_t hot_brick_count = -1; int32_t dist_count = 0; int32_t stripe_count = 0; int32_t replica_count = 0; @@ -737,11 +880,6 @@ xml_output: if (ret) goto out; - snprintf (key, 256, "volume%d.hot_brick_count", i); - ret = dict_get_int32 (dict, key, &hot_brick_count); - if (ret) - goto out; - snprintf (key, 256, "volume%d.dist_count", i); ret = dict_get_int32 (dict, key, &dist_count); if (ret) @@ -822,27 +960,9 @@ next: #else caps = 0; /* Avoid compiler warnings when BD not enabled */ #endif - - if (type == GF_CLUSTER_TYPE_STRIPE_REPLICATE) { - cli_out ("Number of Bricks: %d x %d x %d = %d", - (brick_count / dist_count), - stripe_count, - replica_count, - brick_count); - } else if (type == GF_CLUSTER_TYPE_NONE) { - cli_out ("Number of Bricks: %d", brick_count); - } else if (type == GF_CLUSTER_TYPE_DISPERSE) { - cli_out ("Number of Bricks: %d x (%d + %d) = %d", - (brick_count / dist_count), - disperse_count - redundancy_count, - redundancy_count, brick_count); - } else { - /* For both replicate and stripe, dist_count is - good enough */ - cli_out ("Number of Bricks: %d x %d = %d", - (brick_count / dist_count), - dist_count, brick_count); - } + gf_cli_print_number_of_bricks (type, brick_count, + dist_count, stripe_count, replica_count, + disperse_count, redundancy_count); cli_out ("Transport-type: %s", ((transport == 0)?"tcp": @@ -854,13 +974,7 @@ next: local->get_vol.volname = gf_strdup (volname); if (type == GF_CLUSTER_TYPE_TIER) { - cli_out ("Hot Bricks:"); - ret = print_brick_details (dict, i, j, hot_brick_count); - if (ret) - goto out; - cli_out ("Cold Bricks:"); - ret = print_brick_details (dict, i, hot_brick_count+1, - brick_count); + ret = gf_cli_print_tier_info (dict, i, brick_count); if (ret) goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index 1ea520d286d..75c7926e49e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -1907,6 +1907,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) @@ -1991,9 +1992,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 @@ -311,6 +311,79 @@ _build_option_key (dict_t *d, char *k, data_t *v, void *tmp) } 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 e2bb59bb97b..568ce61fb39 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 37a5737060c..335513b4934 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; @@ -899,6 +900,10 @@ 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); |