From ad17dd9122128fdea668894ace6a47c970126889 Mon Sep 17 00:00:00 2001 From: Ryan Haasken Date: Wed, 22 Jan 2014 13:34:15 -0600 Subject: [PATCH] LU-4129 libcfs: Only dump log once per sec. to avoid EEXIST Since the log file name contains the current time in seconds, dumping the logs more than once per second causes EEXIST errors to be emitted. Add a static variable to libcfs_debug_dumplog_internal that records the time of the last Lustre log dump. If the current time in seconds is equal to the last time, do not dump logs again. Note that this is not thread-safe. However, in the rare case that two threads try to access last_dump_time simultaneously, the worst thing that could happen is that one of the threads will get an EEXIST error when trying to write the log file. This is no worse than the current situation, and it is not likely to happen. Signed-off-by: Ryan Haasken Change-Id: I7345635ab84333d6c1b455de6059d9d72e5a88f5 Reviewed-on: http://review.whamcloud.com/8964 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Bob Glossman --- libcfs/libcfs/debug.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index 687c476..0691471 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -229,14 +229,20 @@ libcfs_debug_str2mask(int *mask, const char *str, int is_subsys) */ void libcfs_debug_dumplog_internal(void *arg) { + static time_t last_dump_time; + time_t current_time; DECL_JOURNAL_DATA; PUSH_JOURNAL; - if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0) { + current_time = cfs_time_current_sec(); + + if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0 && + current_time > last_dump_time) { + last_dump_time = current_time; snprintf(debug_file_name, sizeof(debug_file_name) - 1, "%s.%ld." LPLD, libcfs_debug_file_path_arr, - cfs_time_current_sec(), (long_ptr_t)arg); + current_time, (long_ptr_t)arg); printk(KERN_ALERT "LustreError: dumping log to %s\n", debug_file_name); cfs_tracefile_dump_all_pages(debug_file_name); -- 1.8.3.1