From 2b1bf891f550487d2c05fc9e377f0d15d4a08d0a Mon Sep 17 00:00:00 2001 From: Venkatesh Somyajula Date: Fri, 23 Nov 2012 18:12:52 +0530 Subject: Cluster/afr: Fix output for gluster volume heal vn info healed Problem: Whenever gluster volume heal vol full command is executed, the entries stored in the circual buffer for sh->healed are added in the dictionary in the _crawl_post_sh_action function irrespective of whether actual self heal (due to non-zero values in chage log) takes place or not. Fix: Value of key (actual-sh-done) will be set to 1 whenever self heal takes place due to non-zero change log values and if for some FOP self heal daemon finds that no self heal required after examining the pending matrix, the value will be 0. Change-Id: I11fd0b9ee76759af17c5bca6bfafbaf66bcaacbc BUG: 863068 Signed-off-by: Venkatesh Somyajula Reviewed-on: http://review.gluster.org/4181 Reviewed-by: Pranith Kumar Karampuri Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/cluster/afr/src/afr-self-heald.c | 48 +++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'xlators/cluster/afr/src/afr-self-heald.c') diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c index b3dee3f5..214c0fff 100644 --- a/xlators/cluster/afr/src/afr-self-heald.c +++ b/xlators/cluster/afr/src/afr-self-heald.c @@ -307,7 +307,7 @@ _crawl_post_sh_action (xlator_t *this, loc_t *parent, loc_t *child, shd_event_t *event = NULL; int32_t sh_failed = 0; gf_boolean_t split_brain = 0; - + int32_t actual_sh_done = 0; priv = this->private; shd = &priv->shd; if (crawl_data->crawl == INDEX) { @@ -328,26 +328,42 @@ _crawl_post_sh_action (xlator_t *this, loc_t *parent, loc_t *child, } } - if (xattr_rsp) + if (xattr_rsp) { ret = dict_get_int32 (xattr_rsp, "sh-failed", &sh_failed); + ret = dict_get_int32 (xattr_rsp, "actual-sh-done", &actual_sh_done); + } + split_brain = afr_is_split_brain (this, child->inode); - if ((op_ret < 0 && op_errno == EIO) || split_brain) + + if ((op_ret < 0 && op_errno == EIO) || split_brain) { eh = shd->split_brain; - else if ((op_ret < 0) || sh_failed) + } else if ((op_ret < 0) || sh_failed) { eh = shd->heal_failed; - else - eh = shd->healed; + } else if (actual_sh_done == 1) { + eh = shd->healed; + } + ret = -1; - event = GF_CALLOC (1, sizeof (*event), gf_afr_mt_shd_event_t); - if (!event) - goto out; - event->child = crawl_data->child; - event->path = path; - ret = eh_save_history (eh, event); - if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "%s:Failed to save to " - "event history, (%d, %s)", path, op_ret, strerror (op_errno)); - goto out; + + if (eh != NULL) { + event = GF_CALLOC (1, sizeof (*event), gf_afr_mt_shd_event_t); + if (!event) + goto out; + event->child = crawl_data->child; + event->path = path; + + ret = eh_save_history (eh, event); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "%s:Failed to save " + "to event history, (%d, %s)", path, op_ret, + strerror (op_errno)); + + goto out; + } + } else { + gf_log (this->name, GF_LOG_DEBUG, "%s:Self heal already done ", + path); + } ret = 0; out: -- cgit