Whamcloud - gitweb
This fixes the bug that new S_* debug subsystems were not being
authorphil <phil>
Fri, 18 Jul 2003 16:42:00 +0000 (16:42 +0000)
committerphil <phil>
Fri, 18 Jul 2003 16:42:00 +0000 (16:42 +0000)
printed in debug logs.  The problem was a desynchronization between
the kernel and userspace tools.

The old code would silently drop unknown subsystem messages.  Now a
warning is printed and they are included.

The subsystems are no longer a crazy twist of left-shifted integers, but
a normal bitmask.  There may have been a good reason for the craziness,
to try to fit a subsystem and type into one integer, but it's long gone.

lnet/include/config.h.in
lnet/include/linux/kp30.h
lnet/libcfs/debug.c
lnet/lnet/api-init.c
lnet/utils/debug.c
lustre/portals/include/config.h.in
lustre/portals/include/linux/kp30.h
lustre/portals/libcfs/debug.c
lustre/portals/portals/api-init.c
lustre/portals/utils/debug.c

index a4b1e1e..648a1f1 100644 (file)
@@ -12,3 +12,8 @@
 /* IOCTL Buffer Size */
 #undef OBD_MAX_IOCTL_BUFFER
 
+/* temporary pinger */
+#undef ENABLE_PINGER
+
+/* experimental orphans */
+#undef ENABLE_ORPHANS
index 7b454f0..bd263c1 100644 (file)
@@ -4,7 +4,6 @@
 #ifndef _KP30_INCLUDED
 #define _KP30_INCLUDED
 
-
 #define PORTAL_DEBUG
 
 #ifndef offsetof
@@ -20,40 +19,34 @@ extern unsigned int portal_subsystem_debug;
 extern unsigned int portal_stack;
 extern unsigned int portal_debug;
 extern unsigned int portal_printk;
-/* Debugging subsystems  (8 bit ID)
- *
- * If you add debug subsystem #32, you need to send email to phil, because
- * you're going to break kernel subsystem debug filtering. */
-#define S_UNDEFINED    (0 << 24)
-#define S_MDC          (1 << 24)
-#define S_MDS          (2 << 24)
-#define S_OSC          (3 << 24)
-#define S_OST          (4 << 24)
-#define S_CLASS        (5 << 24)
-#define S_OBDFS        (6 << 24) /* obsolete */
-#define S_LLITE        (7 << 24)
-#define S_RPC          (8 << 24)
-#define S_EXT2OBD      (9 << 24) /* obsolete */
-#define S_PORTALS     (10 << 24)
-#define S_SOCKNAL     (11 << 24)
-#define S_QSWNAL      (12 << 24)
-#define S_PINGER      (13 << 24)
-#define S_FILTER      (14 << 24)
-#define S_TRACE       (15 << 24) /* obsolete */
-#define S_ECHO        (16 << 24)
-#define S_LDLM        (17 << 24)
-#define S_LOV         (18 << 24)
-#define S_GMNAL       (19 << 24)
-#define S_PTLROUTER   (20 << 24)
-#define S_COBD        (21 << 24)
-#define S_PTLBD       (22 << 24)
-#define S_LOG         (23 << 24)
-#define S_MGMT        (24 << 24)
-
-/* If you change these values, please keep portals/linux/utils/debug.c
+/* Debugging subsystems (32 bits, non-overlapping) */
+#define S_UNDEFINED    (1 << 0)
+#define S_MDC          (1 << 1)
+#define S_MDS          (1 << 2)
+#define S_OSC          (1 << 3)
+#define S_OST          (1 << 4)
+#define S_CLASS        (1 << 5)
+#define S_LOG          (1 << 6)
+#define S_LLITE        (1 << 7)
+#define S_RPC          (1 << 8)
+#define S_MGMT         (1 << 9)
+#define S_PORTALS     (1 << 10)
+#define S_SOCKNAL     (1 << 11)
+#define S_QSWNAL      (1 << 12)
+#define S_PINGER      (1 << 13)
+#define S_FILTER      (1 << 14)
+#define S_PTLBD       (1 << 15)
+#define S_ECHO        (1 << 16)
+#define S_LDLM        (1 << 17)
+#define S_LOV         (1 << 18)
+#define S_GMNAL       (1 << 19)
+#define S_PTLROUTER   (1 << 20)
+#define S_COBD        (1 << 21)
+
+/* If you change these values, please keep portals/utils/debug.c
  * up to date! */
 
-/* Debugging masks (24 bits, non-overlapping) */
+/* Debugging masks (32 bits, non-overlapping) */
 #define D_TRACE     (1 << 0) /* ENTRY/EXIT markers */
 #define D_INODE     (1 << 1)
 #define D_SUPER     (1 << 2)
@@ -116,7 +109,7 @@ do {                                                                          \
         CHECK_STACK(CDEBUG_STACK);                                            \
         if (!(mask) || ((mask) & (D_ERROR | D_EMERG)) ||                      \
             (portal_debug & (mask) &&                                         \
-             portal_subsystem_debug & (1 << (DEBUG_SUBSYSTEM >> 24))))        \
+             portal_subsystem_debug & DEBUG_SUBSYSTEM))                       \
                 portals_debug_msg(DEBUG_SUBSYSTEM, mask,                      \
                                   __FILE__, __FUNCTION__, __LINE__,           \
                                   CDEBUG_STACK, format, ## a);                \
@@ -163,7 +156,6 @@ do {                                                                    \
 #define EXIT                            do { } while (0)
 #endif
 
-
 #ifdef __KERNEL__
 # include <linux/vmalloc.h>
 # include <linux/time.h>
@@ -569,7 +561,7 @@ int portals_debug_cleanup(void);
 int portals_debug_clear_buffer(void);
 int portals_debug_mark_buffer(char *text);
 int portals_debug_set_daemon(unsigned int cmd, unsigned int length,
-                char *file, unsigned int size);
+                             char *file, unsigned int size);
 __s32 portals_debug_copy_to_user(char *buf, unsigned long len);
 #if (__GNUC__)
 /* Use the special GNU C __attribute__ hack to have the compiler check the
@@ -585,9 +577,9 @@ void portals_debug_msg(int subsys, int mask, char *file, const char *fn,
                        const char *format, ...)
         __attribute__ ((format (printf, 7, 8)));
 #else
-void portals_debug_msg (int subsys, int mask, char *file, const char *fn,
-                        const int line, unsigned long stack,
-                        const char *format, ...);
+void portals_debug_msg(int subsys, int mask, char *file, const char *fn,
+                       const int line, unsigned long stack,
+                       const char *format, ...);
 #endif /* __GNUC__ */
 void portals_debug_set_level(unsigned int debug_level);
 
@@ -621,9 +613,9 @@ extern void kportal_blockallsigs (void);
 # define PORTAL_ALLOC(ptr, size) do { (ptr) = malloc(size); } while (0);
 # define PORTAL_FREE(a, b) do { free(a); } while (0);
 # define portals_debug_msg(subsys, mask, file, fn, line, stack, format, a...) \
-    printf ("%02x:%06x (@%lu %s:%s,l. %d %d %lu): " format,                    \
-            (subsys) >> 24, (mask), (long)time(0), file, fn, line,            \
-            getpid() , stack, ## a);
+    printf("%02x:%06x (@%lu %s:%s,l. %d %d %lu): " format,                    \
+           (subsys), (mask), (long)time(0), file, fn, line,                   \
+           getpid() , stack, ## a);
 #endif
 
 #ifndef CURRENT_TIME
@@ -914,13 +906,13 @@ ptl_handle_ni_t *kportal_get_ni (int nal);
 void kportal_put_ni (int nal);
 
 #ifdef __CYGWIN__
-#ifndef BITS_PER_LONG
-#if (~0UL) == 0xffffffffUL
-#define BITS_PER_LONG 32
-#else
-#define BITS_PER_LONG 64
-#endif
-#endif
+# ifndef BITS_PER_LONG
+#  if (~0UL) == 0xffffffffUL
+#   define BITS_PER_LONG 32
+#  else
+#   define BITS_PER_LONG 64
+#  endif
+# endif
 #endif
 
 #if (BITS_PER_LONG == 32 || __WORDSIZE == 32)
index aefe5b9..f37cd96 100644 (file)
@@ -728,8 +728,8 @@ portals_debug_msg(int subsys, int mask, char *file, const char *fn,
         do_gettimeofday(&tv);
 
         prefix_nob = snprintf(debug_buf + debug_off, max_nob,
-                              "%02x:%06x:%d:%lu.%06lu ",
-                              subsys >> 24, mask, smp_processor_id(),
+                              "%06x:%06x:%d:%lu.%06lu ",
+                              subsys, mask, smp_processor_id(),
                               tv.tv_sec, tv.tv_usec);
         max_nob -= prefix_nob;
 
@@ -752,7 +752,7 @@ portals_debug_msg(int subsys, int mask, char *file, const char *fn,
 
         va_start(ap, format);
         msg_nob += vsnprintf(debug_buf + debug_off + prefix_nob + msg_nob,
-                            max_nob, format, ap);
+                             max_nob, format, ap);
         max_nob -= msg_nob;
         va_end(ap);
 
index e59c922..dc1fead 100644 (file)
@@ -26,7 +26,7 @@
 #include <portals/api-support.h>
 
 int ptl_init;
-unsigned int portal_subsystem_debug = 0xfff7e3ff;
+unsigned int portal_subsystem_debug = ~0 - (S_PORTALS | S_QSWNAL | S_SOCKNAL | S_GMNAL);
 unsigned int portal_debug = ~0;
 unsigned int portal_printk;
 unsigned int portal_stack;
index 78271d5..fe7c242 100644 (file)
@@ -57,13 +57,14 @@ static int subsystem_array[1 << 8];
 static int debug_mask = ~0;
 
 static const char *portal_debug_subsystems[] =
-        {"undefined", "mdc", "mds", "osc", "ost", "class", "obdfs", "llite",
-         "rpc", "ext2obd", "portals", "socknal", "qswnal", "pinger", "filter",
-         "obdtrace", "echo", "ldlm", "lov", "gmnal", "router", "ptldb", NULL};
+        {"undefined", "mdc", "mds", "osc", "ost", "class", "log", "llite",
+         "rpc", "mgmt", "portals", "socknal", "qswnal", "pinger", "filter",
+         "ptlbd", "echo", "ldlm", "lov", "gmnal", "router", "cobd", NULL};
 static const char *portal_debug_masks[] =
         {"trace", "inode", "super", "ext2", "malloc", "cache", "info", "ioctl",
          "blocks", "net", "warning", "buffs", "other", "dentry", "portals",
-         "page", "dlmtrace", "error", "emerg", "ha", "rpctrace", "vfstrace", NULL};
+         "page", "dlmtrace", "error", "emerg", "ha", "rpctrace", "vfstrace",
+         NULL};
 
 struct debug_daemon_cmd {
         char *cmd;
@@ -230,7 +231,7 @@ static void dump_buffer(FILE *fd, char *buf, int size, int raw)
 {
         char *p, *z;
         unsigned long subsystem, debug, dropped = 0, kept = 0;
-        int max_sub, max_type;
+        int max_sub, max_type, warn = 0;
 
         for (max_sub = 0; portal_debug_subsystems[max_sub] != NULL; max_sub++)
                 ;
@@ -247,8 +248,13 @@ static void dump_buffer(FILE *fd, char *buf, int size, int raw)
                 z++;
                 /* for some reason %*s isn't working. */
                 *p = '\0';
-                if (subsystem < max_sub &&
-                    subsystem_array[subsystem] &&
+                if (subsystem >= max_sub && warn == 0) {
+                        fprintf(stderr, "warning: unrecognized debug subsystem "
+                                "%lx; did someone update kp30.h but not "
+                                "portals/utils/debug.c?\n", subsystem);
+                        warn = 1;
+                }
+                if ((subsystem >= max_sub || subsystem_array[subsystem]) &&
                     (!debug || (debug_mask & debug))) {
                         if (raw)
                                 fprintf(fd, "%s\n", buf);
index a4b1e1e..648a1f1 100644 (file)
@@ -12,3 +12,8 @@
 /* IOCTL Buffer Size */
 #undef OBD_MAX_IOCTL_BUFFER
 
+/* temporary pinger */
+#undef ENABLE_PINGER
+
+/* experimental orphans */
+#undef ENABLE_ORPHANS
index 7b454f0..bd263c1 100644 (file)
@@ -4,7 +4,6 @@
 #ifndef _KP30_INCLUDED
 #define _KP30_INCLUDED
 
-
 #define PORTAL_DEBUG
 
 #ifndef offsetof
@@ -20,40 +19,34 @@ extern unsigned int portal_subsystem_debug;
 extern unsigned int portal_stack;
 extern unsigned int portal_debug;
 extern unsigned int portal_printk;
-/* Debugging subsystems  (8 bit ID)
- *
- * If you add debug subsystem #32, you need to send email to phil, because
- * you're going to break kernel subsystem debug filtering. */
-#define S_UNDEFINED    (0 << 24)
-#define S_MDC          (1 << 24)
-#define S_MDS          (2 << 24)
-#define S_OSC          (3 << 24)
-#define S_OST          (4 << 24)
-#define S_CLASS        (5 << 24)
-#define S_OBDFS        (6 << 24) /* obsolete */
-#define S_LLITE        (7 << 24)
-#define S_RPC          (8 << 24)
-#define S_EXT2OBD      (9 << 24) /* obsolete */
-#define S_PORTALS     (10 << 24)
-#define S_SOCKNAL     (11 << 24)
-#define S_QSWNAL      (12 << 24)
-#define S_PINGER      (13 << 24)
-#define S_FILTER      (14 << 24)
-#define S_TRACE       (15 << 24) /* obsolete */
-#define S_ECHO        (16 << 24)
-#define S_LDLM        (17 << 24)
-#define S_LOV         (18 << 24)
-#define S_GMNAL       (19 << 24)
-#define S_PTLROUTER   (20 << 24)
-#define S_COBD        (21 << 24)
-#define S_PTLBD       (22 << 24)
-#define S_LOG         (23 << 24)
-#define S_MGMT        (24 << 24)
-
-/* If you change these values, please keep portals/linux/utils/debug.c
+/* Debugging subsystems (32 bits, non-overlapping) */
+#define S_UNDEFINED    (1 << 0)
+#define S_MDC          (1 << 1)
+#define S_MDS          (1 << 2)
+#define S_OSC          (1 << 3)
+#define S_OST          (1 << 4)
+#define S_CLASS        (1 << 5)
+#define S_LOG          (1 << 6)
+#define S_LLITE        (1 << 7)
+#define S_RPC          (1 << 8)
+#define S_MGMT         (1 << 9)
+#define S_PORTALS     (1 << 10)
+#define S_SOCKNAL     (1 << 11)
+#define S_QSWNAL      (1 << 12)
+#define S_PINGER      (1 << 13)
+#define S_FILTER      (1 << 14)
+#define S_PTLBD       (1 << 15)
+#define S_ECHO        (1 << 16)
+#define S_LDLM        (1 << 17)
+#define S_LOV         (1 << 18)
+#define S_GMNAL       (1 << 19)
+#define S_PTLROUTER   (1 << 20)
+#define S_COBD        (1 << 21)
+
+/* If you change these values, please keep portals/utils/debug.c
  * up to date! */
 
-/* Debugging masks (24 bits, non-overlapping) */
+/* Debugging masks (32 bits, non-overlapping) */
 #define D_TRACE     (1 << 0) /* ENTRY/EXIT markers */
 #define D_INODE     (1 << 1)
 #define D_SUPER     (1 << 2)
@@ -116,7 +109,7 @@ do {                                                                          \
         CHECK_STACK(CDEBUG_STACK);                                            \
         if (!(mask) || ((mask) & (D_ERROR | D_EMERG)) ||                      \
             (portal_debug & (mask) &&                                         \
-             portal_subsystem_debug & (1 << (DEBUG_SUBSYSTEM >> 24))))        \
+             portal_subsystem_debug & DEBUG_SUBSYSTEM))                       \
                 portals_debug_msg(DEBUG_SUBSYSTEM, mask,                      \
                                   __FILE__, __FUNCTION__, __LINE__,           \
                                   CDEBUG_STACK, format, ## a);                \
@@ -163,7 +156,6 @@ do {                                                                    \
 #define EXIT                            do { } while (0)
 #endif
 
-
 #ifdef __KERNEL__
 # include <linux/vmalloc.h>
 # include <linux/time.h>
@@ -569,7 +561,7 @@ int portals_debug_cleanup(void);
 int portals_debug_clear_buffer(void);
 int portals_debug_mark_buffer(char *text);
 int portals_debug_set_daemon(unsigned int cmd, unsigned int length,
-                char *file, unsigned int size);
+                             char *file, unsigned int size);
 __s32 portals_debug_copy_to_user(char *buf, unsigned long len);
 #if (__GNUC__)
 /* Use the special GNU C __attribute__ hack to have the compiler check the
@@ -585,9 +577,9 @@ void portals_debug_msg(int subsys, int mask, char *file, const char *fn,
                        const char *format, ...)
         __attribute__ ((format (printf, 7, 8)));
 #else
-void portals_debug_msg (int subsys, int mask, char *file, const char *fn,
-                        const int line, unsigned long stack,
-                        const char *format, ...);
+void portals_debug_msg(int subsys, int mask, char *file, const char *fn,
+                       const int line, unsigned long stack,
+                       const char *format, ...);
 #endif /* __GNUC__ */
 void portals_debug_set_level(unsigned int debug_level);
 
@@ -621,9 +613,9 @@ extern void kportal_blockallsigs (void);
 # define PORTAL_ALLOC(ptr, size) do { (ptr) = malloc(size); } while (0);
 # define PORTAL_FREE(a, b) do { free(a); } while (0);
 # define portals_debug_msg(subsys, mask, file, fn, line, stack, format, a...) \
-    printf ("%02x:%06x (@%lu %s:%s,l. %d %d %lu): " format,                    \
-            (subsys) >> 24, (mask), (long)time(0), file, fn, line,            \
-            getpid() , stack, ## a);
+    printf("%02x:%06x (@%lu %s:%s,l. %d %d %lu): " format,                    \
+           (subsys), (mask), (long)time(0), file, fn, line,                   \
+           getpid() , stack, ## a);
 #endif
 
 #ifndef CURRENT_TIME
@@ -914,13 +906,13 @@ ptl_handle_ni_t *kportal_get_ni (int nal);
 void kportal_put_ni (int nal);
 
 #ifdef __CYGWIN__
-#ifndef BITS_PER_LONG
-#if (~0UL) == 0xffffffffUL
-#define BITS_PER_LONG 32
-#else
-#define BITS_PER_LONG 64
-#endif
-#endif
+# ifndef BITS_PER_LONG
+#  if (~0UL) == 0xffffffffUL
+#   define BITS_PER_LONG 32
+#  else
+#   define BITS_PER_LONG 64
+#  endif
+# endif
 #endif
 
 #if (BITS_PER_LONG == 32 || __WORDSIZE == 32)
index aefe5b9..f37cd96 100644 (file)
@@ -728,8 +728,8 @@ portals_debug_msg(int subsys, int mask, char *file, const char *fn,
         do_gettimeofday(&tv);
 
         prefix_nob = snprintf(debug_buf + debug_off, max_nob,
-                              "%02x:%06x:%d:%lu.%06lu ",
-                              subsys >> 24, mask, smp_processor_id(),
+                              "%06x:%06x:%d:%lu.%06lu ",
+                              subsys, mask, smp_processor_id(),
                               tv.tv_sec, tv.tv_usec);
         max_nob -= prefix_nob;
 
@@ -752,7 +752,7 @@ portals_debug_msg(int subsys, int mask, char *file, const char *fn,
 
         va_start(ap, format);
         msg_nob += vsnprintf(debug_buf + debug_off + prefix_nob + msg_nob,
-                            max_nob, format, ap);
+                             max_nob, format, ap);
         max_nob -= msg_nob;
         va_end(ap);
 
index e59c922..dc1fead 100644 (file)
@@ -26,7 +26,7 @@
 #include <portals/api-support.h>
 
 int ptl_init;
-unsigned int portal_subsystem_debug = 0xfff7e3ff;
+unsigned int portal_subsystem_debug = ~0 - (S_PORTALS | S_QSWNAL | S_SOCKNAL | S_GMNAL);
 unsigned int portal_debug = ~0;
 unsigned int portal_printk;
 unsigned int portal_stack;
index 78271d5..fe7c242 100644 (file)
@@ -57,13 +57,14 @@ static int subsystem_array[1 << 8];
 static int debug_mask = ~0;
 
 static const char *portal_debug_subsystems[] =
-        {"undefined", "mdc", "mds", "osc", "ost", "class", "obdfs", "llite",
-         "rpc", "ext2obd", "portals", "socknal", "qswnal", "pinger", "filter",
-         "obdtrace", "echo", "ldlm", "lov", "gmnal", "router", "ptldb", NULL};
+        {"undefined", "mdc", "mds", "osc", "ost", "class", "log", "llite",
+         "rpc", "mgmt", "portals", "socknal", "qswnal", "pinger", "filter",
+         "ptlbd", "echo", "ldlm", "lov", "gmnal", "router", "cobd", NULL};
 static const char *portal_debug_masks[] =
         {"trace", "inode", "super", "ext2", "malloc", "cache", "info", "ioctl",
          "blocks", "net", "warning", "buffs", "other", "dentry", "portals",
-         "page", "dlmtrace", "error", "emerg", "ha", "rpctrace", "vfstrace", NULL};
+         "page", "dlmtrace", "error", "emerg", "ha", "rpctrace", "vfstrace",
+         NULL};
 
 struct debug_daemon_cmd {
         char *cmd;
@@ -230,7 +231,7 @@ static void dump_buffer(FILE *fd, char *buf, int size, int raw)
 {
         char *p, *z;
         unsigned long subsystem, debug, dropped = 0, kept = 0;
-        int max_sub, max_type;
+        int max_sub, max_type, warn = 0;
 
         for (max_sub = 0; portal_debug_subsystems[max_sub] != NULL; max_sub++)
                 ;
@@ -247,8 +248,13 @@ static void dump_buffer(FILE *fd, char *buf, int size, int raw)
                 z++;
                 /* for some reason %*s isn't working. */
                 *p = '\0';
-                if (subsystem < max_sub &&
-                    subsystem_array[subsystem] &&
+                if (subsystem >= max_sub && warn == 0) {
+                        fprintf(stderr, "warning: unrecognized debug subsystem "
+                                "%lx; did someone update kp30.h but not "
+                                "portals/utils/debug.c?\n", subsystem);
+                        warn = 1;
+                }
+                if ((subsystem >= max_sub || subsystem_array[subsystem]) &&
                     (!debug || (debug_mask & debug))) {
                         if (raw)
                                 fprintf(fd, "%s\n", buf);