diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2013-07-29 14:44:40 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2013-07-31 01:41:45 -0700 |
commit | 177f32e5b0d73336b2d5bde08bafff186b65e211 (patch) | |
tree | 21e6137739ba04e5b6cfb259a782f37ac2a1e171 /xlators/cluster/afr/src/afr-self-heal-data.c | |
parent | acf8cfdf698aa3ebe42ed55bba8be4f85b751c29 (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/cluster/afr/src/afr-self-heal-data.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-data.c | 59 |
1 files changed, 59 insertions, 0 deletions
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", |