summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-self-heal-common.c
diff options
context:
space:
mode:
authorVenkatesh Somyajulu <vsomyaju@redhat.com>2013-08-28 17:39:23 +0530
committerAnand Avati <avati@redhat.com>2013-08-29 15:50:28 -0700
commit85b6dcfb533c5b04038808135a581eb7ca9fd61d (patch)
tree3b0f81803fab72c0becdef542e53fdb87895a35f /xlators/cluster/afr/src/afr-self-heal-common.c
parent479087c1e670faea4a0ef7a6d13a9869ef9de69f (diff)
cluster/afr: Improvement in logging of self heal completion status
Additional information for source and sinks are added. Change-Id: I1704956ff86ac3ae36744efe7499c1d1c43faeaf BUG: 968301 Signed-off-by: Venkatesh Somyajulu <vsomyaju@redhat.com> Reviewed-on: http://review.gluster.org/5638 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-common.c')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c63
1 files changed, 46 insertions, 17 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index e6a8092..f82ce23 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -18,12 +18,24 @@
#include "afr-self-heal.h"
#include "pump.h"
-#define ADD_FMT_STRING(msg, off, sh_str, status) \
+#define ADD_FMT_STRING(msg, off, sh_str, status, print_log) \
do { \
if (AFR_SELF_HEAL_NOT_ATTEMPTED != status) { \
off += snprintf (msg + off, sizeof (msg) - off, \
" "sh_str" self heal %s,", \
get_sh_completion_status (status));\
+ print_log = 1; \
+ } \
+ } while (0)
+
+#define ADD_FMT_STRING_SYNC(msg, off, sh_str, status, print_log) \
+ do { \
+ if (AFR_SELF_HEAL_SYNC_BEGIN == status || \
+ AFR_SELF_HEAL_FAILED == status) { \
+ off += snprintf (msg + off, sizeof (msg) - off, \
+ " "sh_str" self heal %s,", \
+ get_sh_completion_status (status));\
+ print_log = 1; \
} \
} while (0)
@@ -2197,6 +2209,7 @@ afr_self_heal_local_init (afr_local_t *l, xlator_t *this)
shc->background = sh->background;
shc->type = sh->type;
shc->data_sh_info = "";
+ shc->metadata_sh_info = "";
uuid_copy (shc->sh_gfid_req, sh->sh_gfid_req);
if (l->loc.path) {
@@ -2716,7 +2729,8 @@ get_sh_completion_status (afr_self_heal_status status)
char *not_attempted = " is not attempted";
char *failed = " failed";
- char *successfull_complt = " is successfully completed";
+ char *started = " is started";
+ char *sync_begin = " is successfully completed";
char *result = " has unknown status";
switch (status)
@@ -2728,7 +2742,10 @@ get_sh_completion_status (afr_self_heal_status status)
result = failed;
break;
case AFR_SELF_HEAL_STARTED:
- result = successfull_complt;
+ result = started;
+ break;
+ case AFR_SELF_HEAL_SYNC_BEGIN:
+ result = sync_begin;
break;
}
@@ -2745,26 +2762,38 @@ afr_log_self_heal_completion_status (afr_local_t *local, gf_loglevel_t loglvl)
afr_sh_status_for_all_type all_status = sh->afr_all_sh_status;
xlator_t *this = NULL;
size_t off = 0;
+ int data_sh = 0;
+ int metadata_sh = 0;
+ int print_log = 0;
this = THIS;
ADD_FMT_STRING (sh_log, off, "gfid or missing entry",
- all_status.gfid_or_missing_entry_self_heal);
- ADD_FMT_STRING (sh_log, off, "metadata", all_status.metadata_self_heal);
+ all_status.gfid_or_missing_entry_self_heal, print_log);
+ ADD_FMT_STRING_SYNC (sh_log, off, "metadata",
+ all_status.metadata_self_heal, print_log);
if (sh->background) {
- ADD_FMT_STRING (sh_log, off, "backgroung data",
- all_status.data_self_heal);
+ ADD_FMT_STRING_SYNC (sh_log, off, "backgroung data",
+ all_status.data_self_heal, print_log);
} else {
- ADD_FMT_STRING (sh_log, off, "foreground data",
- all_status.data_self_heal);
+ ADD_FMT_STRING_SYNC (sh_log, off, "foreground data",
+ all_status.data_self_heal, print_log);
}
- ADD_FMT_STRING (sh_log, off, "entry", all_status.entry_self_heal);
+ ADD_FMT_STRING_SYNC (sh_log, off, "entry", all_status.entry_self_heal,
+ print_log);
- if (AFR_SELF_HEAL_STARTED == all_status.data_self_heal) {
- gf_log (this->name, loglvl, "%s %s on %s", sh_log,
- sh->data_sh_info, local->loc.path);
- } else {
- gf_log (this->name, loglvl, "%s on %s", sh_log,
- local->loc.path);
- }
+ if (AFR_SELF_HEAL_SYNC_BEGIN == all_status.data_self_heal &&
+ strcmp (sh->data_sh_info, "") && sh->data_sh_info )
+ data_sh = 1;
+ if (AFR_SELF_HEAL_SYNC_BEGIN == all_status.metadata_self_heal &&
+ strcmp (sh->metadata_sh_info, "") && sh->metadata_sh_info)
+ metadata_sh = 1;
+
+ if (!print_log)
+ return;
+
+ gf_log (this->name, loglvl, "%s %s %s on %s", sh_log,
+ ((data_sh == 1) ? sh->data_sh_info : ""),
+ ((metadata_sh == 1) ? sh->metadata_sh_info : ""),
+ local->loc.path);
}