From 3a655f60de084823da81f52d0da2510784b97e4e Mon Sep 17 00:00:00 2001
From: johann <johann>
Date: Fri, 28 Dec 2007 07:39:21 +0000
Subject: [PATCH] Branch b1_6 b=14398 i=johann i=bobijam

Console messages can now be disabled via lnet.printk.
---
 lnet/libcfs/debug.c                 | 6 ++----
 lnet/libcfs/linux/linux-proc.c      | 8 ++++++--
 lnet/libcfs/linux/linux-tracefile.c | 2 +-
 lnet/libcfs/tracefile.c             | 2 +-
 lnet/utils/portals.c                | 2 +-
 5 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/lnet/libcfs/debug.c b/lnet/libcfs/debug.c
index c1601d8ad8..b50ee4df89 100644
--- a/lnet/libcfs/debug.c
+++ b/lnet/libcfs/debug.c
@@ -41,7 +41,7 @@ unsigned int libcfs_debug = (D_EMERG | D_ERROR | D_WARNING | D_CONSOLE |
                              D_NETERROR | D_HA | D_CONFIG | D_IOCTL);
 EXPORT_SYMBOL(libcfs_debug);
 
-unsigned int libcfs_printk;
+unsigned int libcfs_printk = D_CANTMASK;
 EXPORT_SYMBOL(libcfs_printk);
 
 unsigned int libcfs_console_ratelimit = 0;
@@ -698,10 +698,8 @@ libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls,
         /* toconsole == 0 - all messages to debug_file_fd
          * toconsole == 1 - warnings to console, all to debug_file_fd
          * toconsole >  1 - all debug to console */
-        if ( ((mask & D_CANTMASK) &&
-             (toconsole == 1)) || (toconsole > 1)) {
+        if (((mask & libcfs_printk) && toconsole == 1) || toconsole > 1)
                 console = 1;
-        }
 #endif
 
         if ((!console) && (!debug_file_fd)) {
diff --git a/lnet/libcfs/linux/linux-proc.c b/lnet/libcfs/linux/linux-proc.c
index c317a5abf8..3be3bee533 100644
--- a/lnet/libcfs/linux/linux-proc.c
+++ b/lnet/libcfs/linux/linux-proc.c
@@ -121,11 +121,12 @@ static int __proc_dobitmasks(void *data, int write,
         int           rc;
         unsigned int *mask = data;
         int           is_subsys = (mask == &libcfs_subsystem_debug) ? 1 : 0;
+        int           is_printk = (mask == &libcfs_printk) ? 1 : 0;
 
         rc = trace_allocate_string_buffer(&tmpstr, tmpstrlen);
         if (rc < 0)
                 return rc;
-        
+
         if (!write) {
                 libcfs_debug_mask2str(tmpstr, tmpstrlen, *mask, is_subsys);
                 rc = strlen(tmpstr);
@@ -140,8 +141,11 @@ static int __proc_dobitmasks(void *data, int write,
                 rc = trace_copyin_string(tmpstr, tmpstrlen, buffer, nob);
                 if (rc < 0)
                         return rc;
-                
+
                 rc = libcfs_debug_str2mask(mask, tmpstr, is_subsys);
+                /* Always print LBUG/LASSERT to console, so keep this mask */
+                if (is_printk)
+                        *mask |= D_EMERG;
         }
 
         trace_free_string_buffer(tmpstr, tmpstrlen);
diff --git a/lnet/libcfs/linux/linux-tracefile.c b/lnet/libcfs/linux/linux-tracefile.c
index d238c52647..59560278a5 100644
--- a/lnet/libcfs/linux/linux-tracefile.c
+++ b/lnet/libcfs/linux/linux-tracefile.c
@@ -221,7 +221,7 @@ void print_to_console(struct ptldebug_header *hdr, int mask, const char *buf,
 	} else if ((mask & D_WARNING) != 0) {
 		prefix = "Lustre";
 		ptype = KERN_WARNING;
-	} else if ((mask & libcfs_printk) != 0 || (mask & D_CONSOLE)) {
+	} else if ((mask & (D_CONSOLE | libcfs_printk)) != 0) {
 		prefix = "Lustre";
 		ptype = KERN_INFO;
 	}
diff --git a/lnet/libcfs/tracefile.c b/lnet/libcfs/tracefile.c
index 3ca5ee8538..a0b61ab3b2 100644
--- a/lnet/libcfs/tracefile.c
+++ b/lnet/libcfs/tracefile.c
@@ -343,7 +343,7 @@ int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls, int subsys, int mask,
         __LASSERT (tage->used <= CFS_PAGE_SIZE);
 
 console:
-        if (!((mask & D_CANTMASK) != 0 || (mask & libcfs_printk) != 0)) {
+        if ((mask & libcfs_printk) == 0) {
                 /* no console output requested */
                 if (tcd != NULL)
                         trace_put_tcd(tcd);
diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c
index 0f2c1ca7c2..1acddcdf4e 100644
--- a/lnet/utils/portals.c
+++ b/lnet/utils/portals.c
@@ -53,7 +53,7 @@
 #include "parser.h"
 
 unsigned int libcfs_debug;
-unsigned int libcfs_printk;
+unsigned int libcfs_printk = D_CANTMASK;
 
 static int   g_net_set;
 static __u32 g_net;
-- 
GitLab