From 26843b00447cc14427b4f02ca136033b56ca093f Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Fri, 3 Jan 2014 14:44:01 +0530 Subject: heal: Enable logging for glfsheal. logs will be written to /glfsheal-.log Moved some non-essential frequent logs to DEBUG. BUG: 1039544 Change-Id: I2aceda6e3092f8c5052e7a4b8b5dec3cdeebd9a9 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/7481 Tested-by: Gluster Build System Reviewed-by: Ravishankar N Reviewed-by: Vijay Bellur --- heal/src/glfs-heal.c | 25 +++++++++++++++++++------ xlators/cluster/afr/src/afr-common.c | 4 ++-- xlators/cluster/afr/src/afr-self-heal-common.c | 3 +++ xlators/cluster/afr/src/afr-self-heal-data.c | 6 +++--- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c index 9e2be12ab4c..f198cbee00e 100644 --- a/heal/src/glfs-heal.c +++ b/heal/src/glfs-heal.c @@ -18,6 +18,8 @@ #include #include +#define DEFAULT_HEAL_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs" + int glfsh_link_inode_update_loc (loc_t *loc, struct iatt *iattr) { @@ -212,8 +214,7 @@ glfsh_process_entries (xlator_t *xl, loc_t *parentloc, gf_dirent_t *entries, goto out; uuid_parse (entry->d_name, entry_loc.gfid); - //TODO: put gfid-path - glfs_loc_touchup (&entry_loc); + entry_loc.path = gf_strdup (uuid_utoa (entry_loc.gfid)); ret = syncop_lookup (xl->parents->xlator, &entry_loc, xattr_req, &iattr, &xattr_rsp, &parent); if (ret < 0) @@ -407,6 +408,7 @@ main (int argc, char **argv) xlator_t *top_subvol = NULL; xlator_t *xl = NULL; loc_t rootloc = {0}; + char logfilepath[PATH_MAX]; if (argc != 2) { printf ("Usage: %s \n", argv[0]); @@ -423,6 +425,15 @@ main (int argc, char **argv) } ret = glfs_set_volfile_server (fs, "tcp", "localhost", 24007); + snprintf (logfilepath, sizeof (logfilepath), + DEFAULT_HEAL_LOG_FILE_DIRECTORY"/glfsheal-%s.log", volname); + ret = glfs_set_logging(fs, logfilepath, GF_LOG_INFO); + if (ret < 0) { + ret = -1; + printf ("Not able to initialize volume '%s'\n", volname); + goto out; + } + ret = glfs_init (fs); if (ret < 0) { @@ -473,16 +484,18 @@ main (int argc, char **argv) } loc_wipe (&rootloc); - glfs_subvol_done (fs, top_subvol); - glfs_fini (fs); + //Calling this sometimes gives log messages on stderr. + //There is no graceful way of disabling that at the moment, + //since this process dies anyway, ignoring cleanup for now. + //glfs_fini (fs); return 0; out: if (fs && top_subvol) glfs_subvol_done (fs, top_subvol); loc_wipe (&rootloc); - if (fs) - glfs_fini (fs); + //if (fs) + // glfs_fini (fs); return ret; } diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 7dafa0529fa..1e57ebb9d7c 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -2292,7 +2292,7 @@ afr_set_root_inode_on_first_lookup (afr_local_t *local, xlator_t *this, goto out; priv = this->private; if ((priv->first_lookup)) { - gf_log (this->name, GF_LOG_INFO, "added root inode"); + gf_log (this->name, GF_LOG_DEBUG, "added root inode"); priv->root_inode = inode_ref (inode); priv->first_lookup = 0; } @@ -2353,7 +2353,7 @@ afr_discovery_cbk (call_frame_t *frame, void *cookie, xlator_t *this, */ if (is_local) { child_index = (int32_t)(long)cookie; - gf_log (this->name, GF_LOG_INFO, + gf_log (this->name, GF_LOG_DEBUG, "selecting local read_child %s", priv->children[child_index]->name); priv->read_child = child_index; diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index ab9e44b41e0..4916bf45d68 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -2346,6 +2346,9 @@ afr_self_heal_completion_cbk (call_frame_t *bgsh_frame, xlator_t *this) loglevel = GF_LOG_DEBUG; } + if (sh->dry_run) + loglevel = GF_LOG_DEBUG; + afr_log_self_heal_completion_status (local, loglevel); FRAME_SU_UNDO (bgsh_frame, afr_local_t); diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c index 5c53f6a6a06..02c91c95710 100644 --- a/xlators/cluster/afr/src/afr-self-heal-data.c +++ b/xlators/cluster/afr/src/afr-self-heal-data.c @@ -947,7 +947,7 @@ afr_sh_data_fix (call_frame_t *frame, xlator_t *this) afr_sh_mark_source_sinks (frame, this); if (sh->active_sinks == 0) { - gf_log (this->name, GF_LOG_INFO, + gf_log (this->name, GF_LOG_DEBUG, "no active sinks for performing self-heal on file %s", local->loc.path); afr_sh_data_finish (frame, this); @@ -1171,7 +1171,7 @@ afr_sh_data_fstat_cbk (call_frame_t *frame, void *cookie, * the pending data xattrs which need to be erased */ if (!afr_sh_data_proceed (sh->success_count)) { - gf_log (this->name, GF_LOG_ERROR, "inspecting metadata " + gf_log (this->name, GF_LOG_DEBUG, "inspecting metadata " "succeeded on < %d children, aborting " "self-heal for %s", AFR_SH_MIN_PARTICIPANTS, local->loc.path); @@ -1283,7 +1283,7 @@ afr_sh_data_fxattrop_cbk (call_frame_t *frame, void *cookie, call_count = afr_frame_return (frame); if (call_count == 0) { if (!afr_sh_data_proceed (sh->success_count)) { - gf_log (this->name, GF_LOG_ERROR, "%s, inspecting " + gf_log (this->name, GF_LOG_DEBUG, "%s, inspecting " "change log succeeded on < %d children", local->loc.path, AFR_SH_MIN_PARTICIPANTS); afr_sh_data_fail (frame, this); -- cgit