From a70231c78aaea436575d427a1386a64d1471b776 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Fri, 27 Feb 2015 16:01:31 +0530 Subject: cluster/ec: Add self-heal-daemon command handlers This patch introduces the changes required in ec xlator to handle index/full heal. Index healer threads: Ec xlator start an index healer thread per local brick. This thread keeps waking up every minute to check if there are any files to be healed based on the indices kept in index directory. Whenever child_up event comes, then also this index healer thread wakes up and crawls the indices and triggers heal. When self-heal-daemon is disabled on this particular volume then the healer thread keeps waiting until it is enabled again to perform heals. Full healer threads: Ec xlator starts a full healer thread for the local subvolume provided by glusterd to perform full crawl on the directory hierarchy to perform heals. Once the crawl completes the thread exits if no more full heals are issued. Changed xl-op prefix GF_AFR_OP to GF_SHD_OP to make it more generic. Change-Id: Idf9b2735d779a6253717be064173dfde6f8f824b BUG: 1177601 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/9787 Tested-by: Gluster Build System Reviewed-by: Ravishankar N Reviewed-by: Vijay Bellur --- xlators/cluster/ec/src/ec.c | 77 ++++++++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 21 deletions(-) (limited to 'xlators/cluster/ec/src/ec.c') diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c index 219494b961e..9fecde4c495 100644 --- a/xlators/cluster/ec/src/ec.c +++ b/xlators/cluster/ec/src/ec.c @@ -18,6 +18,7 @@ #include "ec-fops.h" #include "ec-method.h" #include "ec.h" +#include "ec-heald.h" #define EC_MAX_FRAGMENTS EC_METHOD_MAX_FRAGMENTS /* The maximum number of nodes is derived from the maximum allowed fragments @@ -186,8 +187,8 @@ reconfigure (xlator_t *this, dict_t *options) { ec_t *ec = this->private; - GF_OPTION_RECONF ("self-heal-daemon", ec->shd, options, bool, failed); - GF_OPTION_RECONF ("iam-self-heal-daemon", ec->iamshd, options, + GF_OPTION_RECONF ("self-heal-daemon", ec->shd.enabled, options, bool, failed); + GF_OPTION_RECONF ("iam-self-heal-daemon", ec->shd.iamshd, options, bool, failed); return 0; @@ -329,13 +330,35 @@ ec_handle_down (xlator_t *this, ec_t *ec, int32_t idx) } int32_t -notify (xlator_t *this, int32_t event, void *data, ...) -{ - ec_t * ec = this->private; - int32_t idx = 0; - int32_t error = 0; - glusterfs_event_t old_event = GF_EVENT_MAXVAL; - glusterfs_event_t new_event = GF_EVENT_MAXVAL; +ec_notify (xlator_t *this, int32_t event, void *data, void *data2) +{ + ec_t *ec = this->private; + int32_t idx = 0; + int32_t error = 0; + glusterfs_event_t old_event = GF_EVENT_MAXVAL; + glusterfs_event_t new_event = GF_EVENT_MAXVAL; + dict_t *input = NULL; + dict_t *output = NULL; + + if (event == GF_EVENT_TRANSLATOR_OP) { + if (!ec->up) { + error = -1; + goto out; + } else { + input = data; + output = data2; + error = ec_xl_op (this, input, output); + } + goto out; + } + + for (idx = 0; idx < ec->nodes; idx++) { + if (ec->xl_list[idx] == data) { + if (event == GF_EVENT_CHILD_UP) + ec_selfheal_childup (ec, idx); + break; + } + } LOCK (&ec->lock); @@ -348,11 +371,6 @@ notify (xlator_t *this, int32_t event, void *data, ...) goto unlock; } - for (idx = 0; idx < ec->nodes; idx++) { - if (ec->xl_list[idx] == data) - break; - } - gf_log (this->name, GF_LOG_TRACE, "NOTIFY(%d): %p, %d", event, data, idx); @@ -381,13 +399,28 @@ notify (xlator_t *this, int32_t event, void *data, ...) if (new_event != GF_EVENT_MAXVAL) error = default_notify (this, new_event, data); } -unlock: - UNLOCK (&ec->lock); + unlock: + UNLOCK (&ec->lock); + + if (event != GF_EVENT_MAXVAL) + return default_notify (this, event, data); +out: + return error; +} + +int32_t +notify (xlator_t *this, int32_t event, void *data, ...) +{ + int ret = -1; + va_list ap; + void *data2 = NULL; - if (event != GF_EVENT_MAXVAL) - return default_notify (this, event, data); + va_start (ap, data); + data2 = va_arg (ap, dict_t*); + va_end (ap); + ret = ec_notify (this, event, data, data2); - return error; + return ret; } int32_t @@ -440,9 +473,11 @@ init (xlator_t *this) } ec_method_initialize(); - GF_OPTION_INIT ("self-heal-daemon", ec->shd, bool, failed); - GF_OPTION_INIT ("iam-self-heal-daemon", ec->iamshd, bool, failed); + GF_OPTION_INIT ("self-heal-daemon", ec->shd.enabled, bool, failed); + GF_OPTION_INIT ("iam-self-heal-daemon", ec->shd.iamshd, bool, failed); + if (ec->shd.iamshd) + ec_selfheal_daemon_init (this); gf_log(this->name, GF_LOG_DEBUG, "Disperse translator initialized."); return 0; -- cgit