Whamcloud - gitweb
LU-4129 libcfs: Only dump log once per sec. to avoid EEXIST 64/8964/5
authorRyan Haasken <haasken@cray.com>
Wed, 22 Jan 2014 19:34:15 +0000 (13:34 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 1 Mar 2014 02:36:13 +0000 (02:36 +0000)
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 <haasken@cray.com>
Change-Id: I7345635ab84333d6c1b455de6059d9d72e5a88f5
Reviewed-on: http://review.whamcloud.com/8964
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
libcfs/libcfs/debug.c

index 687c476..0691471 100644 (file)
@@ -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);