summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2013-07-29 14:44:40 +0530
committerVijay Bellur <vbellur@redhat.com>2013-07-31 01:41:45 -0700
commit177f32e5b0d73336b2d5bde08bafff186b65e211 (patch)
tree21e6137739ba04e5b6cfb259a782f37ac2a1e171 /xlators
parentacf8cfdf698aa3ebe42ed55bba8be4f85b751c29 (diff)
cluster/afr: Print self-heal log when self-heal succeeds
Change-Id: I95e47e589419dc6a032cbd8ba01964b6c176c2d5 BUG: 927146 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/5408 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/afr/src/afr-common.c3
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c86
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.h3
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c59
-rw-r--r--xlators/cluster/afr/src/afr.h1
5 files changed, 120 insertions, 32 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index d2b3e46e53f..075f33c618b 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -779,6 +779,9 @@ afr_local_sh_cleanup (afr_local_t *local, xlator_t *this)
sh = &local->self_heal;
priv = this->private;
+ if (sh->data_sh_info && strcmp (sh->data_sh_info, ""))
+ GF_FREE (sh->data_sh_info);
+
GF_FREE (sh->buf);
GF_FREE (sh->parentbufs);
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index 14283163372..929def2429e 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -18,6 +18,16 @@
#include "afr-self-heal.h"
#include "pump.h"
+#define ADD_FMT_STRING(msg, off, sh_str, status) \
+ 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));\
+ } \
+ } while (0)
+
+
void
afr_sh_reset (call_frame_t *frame, xlator_t *this)
{
@@ -141,9 +151,8 @@ afr_sh_print_pending_matrix (int32_t *pending_matrix[], xlator_t *this)
GF_FREE (buf);
}
-void
-afr_sh_print_split_brain_log (int32_t *pending_matrix[], xlator_t *this,
- const char *loc)
+char*
+afr_get_pending_matrix_str (int32_t *pending_matrix[], xlator_t *this)
{
afr_private_t * priv = this->private;
char *buf = NULL;
@@ -173,10 +182,8 @@ afr_sh_print_split_brain_log (int32_t *pending_matrix[], xlator_t *this,
+ (child_count * child_count * pending_entry_strlen);
buf = GF_CALLOC (1, 1 + strlen (msg) + string_length , gf_afr_mt_char);
- if (!buf) {
- buf = "";
+ if (!buf)
goto out;
- }
ptr = buf;
ptr += sprintf (ptr, "%s", msg);
@@ -192,11 +199,27 @@ afr_sh_print_split_brain_log (int32_t *pending_matrix[], xlator_t *this,
ptr += sprintf (ptr, "%s", matrix_end);
out:
+ return buf;
+}
+
+void
+afr_sh_print_split_brain_log (int32_t *pending_matrix[], xlator_t *this,
+ const char *loc)
+{
+ char *buf = NULL;
+ char *free_ptr = NULL;
+
+ buf = afr_get_pending_matrix_str (pending_matrix, this);
+ if (buf)
+ free_ptr = buf;
+ else
+ buf = "";
+
+
gf_log (this->name, GF_LOG_ERROR, "Unable to self-heal contents of '%s'"
" (possible split-brain). Please delete the file from all but "
"the preferred subvolume.%s", loc, buf);
- if (buf)
- GF_FREE (buf);
+ GF_FREE (free_ptr);
return;
}
@@ -2087,6 +2110,7 @@ afr_self_heal_local_init (afr_local_t *l, xlator_t *this)
shc->forced_merge = sh->forced_merge;
shc->background = sh->background;
shc->type = sh->type;
+ shc->data_sh_info = "";
uuid_copy (shc->sh_gfid_req, sh->sh_gfid_req);
if (l->loc.path) {
@@ -2154,6 +2178,8 @@ afr_self_heal_completion_cbk (call_frame_t *bgsh_frame, xlator_t *this)
sizeof(sh_type_str));
if (is_self_heal_failed (sh, AFR_CHECK_ALL) && !priv->shd.iamshd) {
loglevel = GF_LOG_ERROR;
+ } else if (!is_self_heal_failed (sh, AFR_CHECK_ALL)) {
+ loglevel = GF_LOG_INFO;
} else {
loglevel = GF_LOG_DEBUG;
}
@@ -2628,35 +2654,31 @@ void
afr_log_self_heal_completion_status (afr_local_t *local, gf_loglevel_t loglvl)
{
- char *gfid_or_missing_entry_sh = NULL;
- char *metadata_sh = NULL;
- char *data_sh = NULL;
- char *entry_sh = NULL;
-
+ char sh_log[4096] = {0};
afr_self_heal_t *sh = &local->self_heal;
afr_sh_status_for_all_type all_status = sh->afr_all_sh_status;
xlator_t *this = NULL;
+ size_t off = 0;
this = THIS;
- gfid_or_missing_entry_sh = get_sh_completion_status
- (all_status.gfid_or_missing_entry_self_heal);
-
- metadata_sh = get_sh_completion_status (all_status.metadata_self_heal);
-
-
- data_sh = get_sh_completion_status (all_status.data_self_heal);
-
- entry_sh = get_sh_completion_status (all_status.entry_self_heal);
-
-
- gf_log (this->name, loglvl, "%s "
- "gfid or missing entry self heal %s,"
- " medatadata self heal %s,"
- " data self heal %s,"
- " entry self heal %s on %s",
- (sh->background ? "background" : "foreground"),
- gfid_or_missing_entry_sh, metadata_sh, data_sh, entry_sh,
- local->loc.path);
+ 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);
+ if (sh->background) {
+ ADD_FMT_STRING (sh_log, off, "backgroung data",
+ all_status.data_self_heal);
+ } else {
+ ADD_FMT_STRING (sh_log, off, "foreground data",
+ all_status.data_self_heal);
+ }
+ ADD_FMT_STRING (sh_log, off, "entry", all_status.entry_self_heal);
+ 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);
+ }
}
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.h b/xlators/cluster/afr/src/afr-self-heal-common.h
index 9be1fdff924..4732647760d 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.h
+++ b/xlators/cluster/afr/src/afr-self-heal-common.h
@@ -138,4 +138,7 @@ afr_set_self_heal_status (afr_self_heal_t *sh, afr_self_heal_status status);
void
afr_log_self_heal_completion_status (afr_local_t *local, gf_loglevel_t logl);
+
+char*
+afr_get_pending_matrix_str (int32_t *pending_matrix[], xlator_t *this);
#endif /* __AFR_SELF_HEAL_COMMON_H__ */
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index b71c7599564..cab848832a2 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -727,6 +727,64 @@ out:
return ret;
}
+char*
+afr_get_sizes_str (struct iatt *bufs, xlator_t *this)
+{
+ afr_private_t *priv = NULL;
+ int i = 0;
+ char num[128] = {0};
+ size_t len = 0;
+ char *sizes_str = NULL;
+ size_t off = 0;
+ char *fmt_str = "%llu ";
+
+ priv = this->private;
+ for (i = 0; i < priv->child_count; i++) {
+ len += snprintf (num, sizeof (num), fmt_str,
+ (unsigned long long) bufs[i].ia_size);
+ }
+
+ len++;//for '\0'
+ sizes_str = GF_CALLOC (len, sizeof (char), gf_common_mt_char);
+ if (!sizes_str)
+ return NULL;
+
+ for (i = 0; i < priv->child_count; i++) {
+ off += snprintf (sizes_str + off, len - off, fmt_str,
+ (unsigned long long) bufs[i].ia_size);
+ }
+ return sizes_str;
+}
+
+void
+afr_set_data_sh_info_str (afr_self_heal_t *sh, xlator_t *this)
+{
+ char *pending_matrix_str = NULL;
+ char *sizes_str = NULL;
+ afr_private_t *priv = NULL;
+
+ priv = this->private;
+
+ pending_matrix_str = afr_get_pending_matrix_str (sh->pending_matrix,
+ this);
+ if (!pending_matrix_str)
+ pending_matrix_str = "";
+
+ sizes_str = afr_get_sizes_str (sh->buf, this);
+ if (!sizes_str)
+ sizes_str = "";
+
+ gf_asprintf (&sh->data_sh_info, " from %s with %s sizes %s",
+ priv->children[sh->source]->name, sizes_str,
+ pending_matrix_str);
+
+ if (pending_matrix_str && strcmp (pending_matrix_str, ""))
+ GF_FREE (pending_matrix_str);
+
+ if (sizes_str && strcmp (sizes_str, ""))
+ GF_FREE (sizes_str);
+}
+
void
afr_sh_data_fix (call_frame_t *frame, xlator_t *this)
{
@@ -847,6 +905,7 @@ afr_sh_data_fxattrop_fstat_done (call_frame_t *frame, xlator_t *this)
}
afr_sh_data_setattr (frame, this, &sh->buf[tstamp_source]);
} else {
+ afr_set_data_sh_info_str (sh, this);
if (nsources == 0) {
gf_log (this->name, GF_LOG_DEBUG,
"No self-heal needed for %s",
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index bca5c0f79e7..c6e6913df29 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -292,6 +292,7 @@ struct afr_self_heal_ {
uint8_t *checksum;
afr_post_remove_call_t post_remove_call;
+ char *data_sh_info;
loc_t parent_loc;
call_frame_t *orig_frame;
call_frame_t *old_loop_frame;