From 56343cf608f02c2b6dbaef04ae7a897b13a97d42 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Mon, 1 Aug 2016 16:59:33 +0530 Subject: features/libgfchangelog: Log failure in gf_histroy_changelog Add error logs if gf_history_changelog fails. If requested changelog range is not available, log the error and exit instead of continuing the loop and exiting in readdir without logging. Also fixed the duplicate MSGID number in 'changelog-lib-messages.h' > Change-Id: Icd71b89ae23b48a71380657ba5649029c32fabfd > BUG: 1362151 > Signed-off-by: Kotresh HR > Reviewed-on: http://review.gluster.org/15064 > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: Aravinda VK Change-Id: Icd71b89ae23b48a71380657ba5649029c32fabfd BUG: 1365879 Signed-off-by: Kotresh HR (cherry picked from commit 949472d7561d3bfd67d8204e433a25dbc8a596cc) Reviewed-on: http://review.gluster.org/15138 NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Smoke: Gluster Build System Reviewed-by: Aravinda VK --- .../features/changelog/lib/src/changelog-lib-messages.h | 11 +++++++++-- .../features/changelog/lib/src/gf-history-changelog.c | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'xlators') diff --git a/xlators/features/changelog/lib/src/changelog-lib-messages.h b/xlators/features/changelog/lib/src/changelog-lib-messages.h index 976c67f61a9..a6209af71ee 100644 --- a/xlators/features/changelog/lib/src/changelog-lib-messages.h +++ b/xlators/features/changelog/lib/src/changelog-lib-messages.h @@ -45,7 +45,7 @@ */ #define GLFS_COMP_BASE_CHANGELOG_LIB GLFS_MSGID_COMP_CHANGELOG_LIB -#define GLFS_NUM_MESSAGES 28 +#define GLFS_NUM_MESSAGES 32 #define GLFS_MSGID_END (GLFS_COMP_BASE_CHANGELOG_LIB + GLFS_NUM_MESSAGES + 1) #define glfs_msg_start_x GLFS_COMP_BASE_CHANGELOG_LIB,\ @@ -280,8 +280,15 @@ * @recommended action */ #define CHANGELOG_LIB_MSG_PTHREAD_JOIN_FAILED \ - (GLFS_COMP_BASE_CHANGELOG_LIB + 20) + (GLFS_COMP_BASE_CHANGELOG_LIB + 31) +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_LIB_MSG_HIST_FAILED \ + (GLFS_COMP_BASE_CHANGELOG_LIB + 32) #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" #endif /* !_CHANGELOG_MESSAGES_H_ */ diff --git a/xlators/features/changelog/lib/src/gf-history-changelog.c b/xlators/features/changelog/lib/src/gf-history-changelog.c index 389b65f3b16..bc7b451fb08 100644 --- a/xlators/features/changelog/lib/src/gf-history-changelog.c +++ b/xlators/features/changelog/lib/src/gf-history-changelog.c @@ -808,6 +808,9 @@ gf_history_changelog (char* changelog_dir, unsigned long start, ret = pthread_attr_init (&attr); if (ret != 0) { + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_LIB_MSG_PTHREAD_ERROR, + "Pthread init failed"); return -1; } @@ -831,6 +834,10 @@ gf_history_changelog (char* changelog_dir, unsigned long start, /* basic sanity check */ if (start > end || n_parallel <= 0) { + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_LIB_MSG_HIST_FAILED, "Sanity check failed. " + "START - %lu END - %lu THREAD_COUNT - %d", + start, end, n_parallel); ret = -1; goto out; } @@ -959,8 +966,14 @@ gf_history_changelog (char* changelog_dir, unsigned long start, goto out; - } /* end of range check */ - + } else {/* end of range check */ + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_LIB_MSG_HIST_FAILED, "Requested changelog " + "range is not available. START - %lu CHLOG_MIN - %lu " + "CHLOG_MAX - %lu", start, min_ts, max_ts); + ret = -2; + goto out; + } } /* end of readdir() */ if (!from || !to) -- cgit