Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / libcfs / libcfs / tracefile.c
index b4dc50b..15f70de 100644 (file)
@@ -16,8 +16,8 @@
  * in the LICENSE file that accompanied this code).
  *
  * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see [sun.com URL with a
- * copy of GPLv2].
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  * CA 95054 USA or visit www.sun.com if you need additional information or
@@ -187,8 +187,10 @@ static void tcd_shrink(struct trace_cpu_data *tcd)
         * from here: this will lead to infinite recursion.
         */
 
-        printk(KERN_WARNING "debug daemon buffer overflowed; discarding"
-               " 10%% of pages (%d of %ld)\n", pgcount + 1, tcd->tcd_cur_pages);
+        if (printk_ratelimit())
+                printk(KERN_WARNING "debug daemon buffer overflowed; "
+                       "discarding 10%% of pages (%d of %ld)\n",
+                       pgcount + 1, tcd->tcd_cur_pages);
 
         CFS_INIT_LIST_HEAD(&pc.pc_pages);
         spin_lock_init(&pc.pc_lock);
@@ -236,7 +238,7 @@ static struct trace_page *trace_get_tage(struct trace_cpu_data *tcd,
 int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls, int subsys, int mask,
                        const char *file, const char *fn, const int line,
                        const char *format1, va_list args,
-                       const char *format2, ...)                      
+                       const char *format2, ...)
 {
         struct trace_cpu_data   *tcd = NULL;
         struct ptldebug_header   header;
@@ -281,7 +283,7 @@ int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls, int subsys, int mask,
          * _without_ terminating NULL.
          * if needed is to small for this format.
          */
-        for (i=0;i<2;i++) {
+        for (i = 0; i < 2; i++) {
                 tage = trace_get_tage(tcd, needed + known_size + 1);
                 if (tage == NULL) {
                         if (needed + known_size > CFS_PAGE_SIZE)
@@ -292,7 +294,8 @@ int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls, int subsys, int mask,
                         goto console;
                 }
 
-                string_buf = (char *)cfs_page_address(tage->page)+tage->used+known_size;
+                string_buf = (char *)cfs_page_address(tage->page) +
+                                        tage->used + known_size;
 
                 max_nob = CFS_PAGE_SIZE - tage->used - known_size;
                 if (max_nob <= 0) {
@@ -309,26 +312,26 @@ int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls, int subsys, int mask,
                         needed = vsnprintf(string_buf, max_nob, format1, ap);
                         va_end(ap);
                 }
-               
 
                 if (format2) {
                        remain = max_nob - needed;
                         if (remain < 0)
                                 remain = 0;
-               
+
                         va_start(ap, format2);
-                        needed += vsnprintf(string_buf+needed, remain, format2, ap);
+                        needed += vsnprintf(string_buf + needed, remain,
+                                            format2, ap);
                         va_end(ap);
                 }
 
                 if (needed < max_nob) /* well. printing ok.. */
                         break;
         }
-       
+
         if (*(string_buf+needed-1) != '\n')
                 printk(KERN_INFO "format at %s:%d:%s doesn't end in newline\n",
                        file, line, fn);
-       
+
         header.ph_len = known_size + needed;
         debug_buf = (char *)cfs_page_address(tage->page) + tage->used;
 
@@ -446,7 +449,7 @@ libcfs_assertion_failed(const char *expr, const char *file,
 {
         libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line,
                          "ASSERTION(%s) failed\n", expr);
-        LBUG();
+        lbug_with_loc(file, func, line);
 }
 EXPORT_SYMBOL(libcfs_assertion_failed);
 
@@ -727,11 +730,11 @@ int trace_copyin_string(char *knl_buffer, int knl_buffer_nob,
                         const char *usr_buffer, int usr_buffer_nob)
 {
         int    nob;
-        
+
         if (usr_buffer_nob > knl_buffer_nob)
                 return -EOVERFLOW;
-        
-        if (copy_from_user((void *)knl_buffer, 
+
+        if (copy_from_user((void *)knl_buffer,
                            (void *)usr_buffer, usr_buffer_nob))
                 return -EFAULT;
 
@@ -757,17 +760,17 @@ int trace_copyout_string(char *usr_buffer, int usr_buffer_nob,
          * copied out string - usually "\n", for /proc entries and "" (i.e. a
          * terminating zero byte) for sysctl entries */
         int   nob = strlen(knl_buffer);
-        
+
         if (nob > usr_buffer_nob)
                 nob = usr_buffer_nob;
-        
+
         if (copy_to_user(usr_buffer, knl_buffer, nob))
                 return -EFAULT;
-        
+
         if (append != NULL && nob < usr_buffer_nob) {
                 if (copy_to_user(usr_buffer + nob, append, 1))
                         return -EFAULT;
-                
+
                 nob++;
         }
 
@@ -778,7 +781,7 @@ int trace_allocate_string_buffer(char **str, int nob)
 {
         if (nob > 2 * CFS_PAGE_SIZE)            /* string must be "sensible" */
                 return -EINVAL;
-        
+
         *str = cfs_alloc(nob, CFS_ALLOC_STD | CFS_ALLOC_ZERO);
         if (*str == NULL)
                 return -ENOMEM;
@@ -820,7 +823,7 @@ out:
 int trace_daemon_command(char *str)
 {
         int       rc = 0;
-        
+
        tracefile_write_lock();
 
        if (strcmp(str, "stop") == 0) {
@@ -879,7 +882,7 @@ int trace_set_debug_mb(int mb)
         int pages;
         int limit = trace_max_debug_mb();
         struct trace_cpu_data *tcd;
-        
+
        if (mb < num_possible_cpus())
                return -EINVAL;
 
@@ -920,7 +923,7 @@ int trace_get_debug_mb(void)
         int j;
         struct trace_cpu_data *tcd;
         int total_pages = 0;
-        
+
         tracefile_read_lock();
 
         tcd_for_each(tcd, i, j)