From 07e8f0226d5263501d2b23ed008c59ed45a5a5bd Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Fri, 2 May 2014 13:55:59 +0530 Subject: logging: Add extra logs to enable testing of log suppression Note: This patch may be reverted once the testing effort is complete, if desired. Change-Id: I840399c531a43049749073d4d59bc0c85f525be3 BUG: 1075611 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/7681 Reviewed-by: Raghavendra G Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/logging.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index e18971c26bf..2a8335eb052 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -48,6 +48,11 @@ #include "glusterfs.h" #include "timer.h" +/* Do not replace gf_log in TEST_LOG with gf_msg, as there is a slight chance + * that it could lead to an infinite recursion.*/ +#define TEST_LOG(__msg, __args ...) \ + gf_log ("logging-infra", GF_LOG_DEBUG, __msg, ##__args); + void gf_log_flush_timeout_cbk (void *data); @@ -1796,8 +1801,11 @@ unlock: if (list_empty (©)) return; + TEST_LOG("Log buffer size reduced. About to flush %d extra log " + "messages", count); // ... and then flush them outside the lock. gf_log_flush_list (©, ctx); + TEST_LOG("Just flushed %d extra log messages", count); return; } @@ -1816,6 +1824,8 @@ __gf_log_inject_timer_event (glusterfs_ctx_t *ctx) timeout.tv_sec = ctx->log.timeout; timeout.tv_nsec = 0; + TEST_LOG("Starting timer now. Timeout = %u, current buf size = %d", + ctx->log.timeout, ctx->log.lru_size); ctx->log.log_flush_timer = gf_timer_call_after (ctx, timeout, gf_log_flush_timeout_cbk, (void *)ctx); @@ -1849,6 +1859,8 @@ gf_log_flush_timeout_cbk (void *data) ctx = (glusterfs_ctx_t *) data; + TEST_LOG("Log timer timed out. About to flush outstanding messages if " + "present"); gf_log_flush_msgs (ctx); (void) gf_log_inject_timer_event (ctx); @@ -1966,6 +1978,10 @@ _gf_msg_internal (const char *domain, const char *file, const char *function, /* If the list is full, flush the lru msg to disk and also * release it after unlock, and ... * */ + if (first->refcount >= 1) + TEST_LOG("Buffer overflow of a buffer whose size limit " + "is %d. About to flush least recently used log" + " message to disk", size); list_del_init (&first->msg_list); ctx->log.lru_cur_size--; flush_lru = _gf_true; -- cgit