Whamcloud - gitweb
LU-12349 llite: console message for disabled flock call
[fs/lustre-release.git] / libcfs / libcfs / tracefile.c
index 5074ab1..81e9fb2 100644 (file)
@@ -46,7 +46,6 @@
 #include <linux/pagemap.h>
 #include <linux/uaccess.h>
 #include <libcfs/linux/linux-fs.h>
-#include <libcfs/linux/linux-misc.h>
 #include <libcfs/libcfs.h>
 
 /* XXX move things up to the top, comment */
@@ -359,9 +358,16 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
                         break;
         }
 
-       if (*(string_buf+needed-1) != '\n')
+       if (*(string_buf + needed - 1) != '\n') {
                printk(KERN_INFO "format at %s:%d:%s doesn't end in "
                       "newline\n", file, msgdata->msg_line, msgdata->msg_fn);
+       } else if (mask & D_TTY) {
+               /* TTY needs '\r\n' to move carriage to leftmost position */
+               if (needed < 2 || *(string_buf + needed - 2) != '\r')
+                       printk(KERN_INFO "format at %s:%d:%s doesn't end in "
+                              "'\\r\\n'\n", file, msgdata->msg_line,
+                              msgdata->msg_fn);
+       }
 
         header.ph_len = known_size + needed;
        debug_buf = (char *)page_address(tage->page) + tage->used;
@@ -395,34 +401,34 @@ console:
                 return 1;
         }
 
-        if (cdls != NULL) {
-                if (libcfs_console_ratelimit &&
-                    cdls->cdls_next != 0 &&     /* not first time ever */
-                    !cfs_time_after(cfs_time_current(), cdls->cdls_next)) {
-                        /* skipping a console message */
-                        cdls->cdls_count++;
-                        if (tcd != NULL)
-                                cfs_trace_put_tcd(tcd);
-                        return 1;
-                }
+       if (cdls != NULL) {
+               if (libcfs_console_ratelimit &&
+                   cdls->cdls_next != 0 &&     /* not first time ever */
+                   time_before(jiffies, cdls->cdls_next)) {
+                       /* skipping a console message */
+                       cdls->cdls_count++;
+                       if (tcd != NULL)
+                               cfs_trace_put_tcd(tcd);
+                       return 1;
+               }
 
-                if (cfs_time_after(cfs_time_current(), cdls->cdls_next +
-                                                       libcfs_console_max_delay
-                                                       + cfs_time_seconds(10))) {
-                        /* last timeout was a long time ago */
-                        cdls->cdls_delay /= libcfs_console_backoff * 4;
-                } else {
-                        cdls->cdls_delay *= libcfs_console_backoff;
-                }
+               if (time_after(jiffies, cdls->cdls_next +
+                                       libcfs_console_max_delay +
+                                       cfs_time_seconds(10))) {
+                       /* last timeout was a long time ago */
+                       cdls->cdls_delay /= libcfs_console_backoff * 4;
+               } else {
+                       cdls->cdls_delay *= libcfs_console_backoff;
+               }
 
                if (cdls->cdls_delay < libcfs_console_min_delay)
                        cdls->cdls_delay = libcfs_console_min_delay;
                else if (cdls->cdls_delay > libcfs_console_max_delay)
                        cdls->cdls_delay = libcfs_console_max_delay;
 
-                /* ensure cdls_next is never zero after it's been seen */
-                cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1;
-        }
+               /* ensure cdls_next is never zero after it's been seen */
+               cdls->cdls_next = (jiffies + cdls->cdls_delay) | 1;
+       }
 
         if (tcd != NULL) {
                 cfs_print_to_console(&header, mask, string_buf, needed, file,
@@ -462,8 +468,9 @@ console:
                                   cdls->cdls_count,
                                   (cdls->cdls_count > 1) ? "s" : "");
 
-                cfs_print_to_console(&header, mask,
-                                     string_buf, needed, file, msgdata->msg_fn);
+               /* Do not allow print this to TTY */
+               cfs_print_to_console(&header, mask & ~D_TTY, string_buf,
+                                    needed, file, msgdata->msg_fn);
 
                put_cpu();
                 cdls->cdls_count = 0;
@@ -834,13 +841,16 @@ int cfs_trace_daemon_command(char *str)
                 cfs_tracefile_write_lock();
                 memset(cfs_tracefile, 0, sizeof(cfs_tracefile));
 
-        } else if (strncmp(str, "size=", 5) == 0) {
-                cfs_tracefile_size = simple_strtoul(str + 5, NULL, 0);
-                if (cfs_tracefile_size < 10 || cfs_tracefile_size > 20480)
-                        cfs_tracefile_size = CFS_TRACEFILE_SIZE;
-                else
-                        cfs_tracefile_size <<= 20;
+       } else if (strncmp(str, "size=", 5) == 0) {
+               unsigned long tmp;
 
+               rc = kstrtoul(str + 5, 10, &tmp);
+               if (!rc) {
+                       if (tmp < 10 || tmp > 20480)
+                               cfs_tracefile_size = CFS_TRACEFILE_SIZE;
+                       else
+                               cfs_tracefile_size = tmp << 20;
+               }
         } else if (strlen(str) >= sizeof(cfs_tracefile)) {
                 rc = -ENAMETOOLONG;
         } else if (str[0] != '/') {