diff options
author | Anusha Rao <anusha91rao@gmail.com> | 2015-05-04 12:34:09 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2015-08-11 22:36:44 -0700 |
commit | 64e6836ac8fb96f38a859eea0d8525cd9bd2693f (patch) | |
tree | eb00359a9dd7be26f90f9147330a8e2c6fa83232 /xlators/features/changelog/src | |
parent | 0dcdc8d9d797ed43d305fb3e3437c2576305ac46 (diff) |
features/changelog: Porting log messages to new logging framework
Change-Id: Ic7f842acca52908fd88e0796dc90b82650405b25
BUG: 1194640
Signed-off-by: Anusha Rao <anusha91rao@gmail.com>
Reviewed-on: http://review.gluster.org/10532
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Reviewed-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'xlators/features/changelog/src')
-rw-r--r-- | xlators/features/changelog/src/Makefile.am | 3 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-barrier.c | 13 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-ev-handle.c | 12 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-helpers.c | 350 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-helpers.h | 12 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-messages.h | 450 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-rpc-common.c | 39 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-rpc.c | 4 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog.c | 238 |
9 files changed, 862 insertions, 259 deletions
diff --git a/xlators/features/changelog/src/Makefile.am b/xlators/features/changelog/src/Makefile.am index 8712b9d059f..f70e5f8e707 100644 --- a/xlators/features/changelog/src/Makefile.am +++ b/xlators/features/changelog/src/Makefile.am @@ -4,7 +4,8 @@ xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features noinst_HEADERS = changelog-helpers.h changelog-mem-types.h changelog-rt.h \ changelog-rpc-common.h changelog-misc.h changelog-encoders.h \ - changelog-rpc-common.h changelog-rpc.h changelog-ev-handle.h + changelog-rpc-common.h changelog-rpc.h changelog-ev-handle.h \ + changelog-messages.h changelog_la_LDFLAGS = -module -avoid-version diff --git a/xlators/features/changelog/src/changelog-barrier.c b/xlators/features/changelog/src/changelog-barrier.c index 22cfa617e1b..ac1eb0e4397 100644 --- a/xlators/features/changelog/src/changelog-barrier.c +++ b/xlators/features/changelog/src/changelog-barrier.c @@ -9,6 +9,7 @@ */ #include "changelog-helpers.h" +#include "changelog-messages.h" #include "call-stub.h" /* Enqueue a stub*/ @@ -52,13 +53,15 @@ chlog_barrier_dequeue_all (xlator_t *this, struct list_head *queue) { call_stub_t *stub = NULL; - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Dequeuing all the changelog barriered fops"); while ((stub = __chlog_barrier_dequeue (this, queue))) call_resume (stub); - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Dequeuing changelog barriered fops is finished"); return; } @@ -77,7 +80,8 @@ chlog_barrier_timeout (void *data) INIT_LIST_HEAD (&queue); - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_BARRIER_ERROR, "Disabling changelog barrier because of the timeout."); LOCK (&priv->lock); @@ -117,7 +121,8 @@ __chlog_barrier_enable (xlator_t *this, changelog_priv_t *priv) priv->timer = gf_timer_call_after (this->ctx, priv->timeout, chlog_barrier_timeout, (void *)this); if (!priv->timer) { - gf_log (this->name, GF_LOG_CRITICAL, + gf_msg (this->name, GF_LOG_CRITICAL, 0, + CHANGELOG_MSG_BARRIER_ERROR, "Couldn't add changelog barrier timeout event."); goto out; } diff --git a/xlators/features/changelog/src/changelog-ev-handle.c b/xlators/features/changelog/src/changelog-ev-handle.c index ca7443cfd22..5167b56ed88 100644 --- a/xlators/features/changelog/src/changelog-ev-handle.c +++ b/xlators/features/changelog/src/changelog-ev-handle.c @@ -199,8 +199,10 @@ changelog_ev_connector (void *data) crpc->sock, changelog_rpc_notify); if (!crpc->rpc) { - gf_log (this->name, GF_LOG_ERROR, "failed to " - "connect back.. <%s>", crpc->sock); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_RPC_CONNECT_ERROR, + "failed to connect back.. <%s>", + crpc->sock); crpc->cleanup (crpc); goto mutex_unlock; } @@ -338,7 +340,8 @@ changelog_ev_dispatch (void *data) &opaque, sequencer, c_clnt); if (ret != RBUF_CONSUMABLE) { if (ret != RBUF_EMPTY) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_BUFFER_STARVATION_ERROR, "Failed to get buffer for RPC dispatch " "[rbuf retval: %d]", ret); continue; @@ -347,7 +350,8 @@ changelog_ev_dispatch (void *data) ret = rbuf_wait_for_completion (c_clnt->rbuf, opaque, _dispatcher, c_clnt); if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_PUT_BUFFER_FAILED, "failed to put buffer after consumption"); } diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c index a3a1289d792..d67be6f9838 100644 --- a/xlators/features/changelog/src/changelog-helpers.c +++ b/xlators/features/changelog/src/changelog-helpers.c @@ -17,6 +17,7 @@ #include "changelog-helpers.h" #include "changelog-encoders.h" #include "changelog-mem-types.h" +#include "changelog-messages.h" #include "changelog-encoders.h" #include "changelog-rpc-common.h" @@ -40,17 +41,17 @@ changelog_thread_cleanup (xlator_t *this, pthread_t thr_id) /* send a cancel request to the thread */ ret = pthread_cancel (thr_id); if (ret != 0) { - gf_log (this->name, GF_LOG_ERROR, - "could not cancel thread (reason: %s)", - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_CANCEL_FAILED, + "could not cancel thread"); goto out; } ret = pthread_join (thr_id, &retval); if ((ret != 0) || (retval != PTHREAD_CANCELED)) { - gf_log (this->name, GF_LOG_ERROR, - "cancel request not adhered as expected" - " (reason: %s)", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_CANCEL_FAILED, + "cancel request not adhered as expected"); } out: @@ -86,9 +87,9 @@ changelog_ev_selected (xlator_t *this, int idx = 0; idx = changelog_selector_index (selector); - gf_log (this->name, GF_LOG_DEBUG, - "selector ref count for %d (idx: %d): %d", - selector, idx, selection->ref[idx]); + gf_msg_debug (this->name, 0, + "selector ref count for %d (idx: %d): %d", + selector, idx, selection->ref[idx]); /* this can be lockless */ return (idx < CHANGELOG_EV_SELECTION_RANGE && (selection->ref[idx] > 0)); @@ -107,8 +108,8 @@ changelog_select_event (xlator_t *this, idx = changelog_selector_index (selector); if (idx < CHANGELOG_EV_SELECTION_RANGE) { selection->ref[idx]++; - gf_log (this->name, GF_LOG_DEBUG, - "selecting event %d", idx); + gf_msg_debug (this->name, 0, + "selecting event %d", idx); } selector &= ~(1 << idx); } @@ -129,8 +130,8 @@ changelog_deselect_event (xlator_t *this, idx = changelog_selector_index (selector); if (idx < CHANGELOG_EV_SELECTION_RANGE) { selection->ref[idx]--; - gf_log (this->name, GF_LOG_DEBUG, - "de-selecting event %d", idx); + gf_msg_debug (this->name, 0, + "de-selecting event %d", idx); } selector &= ~(1 << idx); } @@ -171,7 +172,8 @@ changelog_cleanup_event_selection (xlator_t *this, { while (j--) { if (selection->ref[j] > 0) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_CLEANUP_ON_ACTIVE_REF, "changelog event selection cleaning up " " on active references"); } @@ -190,8 +192,10 @@ changelog_perform_dispatch (xlator_t *this, buf = rbuf_reserve_write_area (priv->rbuf, size, &opaque); if (!buf) { - gf_log_callingfn (this->name, - GF_LOG_WARNING, "failed to dispatch event"); + gf_msg_callingfn (this->name, + GF_LOG_WARNING, 0, + CHANGELOG_MSG_DISPATCH_EVENT_FAILED, + "failed to dispatch event"); return; } @@ -281,7 +285,8 @@ htime_update (xlator_t *this, int ret = 0; if (priv->htime_fd ==-1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_HTIME_ERROR, "Htime fd not available for updation"); ret = -1; goto out; @@ -291,7 +296,8 @@ htime_update (xlator_t *this, changelog_path[len] = '\0'; /* redundant */ if (changelog_write (priv->htime_fd, (void*) changelog_path, len+1 ) < 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_HTIME_ERROR, "Htime file content write failed"); ret =-1; goto out; @@ -301,17 +307,17 @@ htime_update (xlator_t *this, if (sys_fsetxattr (priv->htime_fd, HTIME_KEY, x_value, strlen (x_value), XATTR_REPLACE)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_HTIME_ERROR, "Htime xattr updation failed with XATTR_REPLACE " - "Changelog: %s Reason (%s)", changelog_path, - strerror (errno)); + "Changelog: %s", changelog_path); if (sys_fsetxattr (priv->htime_fd, HTIME_KEY, x_value, strlen (x_value), 0)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_HTIME_ERROR, "Htime xattr updation failed " - "Changelog: %s Reason (%s)", changelog_path, - strerror (errno)); + "Changelog: %s", changelog_path); ret = -1; goto out; } @@ -344,15 +350,17 @@ cl_is_empty (xlator_t *this, int fd) ret = fstat (fd, &stbuf); if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "Could not stat (CHANGELOG)"); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSTAT_OP_FAILED, + "Could not stat (CHANGELOG)"); goto out; } ret = lseek (fd, 0, SEEK_SET); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, - "Could not lseek (CHANGELOG)"); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_LSEEK_OP_FAILED, + "Could not lseek (CHANGELOG)"); goto out; } @@ -389,8 +397,9 @@ update_path (xlator_t *this, char *cl_path) found = strstr(cl_path, up_cl); if (found == NULL) { - gf_log (this->name, GF_LOG_ERROR, - "Could not find CHANGELOG in changelog path"); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_LSEEK_OP_FAILED, + "Could not find CHANGELOG in changelog path"); goto out; } else { strncpy(found, low_cl, strlen(low_cl)); @@ -415,17 +424,18 @@ changelog_rollover_changelog (xlator_t *this, if (priv->changelog_fd != -1) { ret = fsync (priv->changelog_fd); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "fsync failed (reason: %s)", - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSYNC_OP_FAILED, + "fsync failed"); } ret = cl_is_empty (this, priv->changelog_fd); if (ret == 1) { cl_empty_flag = 1; } else if (ret == -1) { /* Log error but proceed as usual */ - gf_log (this->name, GF_LOG_WARNING, - "Error detecting empty changelog"); + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_DETECT_EMPTY_CHANGELOG_FAILED, + "Error detecting empty changelog"); } close (priv->changelog_fd); priv->changelog_fd = -1; @@ -440,9 +450,10 @@ changelog_rollover_changelog (xlator_t *this, if (cl_empty_flag == 1) { ret = unlink (ofile); if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "error unlinking(empty cl) %s (reason %s)", - ofile, strerror(errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_UNLINK_OP_FAILED, + "error unlinking(empty cl) %s)", + ofile); ret = 0; /* Error in unlinking empty changelog should not break further changelog operation, so reset return value to 0*/ @@ -455,14 +466,19 @@ changelog_rollover_changelog (xlator_t *this, goto out; } if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "error renaming %s -> %s (reason %s)", - ofile, nfile, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_RENAME_ERROR, + "error renaming %s -> %s", + ofile, nfile); } } if (!ret && (cl_empty_flag == 0)) { notify = 1; + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_RENAME_ERROR, + "error renaming %s -> %s", + ofile, nfile); } if (!ret) { @@ -471,7 +487,8 @@ changelog_rollover_changelog (xlator_t *this, } ret = htime_update (this, priv, ts, nfile); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, + 0, CHANGELOG_MSG_HTIME_ERROR, "could not update htime file"); goto out; } @@ -496,10 +513,13 @@ changelog_rollover_changelog (xlator_t *this, { if (ret) { priv->bn.bnotify_error = _gf_true; - gf_log (this->name, GF_LOG_ERROR, "Fail " - "snapshot because of previous errors"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_EXPLICIT_ROLLOVER_FAILED, + "Fail snapshot because of " + "previous errors"); } else { - gf_log (this->name, GF_LOG_INFO, "Explicit " + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BNOTIFY_INFO, "Explicit " "rollover changelog: %s signaling " "bnotify", nfile); } @@ -548,23 +568,26 @@ find_current_htime (int ht_dir_fd, const char *ht_dir_path, char *ht_file_bname) cnt = scandir (ht_dir_path, &namelist, filter_cur_par_dirs, alphasort); if (cnt < 0) { - gf_log (this->name, GF_LOG_ERROR, - "scandir failed: %s", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_SCAN_DIR_FAILED, + "scandir failed"); } else if (cnt > 0) { strncpy (ht_file_bname, namelist[cnt - 1]->d_name, NAME_MAX); ht_file_bname[NAME_MAX - 1] = 0; if (sys_fsetxattr (ht_dir_fd, HTIME_CURRENT, ht_file_bname, strlen (ht_file_bname), 0)) { - gf_log (this->name, GF_LOG_ERROR, "fsetxattr failed:" - " HTIME_CURRENT: %s", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSETXATTR_FAILED, + "fsetxattr failed: HTIME_CURRENT"); ret = -1; goto out; } if (fsync (ht_dir_fd) < 0) { - gf_log (this->name, GF_LOG_ERROR, - "fsync failed (reason: %s)", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSYNC_OP_FAILED, + "fsync failed"); ret = -1; goto out; } @@ -607,8 +630,9 @@ htime_open (xlator_t *this, /* Open htime directory to get HTIME_CURRENT */ ht_dir_fd = open (ht_dir_path, O_RDONLY); if (ht_dir_fd == -1) { - gf_log (this->name, GF_LOG_ERROR, "open failed: %s : %s", - ht_dir_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, "open failed: %s", + ht_dir_path); ret = -1; goto out; } @@ -616,6 +640,10 @@ htime_open (xlator_t *this, size = sys_fgetxattr (ht_dir_fd, HTIME_CURRENT, ht_file_bname, sizeof (ht_file_bname)); if (size < 0) { + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FGETXATTR_FAILED, "Error extracting" + " HTIME_CURRENT."); + /* If upgrade scenario, find the latest HTIME.TSTAMP file * and use the same. If error, create a new HTIME.TSTAMP * file. @@ -623,17 +651,20 @@ htime_open (xlator_t *this, cnt = find_current_htime (ht_dir_fd, ht_dir_path, ht_file_bname); if (cnt <= 0) { - gf_log (this->name, GF_LOG_INFO, - "HTIME_CURRENT not found: %s. Changelog enabled" - " before init", strerror (errno)); + gf_msg (this->name, GF_LOG_INFO, errno, + CHANGELOG_MSG_HTIME_INFO, + "HTIME_CURRENT not found. Changelog enabled" + " before init"); return htime_create (this, priv, ts); } - gf_log (this->name, GF_LOG_ERROR, "Error extracting" - " HTIME_CURRENT: %s.", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_HTIME_ERROR, "Error extracting" + " HTIME_CURRENT."); } - gf_log (this->name, GF_LOG_INFO, "HTIME_CURRENT: %s", ht_file_bname); + gf_msg (this->name, GF_LOG_INFO, 0, CHANGELOG_MSG_HTIME_INFO, + "HTIME_CURRENT: %s", ht_file_bname); (void) snprintf (ht_file_path, PATH_MAX, "%s/%s", ht_dir_path, ht_file_bname); @@ -642,9 +673,10 @@ htime_open (xlator_t *this, ht_file_fd = open (ht_file_path, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (ht_file_fd < 0) { - gf_log (this->name, GF_LOG_ERROR, - "unable to open htime file: %s" - "(reason: %s)", ht_file_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, + "unable to open htime file: %s", + ht_file_path); ret = -1; goto out; } @@ -655,15 +687,18 @@ htime_open (xlator_t *this, /* Initialize rollover-number in priv to current number */ size = sys_fgetxattr (ht_file_fd, HTIME_KEY, x_value, sizeof (x_value)); if (size < 0) { - gf_log (this->name, GF_LOG_ERROR, "error extracting max" - " timstamp from htime file %s (reason %s)", - ht_file_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FGETXATTR_FAILED, "error extracting max" + " timstamp from htime file %s", + ht_file_path); ret = -1; goto out; } sscanf (x_value, "%lu:%lu", &max_ts, &total); - gf_log (this->name, GF_LOG_INFO, "INIT CASE: MIN: %lu, MAX: %lu," + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_TOTAL_LOG_INFO, + "INIT CASE: MIN: %lu, MAX: %lu," " TOTAL CHANGELOGS: %lu", min_ts, max_ts, total); priv->rollover_count = total + 1; @@ -688,7 +723,8 @@ htime_create (xlator_t *this, char ht_file_bname[NAME_MAX + 1] = {0,}; int flags = 0; - gf_log (this->name, GF_LOG_INFO, "Changelog enable: Creating new " + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_HTIME_INFO, "Changelog enable: Creating new " "HTIME.%lu file", ts); CHANGELOG_FILL_HTIME_DIR(priv->changelog_dir, ht_dir_path); @@ -701,16 +737,18 @@ htime_create (xlator_t *this, ht_file_fd = open (ht_file_path, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (ht_file_fd < 0) { - gf_log (this->name, GF_LOG_ERROR, - "unable to create htime file: %s" - "(reason: %s)", ht_file_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, + "unable to create htime file: %s", + ht_file_path); ret = -1; goto out; } if (sys_fsetxattr (ht_file_fd, HTIME_KEY, HTIME_INITIAL_VALUE, sizeof (HTIME_INITIAL_VALUE)-1, 0)) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSETXATTR_FAILED, "Htime xattr initialization failed"); ret = -1; goto out; @@ -718,16 +756,18 @@ htime_create (xlator_t *this, ret = fsync (ht_file_fd); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "fsync failed (reason: %s)", - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSYNC_OP_FAILED, + "fsync failed"); goto out; } /* Set xattr HTIME_CURRENT on htime directory to htime filename */ ht_dir_fd = open (ht_dir_path, O_RDONLY); if (ht_dir_fd == -1) { - gf_log (this->name, GF_LOG_ERROR, "open of %s failed: %s", - ht_dir_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, "open of %s failed", + ht_dir_path); ret = -1; goto out; } @@ -736,16 +776,18 @@ htime_create (xlator_t *this, HTIME_FILE_NAME, ts); if (sys_fsetxattr (ht_dir_fd, HTIME_CURRENT, ht_file_bname, strlen (ht_file_bname), 0)) { - gf_log (this->name, GF_LOG_ERROR, "fsetxattr failed:" - " HTIME_CURRENT: %s", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSETXATTR_FAILED, "fsetxattr failed:" + " HTIME_CURRENT"); ret = -1; goto out; } ret = fsync (ht_dir_fd); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, "fsync failed (reason: %s)", - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSYNC_OP_FAILED, + "fsync failed"); goto out; } @@ -790,9 +832,9 @@ changelog_snap_open (xlator_t *this, fd = open (c_snap_path, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { - gf_log (this->name, GF_LOG_ERROR, - "unable to open %s file " - "reason:(%s)", c_snap_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, "unable to open %s file ", + c_snap_path); ret = -1; goto out; } @@ -827,7 +869,8 @@ changelog_snap_logging_start (xlator_t *this, int ret = 0; ret = changelog_snap_open (this, priv); - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_SNAP_INFO, "Now starting to log in call path"); return ret; @@ -849,8 +892,9 @@ changelog_snap_logging_stop (xlator_t *this, close (priv->c_snap_fd); priv->c_snap_fd = -1; - gf_log (this->name, GF_LOG_INFO, - "Stopped to log in call path"); + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_SNAP_INFO, + "Stopped to log in call path"); return ret; } @@ -876,10 +920,11 @@ changelog_open_journal (xlator_t *this, fd = open (changelog_path, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd < 0) { - gf_log (this->name, GF_LOG_ERROR, - "unable to open/create changelog file %s" - " (reason: %s). change-logging will be" - " inactive", changelog_path, strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_OPEN_FAILED, + "unable to open/create changelog file %s." + " change-logging will be" + " inactive", changelog_path); goto out; } @@ -998,10 +1043,11 @@ changelog_snap_handle_ascii_change (xlator_t *this, ret = changelog_snap_write_change (priv, buffer, off); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "error writing csnap to disk"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_WRITE_FAILED, + "error writing csnap to disk"); } - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, CHANGELOG_MSG_SNAP_INFO, "Successfully wrote to csnap"); ret = 0; out: @@ -1020,7 +1066,8 @@ changelog_handle_change (xlator_t *this, cld->cld_roll_time, cld->cld_finale); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_GET_TIME_OP_FAILED, "Problem rolling over changelog(s)"); goto out; } @@ -1035,16 +1082,17 @@ changelog_handle_change (xlator_t *this, if (CHANGELOG_TYPE_IS_FSYNC (cld->cld_type)) { ret = fsync (priv->changelog_fd); if (ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "fsync failed (reason: %s)", - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FSYNC_OP_FAILED, + "fsync failed"); } goto out; } ret = priv->ce->encode (this, cld); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_WRITE_FAILED, "error writing changelog to disk"); } @@ -1066,7 +1114,8 @@ changelog_local_init (xlator_t *this, inode_t *inode, * not blindly use local->inode. */ if (!update_flag && !inode) { - gf_log_callingfn (this->name, GF_LOG_WARNING, + gf_msg_callingfn (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_INODE_NOT_FOUND, "inode needed for version checking !!!"); goto out; } @@ -1136,27 +1185,31 @@ changelog_drain_black_fops (xlator_t *this, changelog_priv_t *priv) &priv->dm.drain_black_mutex); ret = pthread_mutex_lock (&priv->dm.drain_black_mutex); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread error:" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_ERROR, "pthread error:" " Error:%d", ret); while (priv->dm.black_fop_cnt > 0) { - gf_log (this->name, GF_LOG_DEBUG, - "Condtional wait on black fops: %ld", - priv->dm.black_fop_cnt); + gf_msg_debug (this->name, 0, + "Condtional wait on black fops: %ld", + priv->dm.black_fop_cnt); priv->dm.drain_wait_black = _gf_true; ret = pthread_cond_wait (&priv->dm.drain_black_cond, &priv->dm.drain_black_mutex); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread" - " cond wait failed: Error:%d", ret); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_COND_WAIT_FAILED, + "pthread cond wait failed: Error:%d", + ret); } priv->dm.drain_wait_black = _gf_false; ret = pthread_mutex_unlock (&priv->dm.drain_black_mutex); - pthread_cleanup_pop (0); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread error:" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_ERROR, "pthread error:" " Error:%d", ret); - gf_log (this->name, GF_LOG_DEBUG, - "Woke up: Conditional wait on black fops"); + pthread_cleanup_pop (0); + gf_msg_debug (this->name, 0, + "Woke up: Conditional wait on black fops"); } /* Wait till all the white fops are drained */ @@ -1173,27 +1226,31 @@ changelog_drain_white_fops (xlator_t *this, changelog_priv_t *priv) &priv->dm.drain_white_mutex); ret = pthread_mutex_lock (&priv->dm.drain_white_mutex); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread error:" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_ERROR, "pthread error:" " Error:%d", ret); while (priv->dm.white_fop_cnt > 0) { - gf_log (this->name, GF_LOG_DEBUG, - "Condtional wait on white fops : %ld", + gf_msg_debug (this->name, 0, + "Condtional wait on white fops : %ld", priv->dm.white_fop_cnt); priv->dm.drain_wait_white = _gf_true; ret = pthread_cond_wait (&priv->dm.drain_white_cond, &priv->dm.drain_white_mutex); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread" - " cond wait failed: Error:%d", ret); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_COND_WAIT_FAILED, + "pthread cond wait failed: Error:%d", + ret); } priv->dm.drain_wait_white = _gf_false; ret = pthread_mutex_unlock (&priv->dm.drain_white_mutex); if (ret) - gf_log (this->name, GF_LOG_ERROR, "pthread error:" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_ERROR, "pthread error:" " Error:%d", ret); pthread_cleanup_pop (0); - gf_log (this->name, GF_LOG_DEBUG, - "Woke up: Conditional wait on white fops"); + gf_msg_debug (this->name, 0, + "Woke up: Conditional wait on white fops"); } /** @@ -1237,28 +1294,32 @@ changelog_rollover (void *data) ret = select (max_fd, &rset, NULL, NULL, &tv); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, - "select failed: %s", strerror(errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_SELECT_FAILED, + "select failed"); continue; } else if (ret && FD_ISSET(priv->cr.rfd, &rset)) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Explicit wakeup of select on barrier notify"); len = read(priv->cr.rfd, buf, 1); if (len == 0) { - gf_log (this->name, GF_LOG_ERROR, "BUG: Got EOF" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_READ_ERROR, "BUG: Got EOF" " from reconfigure notification pipe"); continue; } if (len < 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_READ_ERROR, "Failed to read wakeup data"); continue; } /* Lock is not required as same thread is modifying.*/ priv->explicit_rollover = _gf_true; } else { - gf_log (this->name, GF_LOG_DEBUG, - "select wokeup on timeout"); + gf_msg_debug (this->name, 0, + "select wokeup on timeout"); } /* Reading curent_color without lock is fine here @@ -1268,15 +1329,17 @@ changelog_rollover (void *data) LOCK(&priv->lock); priv->current_color = FOP_COLOR_WHITE; UNLOCK(&priv->lock); - gf_log (this->name, GF_LOG_DEBUG, "Black fops" - " to be drained:%ld",priv->dm.black_fop_cnt); + gf_msg_debug (this->name, 0, "Black fops" + " to be drained:%ld", + priv->dm.black_fop_cnt); changelog_drain_black_fops (this, priv); } else { LOCK(&priv->lock); priv->current_color = FOP_COLOR_BLACK; UNLOCK(&priv->lock); - gf_log (this->name, GF_LOG_DEBUG, "White fops" - " to be drained:%ld",priv->dm.white_fop_cnt); + gf_msg_debug (this->name, 0, "White fops" + " to be drained:%ld", + priv->dm.white_fop_cnt); changelog_drain_white_fops (this, priv); } @@ -1306,7 +1369,8 @@ changelog_rollover (void *data) ret = changelog_fill_rollover_data (&cld, _gf_false); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_GET_TIME_OP_FAILED, "failed to fill rollover data"); continue; } @@ -1353,7 +1417,8 @@ changelog_fsync_thread (void *data) ret = changelog_inject_single_event (this, priv, &cld); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_INJECT_FSYNC_FAILED, "failed to inject fsync event"); _unmask_cancellation (); @@ -1682,8 +1747,9 @@ changelog_dec_fop_cnt (xlator_t *this, changelog_priv_t *priv, &priv->dm.drain_black_cond); CHANGELOG_PTHREAD_ERROR_HANDLE_0 (ret, out); - gf_log (this->name, GF_LOG_DEBUG, - "Signalled draining of black"); + gf_msg_debug (this->name, 0, + "Signalled " + "draining of black"); } } ret = pthread_mutex_unlock(&priv->dm.drain_black_mutex); @@ -1699,8 +1765,9 @@ changelog_dec_fop_cnt (xlator_t *this, changelog_priv_t *priv, &priv->dm.drain_white_cond); CHANGELOG_PTHREAD_ERROR_HANDLE_0 (ret, out); - gf_log (this->name, GF_LOG_DEBUG, - "Signalled draining of white"); + gf_msg_debug (this->name, 0, + "Signalled " + "draining of white"); } } ret = pthread_mutex_unlock(&priv->dm.drain_white_mutex); @@ -1775,21 +1842,25 @@ changelog_fill_entry_buf (call_frame_t *frame, xlator_t *this, parent = inode_parent (loc->inode, 0, 0); if (!parent) { - gf_log (this->name, GF_LOG_ERROR, "Parent inode not found" + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_INODE_NOT_FOUND, "Parent inode not found" " for gfid: %s", uuid_utoa (loc->inode->gfid)); goto err; } CHANGELOG_INIT_NOCHECK (this, *local, loc->inode, loc->inode->gfid, 5); if (!(*local)) { - gf_log (this->name, GF_LOG_ERROR, "changelog local" + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_LOCAL_INIT_FAILED, "changelog local" " initiatilization failed"); goto err; } co = changelog_get_usable_buffer (*local); if (!co) { - gf_log (this->name, GF_LOG_ERROR, "Failed to get buffer"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_NO_MEMORY, + "Failed to get buffer"); goto err; } @@ -1886,9 +1957,10 @@ resolve_pargfid_to_path (xlator_t *this, uuid_t pargfid, len = readlink (dir_handle, linkname, PATH_MAX); if (len < 0) { - gf_log (this->name, GF_LOG_ERROR, "could not read the " - "link from the gfid handle %s (%s)", dir_handle, - strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_READLINK_OP_FAILED, + "could not read the " + "link from the gfid handle %s", dir_handle); ret = -1; goto out; } diff --git a/xlators/features/changelog/src/changelog-helpers.h b/xlators/features/changelog/src/changelog-helpers.h index 6219d8d9a4b..4427e93f601 100644 --- a/xlators/features/changelog/src/changelog-helpers.h +++ b/xlators/features/changelog/src/changelog-helpers.h @@ -24,6 +24,7 @@ #include "changelog-ev-handle.h" #include "changelog.h" +#include "changelog-messages.h" /** * the changelog entry @@ -644,7 +645,8 @@ resolve_pargfid_to_path (xlator_t *this, uuid_t gfid, char **path, char *bname); #define CHANGELOG_NOT_ON_THEN_GOTO(priv, ret, label) do { \ if (!priv->active) { \ - gf_log (this->name, GF_LOG_WARNING, \ + gf_msg (this->name, GF_LOG_WARNING, 0, \ + CHANGELOG_MSG_NOT_ACTIVE, \ "Changelog is not active, return success"); \ ret = 0; \ goto label; \ @@ -654,17 +656,19 @@ resolve_pargfid_to_path (xlator_t *this, uuid_t gfid, char **path, char *bname); /* Log pthread error and goto label */ #define CHANGELOG_PTHREAD_ERROR_HANDLE_0(ret, label) do { \ if (ret) { \ - gf_log (this->name, GF_LOG_ERROR, \ + gf_msg (this->name, GF_LOG_ERROR, \ + 0, CHANGELOG_MSG_PTHREAD_ERROR, \ "pthread error: Error: %d", ret); \ ret = -1; \ goto label; \ } \ - } while (0) + } while (0); /* Log pthread error, set flag and goto label */ #define CHANGELOG_PTHREAD_ERROR_HANDLE_1(ret, label, flag) do { \ if (ret) { \ - gf_log (this->name, GF_LOG_ERROR, \ + gf_msg (this->name, GF_LOG_ERROR, 0, \ + CHANGELOG_MSG_PTHREAD_ERROR, \ "pthread error: Error: %d", ret); \ ret = -1; \ flag = _gf_true; \ diff --git a/xlators/features/changelog/src/changelog-messages.h b/xlators/features/changelog/src/changelog-messages.h new file mode 100644 index 00000000000..e65a457b7c0 --- /dev/null +++ b/xlators/features/changelog/src/changelog-messages.h @@ -0,0 +1,450 @@ +/* + Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. + */ + +#ifndef _CHANGELOG_MESSAGES_H_ +#define _CHANGELOG_MESSAGES_H_ + +#ifndef _CONFIG_H +#define _CONFIG_H +#include "config.h" +#endif + +#include "glfs-message-id.h" + +/*! \file changelog-messages.h + * \brief CHANGELOG log-message IDs and their descriptions. + */ + +/* NOTE: Rules for message additions + * 1) Each instance of a message is _better_ left with a unique message ID, even + * if the message format is the same. Reasoning is that, if the message + * format needs to change in one instance, the other instances are not + * impacted or the new change does not change the ID of the instance being + * modified. + * 2) Addition of a message, + * - Should increment the GLFS_NUM_MESSAGES + * - Append to the list of messages defined, towards the end + * - Retain macro naming as glfs_msg_X (for readability across developers) + * NOTE: Rules for message format modifications + * 3) Check acorss the code if the message ID macro in question is reused + * anywhere. If reused then then the modifications should ensure correctness + * everywhere, or needs a new message ID as (1) above was not adhered to. If + * not used anywhere, proceed with the required modification. + * NOTE: Rules for message deletion + * 4) Check (3) and if used anywhere else, then cannot be deleted. If not used + * anywhere, then can be deleted, but will leave a hole by design, as + * addition rules specify modification to the end of the list and not filling + * holes. + */ + +#define GLFS_COMP_BASE_CHANGELOG GLFS_MSGID_COMP_CHANGELOG +#define GLFS_NUM_MESSAGES 54 +#define GLFS_MSGID_END (GLFS_COMP_BASE_CHANGELOG + GLFS_NUM_MESSAGES + 1) + +#define glfs_msg_start_x GLFS_COMP_BASE_CHANGELOG, "Invalid: Start of messages" + +/*! + * @messageid + * @diagnosis open/opendir failed on a brick. + * @recommended action Error number in the log should give the reason why it + * failed. Also observe brick logs for more information. + */ +#define CHANGELOG_MSG_OPEN_FAILED (GLFS_COMP_BASE_CHANGELOG + 1) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_NO_MEMORY (GLFS_COMP_BASE_CHANGELOG + 2) +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_VOL_MISCONFIGURED (GLFS_COMP_BASE_CHANGELOG + 3) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_RENAME_ERROR (GLFS_COMP_BASE_CHANGELOG + 4) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_READ_ERROR (GLFS_COMP_BASE_CHANGELOG + 5) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_HTIME_ERROR (GLFS_COMP_BASE_CHANGELOG + 6) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PTHREAD_MUTEX_INIT_FAILED (GLFS_COMP_BASE_CHANGELOG + 7) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PTHREAD_COND_INIT_FAILED (GLFS_COMP_BASE_CHANGELOG + 8) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_CHILD_MISCONFIGURED (GLFS_COMP_BASE_CHANGELOG + 9) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_DIR_OPTIONS_NOT_SET (GLFS_COMP_BASE_CHANGELOG + 10) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_CLOSE_ERROR (GLFS_COMP_BASE_CHANGELOG + 11) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PIPE_CREATION_ERROR (GLFS_COMP_BASE_CHANGELOG + 12) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_DICT_GET_FAILED (GLFS_COMP_BASE_CHANGELOG + 13) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_BARRIER_INFO (GLFS_COMP_BASE_CHANGELOG + 14) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_BARRIER_ERROR (GLFS_COMP_BASE_CHANGELOG + 15) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_GET_TIME_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 16) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_WRITE_FAILED (GLFS_COMP_BASE_CHANGELOG + 17) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PTHREAD_ERROR (GLFS_COMP_BASE_CHANGELOG + 18) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_INODE_NOT_FOUND (GLFS_COMP_BASE_CHANGELOG + 19) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FSYNC_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 20) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_TOTAL_LOG_INFO (GLFS_COMP_BASE_CHANGELOG + 21) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_SNAP_INFO (GLFS_COMP_BASE_CHANGELOG + 22) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_SELECT_FAILED (GLFS_COMP_BASE_CHANGELOG + 23) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FCNTL_FAILED (GLFS_COMP_BASE_CHANGELOG + 24) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_BNOTIFY_INFO (GLFS_COMP_BASE_CHANGELOG + 25) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_ENTRY_BUF_INFO (GLFS_COMP_BASE_CHANGELOG + 26) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_NOT_ACTIVE (GLFS_COMP_BASE_CHANGELOG + 27) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_LOCAL_INIT_FAILED (GLFS_COMP_BASE_CHANGELOG + 28) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_NOTIFY_REGISTER_FAILED (GLFS_COMP_BASE_CHANGELOG + 28) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PROGRAM_NAME_REG_FAILED (GLFS_COMP_BASE_CHANGELOG + 29) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_HANDLE_PROBE_ERROR (GLFS_COMP_BASE_CHANGELOG + 30) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_SET_FD_CONTEXT (GLFS_COMP_BASE_CHANGELOG + 31) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FREEUP_FAILED (GLFS_COMP_BASE_CHANGELOG + 32) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_HTIME_INFO (GLFS_COMP_BASE_CHANGELOG + 33) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_RPC_SUBMIT_REPLY_FAILED (GLFS_COMP_BASE_CHANGELOG + 34) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_RPC_BUILD_ERROR (GLFS_COMP_BASE_CHANGELOG + 35) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_RPC_CONNECT_ERROR (GLFS_COMP_BASE_CHANGELOG + 36) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_RPC_START_ERROR (GLFS_COMP_BASE_CHANGELOG + 37) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_BUFFER_STARVATION_ERROR (GLFS_COMP_BASE_CHANGELOG + 3) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_SCAN_DIR_FAILED (GLFS_COMP_BASE_CHANGELOG + 39) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FSETXATTR_FAILED (GLFS_COMP_BASE_CHANGELOG + 40) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FGETXATTR_FAILED (GLFS_COMP_BASE_CHANGELOG + 41) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_CLEANUP_ON_ACTIVE_REF \ + (GLFS_COMP_BASE_CHANGELOG + 42) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_DISPATCH_EVENT_FAILED (GLFS_COMP_BASE_CHANGELOG + 43) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PUT_BUFFER_FAILED (GLFS_COMP_BASE_CHANGELOG + 44) + +/*! + * @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PTHREAD_COND_WAIT_FAILED (GLFS_COMP_BASE_CHANGELOG + 45) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_PTHREAD_CANCEL_FAILED (GLFS_COMP_BASE_CHANGELOG + 46) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_INJECT_FSYNC_FAILED (GLFS_COMP_BASE_CHANGELOG + 47) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_CREATE_FRAME_FAILED (GLFS_COMP_BASE_CHANGELOG + 48) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_FSTAT_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 49) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_LSEEK_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 50) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_STRSTR_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 51) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_UNLINK_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 52) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_DETECT_EMPTY_CHANGELOG_FAILED \ + (GLFS_COMP_BASE_CHANGELOG + 53) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_READLINK_OP_FAILED (GLFS_COMP_BASE_CHANGELOG + 54) + +/*! + @messageid + * @diagnosis + * @recommended action +*/ +#define CHANGELOG_MSG_EXPLICIT_ROLLOVER_FAILED (GLFS_COMP_BASE_CHANGELOG + 55) + + + +#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" +#endif /* !_CHANGELOG_MESSAGES_H_ */ diff --git a/xlators/features/changelog/src/changelog-rpc-common.c b/xlators/features/changelog/src/changelog-rpc-common.c index de3a730534e..7d2ec1de988 100644 --- a/xlators/features/changelog/src/changelog-rpc-common.c +++ b/xlators/features/changelog/src/changelog-rpc-common.c @@ -9,7 +9,7 @@ */ #include "changelog-rpc-common.h" - +#include "changelog-messages.h" /** ***************************************************** Client Interface @@ -47,7 +47,8 @@ changelog_rpc_client_init (xlator_t *this, void *cbkdata, ret = rpc_transport_unix_options_build (&options, sockfile, 0); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_RPC_BUILD_ERROR, "failed to build rpc options"); goto dealloc_dict; } @@ -58,13 +59,17 @@ changelog_rpc_client_init (xlator_t *this, void *cbkdata, ret = rpc_clnt_register_notify (rpc, fn, cbkdata); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "failed to register notify"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_NOTIFY_REGISTER_FAILED, + "failed to register notify"); goto dealloc_rpc_clnt; } ret = rpc_clnt_start (rpc); if (ret) { - gf_log (this->name, GF_LOG_ERROR, "failed to start rpc"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_RPC_START_ERROR, + "failed to start rpc"); goto dealloc_rpc_clnt; } @@ -158,7 +163,9 @@ changelog_invoke_rpc (xlator_t *this, struct rpc_clnt *rpc, frame = create_frame (this, this->ctx->pool); if (!frame) { - gf_log (this->name, GF_LOG_ERROR, "failed to create frame"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_CREATE_FRAME_FAILED, + "failed to create frame"); goto error_return; } @@ -229,7 +236,9 @@ changelog_rpc_sumbit_reply (rpcsvc_request_t *req, iob = __changelog_rpc_serialize_reply (req, arg, &iov, xdrproc); if (!iob) - gf_log ("", GF_LOG_ERROR, "failed to serialize reply"); + gf_msg ("", GF_LOG_ERROR, 0, + CHANGELOG_MSG_RPC_SUBMIT_REPLY_FAILED, + "failed to serialize reply"); else iobref_add (iobref, iob); @@ -290,21 +299,24 @@ changelog_rpc_server_init (xlator_t *this, char *sockfile, void *cbkdata, rpc = rpcsvc_init (this, this->ctx, options, 8); if (rpc == NULL) { - gf_log (this->name, GF_LOG_ERROR, "failed to init rpc"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_RPC_START_ERROR, + "failed to init rpc"); goto dealloc_dict; } ret = rpcsvc_register_notify (rpc, fn, cbkdata); if (ret) { - gf_log (this->name, - GF_LOG_ERROR, "failed to register notify function"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_NOTIFY_REGISTER_FAILED, + "failed to register notify function"); goto dealloc_rpc; } ret = rpcsvc_create_listeners (rpc, options, this->name); if (ret != 1) { - gf_log (this->name, - GF_LOG_DEBUG, "failed to create listeners"); + gf_msg_debug (this->name, + 0, "failed to create listeners"); goto dealloc_rpc; } @@ -312,8 +324,9 @@ changelog_rpc_server_init (xlator_t *this, char *sockfile, void *cbkdata, prog = *progs; ret = rpcsvc_program_register (rpc, prog); if (ret) { - gf_log (this->name, - GF_LOG_ERROR, "cannot register program " + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_PROGRAM_NAME_REG_FAILED, + "cannot register program " "(name: %s, prognum: %d, pogver: %d)", prog->progname, prog->prognum, prog->progver); goto dealloc_rpc; diff --git a/xlators/features/changelog/src/changelog-rpc.c b/xlators/features/changelog/src/changelog-rpc.c index c7c0fffa9f5..76052a27a9c 100644 --- a/xlators/features/changelog/src/changelog-rpc.c +++ b/xlators/features/changelog/src/changelog-rpc.c @@ -246,7 +246,9 @@ changelog_handle_probe (rpcsvc_request_t *req) ret = xdr_to_generic (req->msg[0], &rpc_req, (xdrproc_t)xdr_changelog_probe_req); if (ret < 0) { - gf_log ("", GF_LOG_ERROR, "xdr decoding error"); + gf_msg ("", GF_LOG_ERROR, 0, + CHANGELOG_MSG_HANDLE_PROBE_ERROR, + "xdr decoding error"); req->rpc_err = GARBAGE_ARGS; goto handle_xdr_error; } diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c index e88306b8f21..acd0d42323a 100644 --- a/xlators/features/changelog/src/changelog.c +++ b/xlators/features/changelog/src/changelog.c @@ -17,10 +17,12 @@ #include "changelog-encoders.h" #include "changelog-mem-types.h" +#include "changelog-messages.h" #include <pthread.h> #include "changelog-rpc.h" +#include "errno.h" static struct changelog_bootstrap cb_bootstrap[] = { @@ -71,8 +73,9 @@ changelog_rmdir_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeue rmdir"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeue rmdir"); + changelog_color_fop_and_inc_cnt (this, priv, + frame->local); STACK_WIND (frame, changelog_rmdir_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->rmdir, loc, xflags, xdata); @@ -143,13 +146,14 @@ changelog_rmdir (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueue rmdir"); + gf_msg_debug (this->name, 0, "Enqueue rmdir"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: rmdir, ERROR: %s", strerror (ENOMEM)); + "FOP: rmdir"); chlog_barrier_dequeue_all (this, &queue); } @@ -195,8 +199,9 @@ changelog_unlink_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeue unlink"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeue unlink"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_unlink_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->unlink, loc, xflags, xdata); @@ -296,13 +301,14 @@ changelog_unlink (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueue unlink"); + gf_msg_debug (this->name, 0, "Enqueue unlink"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: unlink, ERROR: %s", strerror (ENOMEM)); + "FOP: unlink"); chlog_barrier_dequeue_all (this, &queue); } @@ -349,8 +355,9 @@ changelog_rename_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeue rename"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeue rename"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_rename_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->rename, oldloc, newloc, xdata); @@ -420,13 +427,14 @@ changelog_rename (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueue rename"); + gf_msg_debug (this->name, 0, "Enqueue rename"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: rename, ERROR: %s", strerror (ENOMEM)); + "FOP: rename"); chlog_barrier_dequeue_all (this, &queue); } /* changelog barrier */ @@ -477,8 +485,9 @@ changelog_link_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeuing link"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeuing link"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_link_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->link, oldloc, newloc, xdata); @@ -535,14 +544,15 @@ changelog_link (call_frame_t *frame, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueued link"); + gf_msg_debug (this->name, 0, "Enqueued link"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: link, ERROR: %s", strerror (ENOMEM)); + "FOP: link"); chlog_barrier_dequeue_all (this, &queue); } wind: @@ -592,8 +602,9 @@ changelog_mkdir_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeuing mkdir"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeuing mkdir"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_mkdir_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->mkdir, loc, mode, umask, xdata); @@ -621,8 +632,8 @@ changelog_mkdir (call_frame_t *frame, xlator_t *this, ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, - "failed to get gfid from dict"); + gf_msg_debug (this->name, 0, + "failed to get gfid from dict"); goto wind; } gf_uuid_copy (gfid, uuid_req); @@ -668,14 +679,15 @@ changelog_mkdir (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueued mkdir"); + gf_msg_debug (this->name, 0, "Enqueued mkdir"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: mkdir, ERROR: %s", strerror (ENOMEM)); + "FOP: mkdir"); chlog_barrier_dequeue_all (this, &queue); } @@ -727,8 +739,9 @@ changelog_symlink_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeuing symlink"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeuing symlink"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_symlink_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->symlink, linkname, loc, umask, xdata); @@ -757,8 +770,8 @@ changelog_symlink (call_frame_t *frame, xlator_t *this, ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, - "failed to get gfid from dict"); + gf_msg_debug (this->name, 0, + "failed to get gfid from dict"); goto wind; } gf_uuid_copy (gfid, uuid_req); @@ -796,14 +809,15 @@ changelog_symlink (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueued symlink"); + gf_msg_debug (this->name, 0, "Enqueued symlink"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: symlink, ERROR: %s", strerror (ENOMEM)); + "FOP: symlink"); chlog_barrier_dequeue_all (this, &queue); } @@ -854,8 +868,9 @@ changelog_mknod_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeuing mknod"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeuing mknod"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_mknod_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->mknod, loc, mode, rdev, umask, xdata); @@ -885,8 +900,8 @@ changelog_mknod (call_frame_t *frame, ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, - "failed to get gfid from dict"); + gf_msg_debug (this->name, 0, + "failed to get gfid from dict"); goto wind; } gf_uuid_copy (gfid, uuid_req); @@ -932,14 +947,15 @@ changelog_mknod (call_frame_t *frame, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueued mknod"); + gf_msg_debug (this->name, 0, "Enqueued mknod"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: mknod, ERROR: %s", strerror (ENOMEM)); + "FOP: mknod"); chlog_barrier_dequeue_all (this, &queue); } @@ -981,7 +997,8 @@ changelog_create_cbk (call_frame_t *frame, (this, &priv->ev_selection, CHANGELOG_OP_TYPE_RELEASE)) { ret = fd_ctx_set (fd, this, (uint64_t)(long) 0x1); if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_SET_FD_CONTEXT, "could not set fd context (for release cbk)"); } @@ -1008,8 +1025,9 @@ changelog_create_resume (call_frame_t *frame, xlator_t *this, priv = this->private; - gf_log (this->name, GF_LOG_DEBUG, "Dequeuing create"); - changelog_color_fop_and_inc_cnt (this, priv, frame->local); + gf_msg_debug (this->name, 0, "Dequeuing create"); + changelog_color_fop_and_inc_cnt + (this, priv, frame->local); STACK_WIND (frame, changelog_create_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->create, loc, flags, mode, umask, fd, xdata); @@ -1039,8 +1057,8 @@ changelog_create (call_frame_t *frame, xlator_t *this, ret = dict_get_ptr (xdata, "gfid-req", &uuid_req); if (ret) { - gf_log (this->name, GF_LOG_DEBUG, - "failed to get gfid from dict"); + gf_msg_debug (this->name, 0, + "failed to get gfid from dict"); goto wind; } gf_uuid_copy (gfid, uuid_req); @@ -1090,14 +1108,15 @@ changelog_create (call_frame_t *frame, xlator_t *this, UNLOCK (&priv->lock); if (barrier_enabled && stub) { - gf_log (this->name, GF_LOG_DEBUG, "Enqueued create"); + gf_msg_debug (this->name, 0, "Enqueued create"); goto out; } if (barrier_enabled && !stub) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Failed to barrier FOPs, disabling changelog barrier " - "FOP: create, ERROR: %s", strerror (ENOMEM)); + "FOP: create"); chlog_barrier_dequeue_all (this, &queue); } @@ -1408,7 +1427,9 @@ changelog_handle_virtual_xattr (call_frame_t *frame, xlator_t *this, if (valid) { ret = changelog_fill_entry_buf (frame, this, loc, &local); if (ret) { - gf_log (this->name, GF_LOG_INFO, "Entry cannot be" + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_ENTRY_BUF_INFO, + "Entry cannot be" " captured for gfid: %s. Capturing DATA" " entry.", uuid_utoa (loc->inode->gfid)); goto unwind; @@ -1737,7 +1758,8 @@ changelog_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, (this, &priv->ev_selection, CHANGELOG_OP_TYPE_RELEASE)) { ret = fd_ctx_set (fd, this, (uint64_t)(long) 0x1); if (ret) - gf_log (this->name, GF_LOG_WARNING, + gf_msg (this->name, GF_LOG_WARNING, 0, + CHANGELOG_MSG_SET_FD_CONTEXT, "could not set fd context (for release cbk)"); } @@ -1882,9 +1904,9 @@ changelog_cleanup_helper_threads (xlator_t *this, changelog_priv_t *priv) priv->cr.rollover_th = 0; ret = close (priv->cr_wfd); if (ret) - gf_log (this->name, GF_LOG_ERROR, - "error closing write end of rollover pipe" - " (reason: %s)", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_CLOSE_ERROR, + "error closing write end of rollover pipe"); } if (priv->cf.fsync_th) { @@ -1915,8 +1937,9 @@ changelog_spawn_helper_threads (xlator_t *this, changelog_priv_t *priv) ret = pipe (pipe_fd); if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, - "Cannot create pipe (reason: %s)", strerror (errno)); + gf_msg (this->name, GF_LOG_ERROR, + errno, CHANGELOG_MSG_PIPE_CREATION_ERROR, + "Cannot create pipe"); goto out; } @@ -1926,7 +1949,8 @@ changelog_spawn_helper_threads (xlator_t *this, changelog_priv_t *priv) ret = fcntl (pipe_fd[1], F_SETFL, flags); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_FCNTL_FAILED, "failed to set O_NONBLOCK flag"); goto out; } @@ -1979,13 +2003,15 @@ notify (xlator_t *this, int event, void *data, ...) switch (barrier) { case DICT_ERROR: - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_DICT_GET_FAILED, "Barrier dict_get_str_boolean failed"); ret = -1; goto out; case BARRIER_OFF: - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Barrier off notification"); CHANGELOG_NOT_ON_THEN_GOTO(priv, ret, out); @@ -2003,9 +2029,10 @@ notify (xlator_t *this, int event, void *data, ...) UNLOCK (&priv->bflags.lock); if (ret == -1 ) { - gf_log (this->name, GF_LOG_ERROR, "Received" - " another barrier off notification" - " while already off"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_BARRIER_ERROR, + "Received another barrier off" + " notification while already off"); goto out; } @@ -2023,10 +2050,12 @@ notify (xlator_t *this, int event, void *data, ...) */ if (ret == 0) { chlog_barrier_dequeue_all(this, &queue); - gf_log(this->name, GF_LOG_INFO, + gf_msg(this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Disabled changelog barrier"); } else { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_BARRIER_ERROR, "Changelog barrier already disabled"); } @@ -2039,7 +2068,8 @@ notify (xlator_t *this, int event, void *data, ...) goto out; case BARRIER_ON: - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, "Barrier on notification"); CHANGELOG_NOT_ON_THEN_GOTO(priv, ret, out); @@ -2059,9 +2089,11 @@ notify (xlator_t *this, int event, void *data, ...) UNLOCK (&priv->bflags.lock); if (ret == -1 ) { - gf_log (this->name, GF_LOG_ERROR, "Received" - " another barrier on notification when" - " last one is not served yet"); + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_BARRIER_ERROR, + "Received another barrier on" + "notification when last one is" + "not served yet"); goto out; } @@ -2086,12 +2118,14 @@ notify (xlator_t *this, int event, void *data, ...) goto out; } - gf_log(this->name, GF_LOG_INFO, - "Enabled changelog barrier"); + gf_msg(this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BARRIER_INFO, + "Enabled changelog barrier"); ret = changelog_barrier_notify(priv, buf); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_WRITE_FAILED, "Explicit roll over: write failed"); changelog_barrier_cleanup (this, priv, &queue); ret = -1; @@ -2121,19 +2155,22 @@ notify (xlator_t *this, int event, void *data, ...) ret1 = pthread_mutex_unlock (&priv->bn.bnotify_mutex); CHANGELOG_PTHREAD_ERROR_HANDLE_1 (ret1, out, bclean_req); - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_BNOTIFY_INFO, "Woke up: bnotify conditional wait"); goto out; case DICT_DEFAULT: - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_DICT_GET_FAILED, "barrier key not found"); ret = -1; goto out; default: - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + CHANGELOG_MSG_DICT_GET_FAILED, "Something went bad in dict_get_str_boolean"); ret = -1; goto out; @@ -2160,7 +2197,8 @@ mem_acct_init (xlator_t *this) ret = xlator_mem_acct_init (this, gf_changelog_mt_end + 1); if (ret != 0) { - gf_log (this->name, GF_LOG_WARNING, "Memory accounting" + gf_msg (this->name, GF_LOG_WARNING, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "Memory accounting" " init failed"); return ret; } @@ -2178,7 +2216,8 @@ changelog_init (xlator_t *this, changelog_priv_t *priv) ret = gettimeofday (&tv, NULL); if (ret) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_GET_TIME_OP_FAILED, "gettimeofday() failure"); goto out; } @@ -2239,7 +2278,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) int ret = 0; if ((ret = pthread_mutex_init(&priv->bn.bnotify_mutex, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_MUTEX_INIT_FAILED, "bnotify pthread_mutex_init failed (%d)", ret); ret = -1; goto out; @@ -2247,7 +2287,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) bn_mutex_init = _gf_true; if ((ret = pthread_cond_init(&priv->bn.bnotify_cond, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_COND_INIT_FAILED, "bnotify pthread_cond_init failed (%d)", ret); ret = -1; goto out; @@ -2256,7 +2297,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) if ((ret = pthread_mutex_init(&priv->dm.drain_black_mutex, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_MUTEX_INIT_FAILED, "drain_black pthread_mutex_init failed (%d)", ret); ret = -1; goto out; @@ -2264,7 +2306,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) dm_mutex_black_init = _gf_true; if ((ret = pthread_cond_init(&priv->dm.drain_black_cond, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_COND_INIT_FAILED, "drain_black pthread_cond_init failed (%d)", ret); ret = -1; goto out; @@ -2273,7 +2316,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) if ((ret = pthread_mutex_init(&priv->dm.drain_white_mutex, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_MUTEX_INIT_FAILED, "drain_white pthread_mutex_init failed (%d)", ret); ret = -1; goto out; @@ -2281,7 +2325,8 @@ changelog_barrier_pthread_init (xlator_t *this, changelog_priv_t *priv) dm_mutex_white_init = _gf_true; if ((ret = pthread_cond_init(&priv->dm.drain_white_cond, NULL)) != 0) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_PTHREAD_COND_INIT_FAILED, "drain_white pthread_cond_init failed (%d)", ret); ret = -1; goto out; @@ -2345,7 +2390,8 @@ reconfigure (xlator_t *this, dict_t *options) GF_OPTION_RECONF ("changelog-dir", tmp, options, str, out); if (!tmp) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_DIR_OPTIONS_NOT_SET, "\"changelog-dir\" option is not set"); goto out; } @@ -2419,10 +2465,12 @@ reconfigure (xlator_t *this, dict_t *options) if (active_now) { if (!active_earlier) { - gf_log (this->name, GF_LOG_INFO, + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_HTIME_INFO, "Reconfigure: Changelog Enable"); if (gettimeofday(&tv, NULL) ) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_HTIME_ERROR, "unable to fetch htime"); ret = -1; goto out; @@ -2437,8 +2485,8 @@ reconfigure (xlator_t *this, dict_t *options) if (ret) { /* TODO */ } else { - gf_log (this->name, GF_LOG_DEBUG, - "changelog reconfigured"); + gf_msg_debug (this->name, 0, + "changelog reconfigured"); if (active_now && priv) priv->active = _gf_true; } @@ -2453,7 +2501,8 @@ changelog_freeup_options (xlator_t *this, changelog_priv_t *priv) ret = priv->cb->dtor (this, &priv->cd); if (ret) - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_FREEUP_FAILED, "could not cleanup bootstrapper"); GF_FREE (priv->changelog_brick); GF_FREE (priv->changelog_dir); @@ -2601,13 +2650,15 @@ init (xlator_t *this) GF_VALIDATE_OR_GOTO ("changelog", this, error_return); if (!this->children || this->children->next) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_CHILD_MISCONFIGURED, "translator needs a single subvolume"); goto error_return; } if (!this->parents) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, 0, + CHANGELOG_MSG_VOL_MISCONFIGURED, "dangling volume. please check volfile"); goto error_return; } @@ -2618,7 +2669,8 @@ init (xlator_t *this) this->local_pool = mem_pool_new (changelog_local_t, 64); if (!this->local_pool) { - gf_log (this->name, GF_LOG_ERROR, + gf_msg (this->name, GF_LOG_ERROR, ENOMEM, + CHANGELOG_MSG_NO_MEMORY, "failed to create local memory pool"); goto cleanup_priv; } @@ -2659,7 +2711,8 @@ init (xlator_t *this) ret = changelog_init (this, priv); if (ret) goto cleanup_rpc; - gf_log (this->name, GF_LOG_DEBUG, "changelog translator loaded"); + + gf_msg_debug (this->name, 0, "changelog translator loaded"); this->private = priv; return 0; @@ -2698,7 +2751,6 @@ fini (xlator_t *this) /* deallocate mempool */ mem_pool_destroy (this->local_pool); - /* finally, dealloac private variable */ GF_FREE (priv); } |