diff options
author | hari gowtham <hgowtham@redhat.com> | 2016-07-12 16:40:28 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2017-01-16 20:49:47 -0800 |
commit | 3263d1c4f4b7efd1a018c17e1ba4dd9245094f48 (patch) | |
tree | dc1ca7a0236244ccd4dc4d8cd157afe8e543f6f7 /xlators/mgmt/glusterd/src/glusterd-store.c | |
parent | 514522d12e15e5632a0ff89785618b37dad7f5dd (diff) |
tier : Tier as a service
tierd is implemented by separating from rebalance process.
The commands affected:
1) Attach tier will trigger this process instead of old one
2) tier start and tier start force will also trigger this process.
3) volume status [tier] will show tier daemon as a process instead
of task and normal tier status and tier detach status works.
4) tier stop implemented.
5) detach tier implemented separately along with new detach tier
status
6) volume tier volname status will work using the changes.
7) volume set works
This patch has separated the tier translator from the legacy
DHT rebalance code. It now sends the RPCs from the CLI
to glusterd separate to the DHT rebalance code.
The daemon is now a service, similar to the snapshot daemon,
and can be viewed using the volume status command.
The code for the validation and commit phase are the same
as the earlier tier validation code in DHT rebalance.
The “brickop” phase has been changed so that the status
command can use this framework.
The service management framework is now used.
DHT rebalance does not use this framework.
This service framework takes care of :
*) spawning the daemon, killing it and other such processes.
*) volume set options , which are written on the volfile.
*) restart and reconfigure functions. Restart is to restart
the daemon at two points
1)after gluster goes down and comes up.
2) to stop detach tier.
*) reconfigure is used to make immediate volfile changes.
By doing this, we don’t restart the daemon.
it has the code to rewrite the volfile for topological
changes too (which comes into place during add and remove brick).
With this patch the log, pid, and volfile are separated
and put into respective directories.
Change-Id: I3681d0d66894714b55aa02ca2a30ac000362a399
BUG: 1313838
Signed-off-by: hari gowtham <hgowtham@redhat.com>
Reviewed-on: http://review.gluster.org/13365
Smoke: Gluster Build System <jenkins@build.gluster.org>
Tested-by: hari gowtham <hari.gowtham005@gmail.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 151 |
1 files changed, 147 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 8e37c671909..710a92c98c3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -1034,6 +1034,12 @@ glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo) buf); if (ret) goto out; + + snprintf (buf, sizeof (buf), "%d", volinfo->is_tier_enabled); + ret = gf_store_save_value (fd, GF_TIER_ENABLED, buf); + if (ret) + goto out; + } ret = glusterd_volume_write_tier_details (fd, volinfo); @@ -1358,6 +1364,91 @@ _gd_store_rebalance_dict (dict_t *dict, char *key, data_t *value, void *data) } int32_t +glusterd_store_state_tier_write (int fd, glusterd_volinfo_t *volinfo) +{ + int ret = -1; + char buf[PATH_MAX] = {0, }; + + GF_VALIDATE_OR_GOTO (THIS->name, (fd > 0), out); + GF_VALIDATE_OR_GOTO (THIS->name, volinfo, out); + + /*tier counter values are stored here. so that after restart + * of glusterd tier resumes at the state is was brought down + */ + + if (volinfo->tier.defrag_cmd == GF_DEFRAG_CMD_STATUS) { + ret = 0; + goto out; + } + + snprintf (buf, sizeof (buf), "%d", volinfo->tier.defrag_status); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_TIER_STATUS, + buf); + if (ret) + goto out; + + + snprintf (buf, sizeof (buf), "%d", volinfo->tier.op); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_TIER_DETACH_OP, buf); + if (ret) + goto out; + + snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->tier.rebalance_files); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_MIGRATED_FILES, + buf); + if (ret) + goto out; + + snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->tier.rebalance_data); + ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_MIGRATED_SIZE, + buf); + if (ret) + goto out; + + snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->tier.lookedup_files); + ret = gf_store_save_value (fd, + GLUSTERD_STORE_KEY_VOL_MIGRATIONS_SCANNED, + buf); + if (ret) + goto out; + + snprintf (buf, sizeof (buf), "%"PRIu64, + volinfo->tier.rebalance_failures); + ret = gf_store_save_value (fd, + GLUSTERD_STORE_KEY_VOL_MIGRATIONS_FAILURES, + buf); + if (ret) + goto out; + + snprintf (buf, sizeof (buf), "%"PRIu64, volinfo->tier.skipped_files); + ret = gf_store_save_value (fd, + GLUSTERD_STORE_KEY_VOL_MIGRATIONS_SKIPPED, + buf); + if (ret) + goto out; + + snprintf (buf, sizeof (buf), "%f", volinfo->tier.rebalance_time); + ret = gf_store_save_value (fd, + GLUSTERD_STORE_KEY_VOL_MIGRATION_RUN_TIME, + buf); + if (ret) + goto out; + + gf_uuid_unparse (volinfo->tier.rebalance_id, buf); + ret = gf_store_save_value (fd, GF_TIER_TID_KEY, buf); + if (ret) + goto out; + + if (volinfo->tier.dict) { + dict_foreach (volinfo->tier.dict, _gd_store_rebalance_dict, + &fd); + } +out: + gf_msg_debug (THIS->name, 0, "Returning %d", ret); + return ret; +} + +int32_t glusterd_store_node_state_write (int fd, glusterd_volinfo_t *volinfo) { int ret = -1; @@ -1454,6 +1545,12 @@ glusterd_store_perform_node_state_store (glusterd_volinfo_t *volinfo) if (ret) goto out; + if (volinfo->type == GF_CLUSTER_TYPE_TIER) { + ret = glusterd_store_state_tier_write (fd, volinfo); + if (ret) + goto out; + } + ret = gf_store_rename_tmppath (volinfo->node_state_shandle); if (ret) goto out; @@ -2559,6 +2656,41 @@ glusterd_store_retrieve_node_state (glusterd_volinfo_t *volinfo) } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_DEFRAG_RUN_TIME, strlen (GLUSTERD_STORE_KEY_VOL_DEFRAG_RUN_TIME))) { volinfo->rebal.rebalance_time = atoi (value); + + /* if none of the above keys match then its related to tier + * so we get the values and store it on volinfo->tier + */ + } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_TIER_STATUS, + strlen (GLUSTERD_STORE_KEY_VOL_TIER_STATUS))) { + volinfo->tier.defrag_status = atoi (value); + } else if (!strncmp (key, GF_TIER_TID_KEY, + strlen (GF_TIER_TID_KEY))) { + gf_uuid_parse (value, volinfo->tier.rebalance_id); + } else if (!strncmp (key, GLUSTERD_STORE_KEY_TIER_DETACH_OP, + strlen (GLUSTERD_STORE_KEY_TIER_DETACH_OP))) { + volinfo->tier.op = atoi (value); + } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_MIGRATED_FILES, + strlen (GLUSTERD_STORE_KEY_VOL_MIGRATED_FILES))) { + volinfo->tier.rebalance_files = atoi (value); + } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_MIGRATED_SIZE, + strlen (GLUSTERD_STORE_KEY_VOL_MIGRATED_SIZE))) { + volinfo->tier.rebalance_data = atoi (value); + } else if (!strncmp (key, + GLUSTERD_STORE_KEY_VOL_MIGRATIONS_SCANNED, + strlen (GLUSTERD_STORE_KEY_VOL_MIGRATIONS_SCANNED))) { + volinfo->tier.lookedup_files = atoi (value); + } else if (!strncmp (key, + GLUSTERD_STORE_KEY_VOL_MIGRATIONS_FAILURES, + strlen (GLUSTERD_STORE_KEY_VOL_MIGRATIONS_FAILURES))) { + volinfo->tier.rebalance_failures = atoi (value); + } else if (!strncmp (key, + GLUSTERD_STORE_KEY_VOL_MIGRATIONS_SKIPPED, + strlen (GLUSTERD_STORE_KEY_VOL_MIGRATIONS_SKIPPED))) { + volinfo->tier.skipped_files = atoi (value); + } else if (!strncmp (key, + GLUSTERD_STORE_KEY_VOL_MIGRATION_RUN_TIME, + strlen (GLUSTERD_STORE_KEY_VOL_MIGRATION_RUN_TIME))) { + volinfo->tier.rebalance_time = atoi (value); } else { if (!tmp_dict) { tmp_dict = dict_new (); @@ -2593,8 +2725,12 @@ glusterd_store_retrieve_node_state (glusterd_volinfo_t *volinfo) ret = gf_store_iter_get_next (iter, &key, &value, &op_errno); } - if (tmp_dict) - volinfo->rebal.dict = dict_ref (tmp_dict); + if (tmp_dict) { + if (volinfo->type == GF_CLUSTER_TYPE_TIER) + volinfo->tier.dict = dict_ref (tmp_dict); + else + volinfo->rebal.dict = dict_ref (tmp_dict); + } if (op_errno != GD_STORE_EOF) { ret = -1; @@ -2609,8 +2745,12 @@ glusterd_store_retrieve_node_state (glusterd_volinfo_t *volinfo) out: if (dup_value) GF_FREE (dup_value); - if (ret && volinfo->rebal.dict) - dict_unref (volinfo->rebal.dict); + if (ret) { + if (volinfo->rebal.dict) + dict_unref (volinfo->rebal.dict); + else if (volinfo->tier.dict) + dict_unref (volinfo->tier.dict); + } if (tmp_dict) dict_unref (tmp_dict); @@ -2757,6 +2897,9 @@ glusterd_store_update_volinfo (glusterd_volinfo_t *volinfo) strlen (GLUSTERD_STORE_KEY_PARENT_VOLNAME))) { strncpy (volinfo->parent_volname, value, sizeof(volinfo->parent_volname) - 1); + } else if (!strncmp (key, GF_TIER_ENABLED, + strlen (GF_TIER_ENABLED))) { + volinfo->is_tier_enabled = atoi (value); } else if (!strncmp (key, GLUSTERD_STORE_KEY_COLD_COUNT, strlen (key))) { volinfo->tier_info.cold_brick_count = atoi (value); |