Whamcloud - gitweb
Use the newer libsysio tags.
[fs/lustre-release.git] / lustre / portals / include / linux / libcfs.h
index 17d5a11..d8f5349 100644 (file)
@@ -4,7 +4,11 @@
 #ifndef _LIBCFS_H
 #define _LIBCFS_H
 
+#ifdef HAVE_ASM_TYPES_H
 #include <asm/types.h>
+#else
+#include "types.h"
+#endif
 
 #ifdef __KERNEL__
 # include <linux/time.h>
@@ -62,7 +66,6 @@ extern unsigned int portal_stack;
 extern unsigned int portal_debug;
 extern unsigned int portal_printk;
 
-#include <asm/types.h>
 struct ptldebug_header {
         __u32 ph_len;
         __u32 ph_flags;
@@ -91,25 +94,24 @@ struct ptldebug_header {
 #define S_RPC         0x00000100
 #define S_MGMT        0x00000200
 #define S_PORTALS     0x00000400
-#define S_SOCKNAL     0x00000800
-#define S_QSWNAL      0x00001000
-#define S_PINGER      0x00002000
-#define S_FILTER      0x00004000
-#define S_PTLBD       0x00008000
-#define S_ECHO        0x00010000
-#define S_LDLM        0x00020000
-#define S_LOV         0x00040000
-#define S_GMNAL       0x00080000
-#define S_PTLROUTER   0x00100000
-#define S_COBD        0x00200000
-#define S_OPENIBNAL   0x00400000
-#define S_SM          0x00800000
-#define S_ASOBD       0x01000000
-#define S_LMV         0x02000000
-#define S_CMOBD       0x04000000
-
-/* If you change these values, please keep portals/utils/debug.c
- * up to date! */
+#define S_NAL         0x00000800 /* ALL NALs */
+#define S_PINGER      0x00001000
+#define S_FILTER      0x00002000
+#define S_PTLBD       0x00004000
+#define S_ECHO        0x00008000
+#define S_LDLM        0x00010000
+#define S_LOV         0x00020000
+#define S_PTLROUTER   0x00040000
+#define S_COBD        0x00080000
+#define S_SM          0x00100000
+#define S_ASOBD       0x00200000
+#define S_CONFOBD     0x00400000
+#define S_LMV         0x00800000
+#define S_CMOBD       0x01000000
+/* If you change these values, please keep these files up to date...
+ *    portals/utils/debug.c
+ *    utils/lconf
+ */
 
 /* Debugging masks (32 bits, non-overlapping) */
 #define D_TRACE       0x00000001 /* ENTRY/EXIT markers */
@@ -137,6 +139,11 @@ struct ptldebug_header {
 #define D_READA       0x00400000 /* read-ahead */
 #define D_MMAP        0x00800000
 #define D_CONFIG      0x01000000
+/* If you change these values, please keep these files up to date...
+ *    portals/utils/debug.c
+ *    utils/lconf
+ */
+
 #ifdef __KERNEL__
 # include <linux/sched.h> /* THREAD_SIZE */
 #else
@@ -145,13 +152,6 @@ struct ptldebug_header {
 # endif
 #endif
 
-#ifndef likely
-# define likely(exp) (exp)
-#endif
-#ifndef unlikely
-# define unlikely(exp) (exp)
-#endif
-
 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
 
 #ifdef __KERNEL__
@@ -192,8 +192,41 @@ do {                                                                          \
                                   CDEBUG_STACK, format, ## a);                \
 } while (0)
 
-#define CWARN(format, a...) CDEBUG(D_WARNING, format, ## a)
-#define CERROR(format, a...) CDEBUG(D_ERROR, format, ## a)
+#define CDEBUG_MAX_LIMIT 600
+#define CDEBUG_LIMIT(cdebug_mask, cdebug_format, a...)                        \
+do {                                                                          \
+        static unsigned long cdebug_next = 0;                                 \
+        static int cdebug_count = 0, cdebug_delay = 1;                        \
+                                                                              \
+        CHECK_STACK(CDEBUG_STACK);                                            \
+        if (time_after(jiffies, cdebug_next)) {                               \
+                portals_debug_msg(DEBUG_SUBSYSTEM, cdebug_mask, __FILE__,     \
+                                  __FUNCTION__, __LINE__, CDEBUG_STACK,       \
+                                  cdebug_format, ## a);                       \
+                if (cdebug_count) {                                           \
+                        portals_debug_msg(DEBUG_SUBSYSTEM, cdebug_mask,       \
+                                          __FILE__, __FUNCTION__, __LINE__,   \
+                                          0, "skipped %d similar messages\n", \
+                                          cdebug_count);                      \
+                        cdebug_count = 0;                                     \
+                }                                                             \
+                if (time_after(jiffies, cdebug_next+(CDEBUG_MAX_LIMIT+10)*HZ))\
+                        cdebug_delay = cdebug_delay > 8 ? cdebug_delay/8 : 1; \
+                else                                                          \
+                        cdebug_delay = cdebug_delay*2 >= CDEBUG_MAX_LIMIT*HZ ?\
+                                        CDEBUG_MAX_LIMIT*HZ : cdebug_delay*2; \
+                cdebug_next = jiffies + cdebug_delay;                         \
+        } else {                                                              \
+                portals_debug_msg(DEBUG_SUBSYSTEM,                            \
+                                  portal_debug & ~(D_EMERG|D_ERROR|D_WARNING),\
+                                  __FILE__, __FUNCTION__, __LINE__,           \
+                                  CDEBUG_STACK, cdebug_format, ## a);         \
+                cdebug_count++;                                               \
+        }                                                                     \
+} while (0)
+
+#define CWARN(format, a...) CDEBUG_LIMIT(D_WARNING, format, ## a)
+#define CERROR(format, a...) CDEBUG_LIMIT(D_ERROR, format, ## a)
 #define CEMERG(format, a...) CDEBUG(D_EMERG, format, ## a)
 
 #define GOTO(label, rc)                                                 \
@@ -236,14 +269,13 @@ do {                                                                    \
 /* initial pid  */
 # if CRAY_PORTALS
 /* 
+ * 1) ptl_pid_t in cray portals is only 16 bits, not 32 bits, therefore this
+ *    is too big.
  *
- * 1) ptl_pid_t in cray portals is only 16 bits, not 32 bits, therefore this is too
- * big.
- *
- * 2) the implementation of ernal in cray portals further restricts the pid space
- * that may be used to 0 <= pid <= 255 (an 8 bit value).  Returns an error at nal
- * init time for any pid outside this range.  Other nals in cray portals don't have
- * this restriction.
+ * 2) the implementation of ernal in cray portals further restricts the pid
+ *    space that may be used to 0 <= pid <= 255 (an 8 bit value).  Returns
+ *    an error at nal init time for any pid outside this range.  Other nals
+ *    in cray portals don't have this restriction.
  * */
 #define LUSTRE_PTL_PID          9
 # else
@@ -345,6 +377,34 @@ int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
 
 #endif
 
-#define _LIBCFS_H
+#ifdef __KERNEL__
+/* libcfs watchdogs */
+struct lc_watchdog;
+
+/* Just use the default handler (dumplog)  */
+#define LC_WATCHDOG_DEFAULT_CB NULL
+
+/* Add a watchdog which fires after "time" milliseconds of delay.  You have to
+ * touch it once to enable it. */
+struct lc_watchdog *lc_watchdog_add(int time, 
+                                    void (*cb)(struct lc_watchdog *,
+                                               struct task_struct *,
+                                               void *),
+                                    void *data);
+
+/* Enables a watchdog and resets its timer. */
+void lc_watchdog_touch(struct lc_watchdog *lcw);
+
+/* Disable a watchdog; touch it to restart it. */
+void lc_watchdog_disable(struct lc_watchdog *lcw);
+
+/* Clean up the watchdog */
+void lc_watchdog_delete(struct lc_watchdog *lcw);
+
+/* Dump a debug log */
+void lc_watchdog_dumplog(struct lc_watchdog *lcw,
+                         struct task_struct *tsk,
+                         void *data);
+#endif /* !__KERNEL__ */
 
 #endif /* _LIBCFS_H */