Whamcloud - gitweb
use special macro for print time_t, cleanup in includes.
[fs/lustre-release.git] / lnet / libcfs / debug.c
index bf108bb..4b275e6 100644 (file)
@@ -35,29 +35,44 @@ static char debug_file_name[1024];
 
 #ifdef __KERNEL__
 unsigned int libcfs_subsystem_debug = ~0;
+CFS_MODULE_PARM(libcfs_subsystem_debug, "i", int, 0644,
+                "Lustre kernel debug subsystem mask");
 EXPORT_SYMBOL(libcfs_subsystem_debug);
 
 unsigned int libcfs_debug = (D_EMERG | D_ERROR | D_WARNING | D_CONSOLE |
                              D_NETERROR | D_HA | D_CONFIG | D_IOCTL);
+CFS_MODULE_PARM(libcfs_debug, "i", int, 0644,
+                "Lustre kernel debug mask");
 EXPORT_SYMBOL(libcfs_debug);
 
 int libcfs_debug_mb = -1;
+CFS_MODULE_PARM(libcfs_debug_mb, "i", int, 0644,
+                "Total debug buffer size.");
 EXPORT_SYMBOL(libcfs_debug_mb);
-CFS_MODULE_PARM(libcfs_debug_mb, "i", int, 0644, "Total debug buffer size.");
 
 unsigned int libcfs_printk = D_CANTMASK;
+CFS_MODULE_PARM(libcfs_printk, "i", uint, 0644,
+                "Lustre kernel debug console mask");
 EXPORT_SYMBOL(libcfs_printk);
 
 unsigned int libcfs_console_ratelimit = 1;
+CFS_MODULE_PARM(libcfs_console_ratelimit, "i", uint, 0644,
+                "Lustre kernel debug console ratelimit (0 to disable)");
 EXPORT_SYMBOL(libcfs_console_ratelimit);
 
 cfs_duration_t libcfs_console_max_delay;
+CFS_MODULE_PARM(libcfs_console_max_delay, "l", ulong, 0644,
+                "Lustre kernel debug console max delay (jiffies)");
 EXPORT_SYMBOL(libcfs_console_max_delay);
 
 cfs_duration_t libcfs_console_min_delay;
+CFS_MODULE_PARM(libcfs_console_min_delay, "l", ulong, 0644,
+                "Lustre kernel debug console min delay (jiffies)");
 EXPORT_SYMBOL(libcfs_console_min_delay);
 
 unsigned int libcfs_console_backoff = CDEBUG_DEFAULT_BACKOFF;
+CFS_MODULE_PARM(libcfs_console_backoff, "i", uint, 0644,
+                "Lustre kernel debug console backoff factor");
 EXPORT_SYMBOL(libcfs_console_backoff);
 
 unsigned int libcfs_debug_binary = 1;
@@ -73,6 +88,8 @@ unsigned int libcfs_catastrophe;
 EXPORT_SYMBOL(libcfs_catastrophe);
 
 unsigned int libcfs_panic_on_lbug = 0;
+CFS_MODULE_PARM(libcfs_panic_on_lbug, "i", uint, 0644,
+                "Lustre kernel panic on LBUG");
 EXPORT_SYMBOL(libcfs_panic_on_lbug);
 
 atomic_t libcfs_kmemory = ATOMIC_INIT(0);
@@ -85,6 +102,9 @@ char debug_file_path[1024] = "/r/tmp/lustre-log";
 #else
 char debug_file_path[1024] = "/tmp/lustre-log";
 #endif
+CFS_MODULE_PARM(debug_file_path, "s", charp, 0644,
+                "Path for dumping debug logs, "
+                "set 'NONE' to prevent log dumping");
 
 int libcfs_panic_in_progress;
 
@@ -385,11 +405,14 @@ void libcfs_debug_dumplog_internal(void *arg)
 
         CFS_PUSH_JOURNAL;
 
-        snprintf(debug_file_name, sizeof(debug_file_path) - 1, "%s.%ld.%ld",
-                 debug_file_path, cfs_time_current_sec(), (long)arg);
-        printk(KERN_ALERT "LustreError: dumping log to %s\n", debug_file_name);
-        tracefile_dump_all_pages(debug_file_name);
-
+        if (strncmp(debug_file_path, "NONE", 4) != 0) {
+                snprintf(debug_file_name, sizeof(debug_file_path) - 1,
+                         "%s.%ld.%ld", debug_file_path, cfs_time_current_sec(),
+                         (long)arg);
+                printk(KERN_ALERT "LustreError: dumping log to %s\n",
+                       debug_file_name);
+                tracefile_dump_all_pages(debug_file_name);
+        }
         CFS_POP_JOURNAL;
 }
 
@@ -634,7 +657,7 @@ int libcfs_debug_init(unsigned long bufsize)
 
         if (debug_file_name[0] == '\0' && debug_file_path[0] != '\0')
                 snprintf(debug_file_name, sizeof(debug_file_name) - 1,
-                         "%s-%s-%lu.log", debug_file_path, source_nid, time(0));
+                         "%s-%s-"CFS_TIME_T".log", debug_file_path, source_nid, time(0));
 
         if (strcmp(debug_file_name, "stdout") == 0 ||
             strcmp(debug_file_name, "-") == 0) {
@@ -702,8 +725,9 @@ libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls,
         int            nob;
         int            remain;
         va_list        ap;
-        char           buf[PAGE_SIZE]; /* size 4096 used for compatimble with linux,
-                                        * where message can`t be exceed PAGE_SIZE */
+        char           buf[CFS_PAGE_SIZE]; /* size 4096 used for compatimble
+                                            * with linux, where message can`t
+                                            * be exceed PAGE_SIZE */
         int            console = 0;
         char *prefix = "Lustre";
 
@@ -796,7 +820,7 @@ out_file:
 
         gettimeofday(&tv, NULL);
 
-        fprintf(debug_file_fd, "%lu.%06lu:%u:%s:(%s:%d:%s()): %s",
+        fprintf(debug_file_fd, CFS_TIME_T".%06lu:%u:%s:(%s:%d:%s()): %s",
                 tv.tv_sec, tv.tv_usec, source_pid, source_nid,
                 file, line, fn, buf);