From d133071e7ced1794e09ffe4ef8cb14cf5b9f7e75 Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Wed, 29 Apr 2015 12:00:40 +0530 Subject: glusterd/tiering: Exchange tier info during glusted handshake Change-Id: Ibc2f8eeb32d3e5dfd6945ca8a6d5f0f80a78ebac BUG: 1211264 Signed-off-by: Mohammed Rafi KC Reviewed-on: http://review.gluster.org/10449 Reviewed-by: Kaushal M Tested-by: Gluster Build System Tested-by: NetBSD Build System --- xlators/mgmt/glusterd/src/glusterd-utils.c | 154 +++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index b19813cbefb..1c2299db016 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -2168,6 +2168,68 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo, memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s%d.transport_type", prefix, count); ret = dict_set_uint32 (dict, key, volinfo->transport_type); + if (ret) + goto out; + + /* tiering related variables */ + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_brick_count", prefix, count); + ret = dict_set_uint32 (dict, key, volinfo->tier_info.cold_brick_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_type", prefix, count); + ret = dict_set_uint32 (dict, key, volinfo->tier_info.cold_type); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_replica_count", prefix, count); + ret = dict_set_uint32 (dict, key, + volinfo->tier_info.cold_replica_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_disperse_count", prefix, count); + ret = dict_set_uint32 (dict, key, + volinfo->tier_info.cold_disperse_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_redundancy_count", + prefix, count); + ret = dict_set_uint32 (dict, key, + volinfo->tier_info.cold_redundancy_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_dist_count", prefix, count); + ret = dict_set_uint32 (dict, key, + volinfo->tier_info.cold_dist_leaf_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.hot_brick_count", prefix, count); + ret = dict_set_uint32 (dict, key, volinfo->tier_info.hot_brick_count); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.hot_type", prefix, count); + ret = dict_set_uint32 (dict, key, volinfo->tier_info.hot_type); + if (ret) + goto out; + + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.hot_replica_count", prefix, count); + ret = dict_set_uint32 (dict, key, + volinfo->tier_info.hot_replica_count); if (ret) goto out; @@ -3169,6 +3231,98 @@ glusterd_import_volinfo (dict_t *peer_data, int count, if (ret) gf_log (THIS->name, GF_LOG_INFO, "peer is possibly old version"); + + /* not having a 'hot_brick_count' key is not a error + (as peer may be of old version) */ + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.hot_brick_count", prefix, count); + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.hot_brick_count); + if (ret) + gf_log (THIS->name, GF_LOG_DEBUG, + "peer is possibly old version"); + + /* not having a 'hot_type' key is not a error + (as peer may be of old version) */ + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.hot_type", prefix, count); + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.hot_type); + if (ret) + gf_log (THIS->name, GF_LOG_DEBUG, + "peer is possibly old version"); + + /* not having a 'hot_replica_count' key is not a error + (as peer may be of old version) */ + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.hot_replica_count", prefix, count); + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.hot_replica_count); + if (ret) + gf_log (THIS->name, GF_LOG_DEBUG, + "peer is possibly old version"); + + /* not having a 'cold_brick_count' key is not a error + (as peer may be of old version) */ + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_brick_count", prefix, count); + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_brick_count); + if (ret) + gf_log (THIS->name, GF_LOG_DEBUG, + "peer is possibly old version"); + + /* not having a 'cold_type' key is not a error + (as peer may be of old version) */ + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_type", prefix, count); + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_type); + if (ret) + gf_log (THIS->name, GF_LOG_DEBUG, + "peer is possibly old version"); + + /* not having a 'cold_replica_count' key is not a error + (as peer may be of old version) */ + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_replica_count", prefix, count); + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_replica_count); + if (ret) + gf_log (THIS->name, GF_LOG_DEBUG, + "peer is possibly old version"); + + /* not having a 'cold_disperse_count' key is not a error + (as peer may be of old version) */ + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_disperse_count", prefix, count); + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_disperse_count); + if (ret) + gf_log (THIS->name, GF_LOG_DEBUG, + "peer is possibly old version"); + + /* not having a 'cold_redundancy_count' key is not a error + (as peer may be of old version) */ + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_redundancy_count", + prefix, count); + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_redundancy_count); + if (ret) + gf_log (THIS->name, GF_LOG_DEBUG, + "peer is possibly old version"); + + /* not having a 'cold_dist_count' key is not a error + (as peer may be of old version) */ + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "%s%d.cold_dist_count", prefix, count); + ret = dict_get_int32 (peer_data, key, + &new_volinfo->tier_info.cold_dist_leaf_count); + if (ret) + gf_log (THIS->name, GF_LOG_DEBUG, + "peer is possibly old version"); + new_volinfo->subvol_count = new_volinfo->brick_count/ glusterd_get_dist_leaf_count (new_volinfo); memset (key, 0, sizeof (key)); -- cgit