Whamcloud - gitweb
LU-9119 lnet: remove debug ioctl
[fs/lustre-release.git] / libcfs / include / libcfs / libcfs_debug.h
index 85cfea3..2eb6b7a 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * 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
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -74,6 +70,7 @@ struct ptldebug_header {
         __u32 ph_mask;
         __u16 ph_cpu_id;
         __u16 ph_type;
+       /* time_t overflow in 2106 */
         __u32 ph_sec;
         __u64 ph_usec;
         __u32 ph_stack;
@@ -107,7 +104,7 @@ struct ptldebug_header {
 #define S_LQUOTA       0x00040000
 #define S_OSD          0x00080000
 #define S_LFSCK                0x00100000
-/* unused */
+#define S_SNAPSHOT     0x00200000
 /* unused */
 #define S_LMV          0x00800000 /* b_new_cmd */
 /* unused */
@@ -122,8 +119,8 @@ struct ptldebug_header {
 #define LIBCFS_DEBUG_SUBSYS_NAMES {                                    \
        "undefined", "mdc", "mds", "osc", "ost", "class", "log",        \
        "llite", "rpc", "mgmt", "lnet", "lnd", "pinger", "filter", "",  \
-       "echo", "ldlm", "lov", "lquota", "osd", "lfsck", "", "", "lmv", \
-        "", "sec", "gss", "", "mgc", "mgs", "fid", "fld", NULL }
+       "echo", "ldlm", "lov", "lquota", "osd", "lfsck", "snapshot", "",\
+       "lmv",  "", "sec", "gss", "", "mgc", "mgs", "fid", "fld", NULL }
 
 /* Debugging masks (32 bits, non-overlapping) */
 #define D_TRACE                0x00000001 /* ENTRY/EXIT markers */
@@ -156,13 +153,16 @@ struct ptldebug_header {
 #define D_SEC          0x08000000
 #define D_LFSCK                0x10000000 /* For both OI scrub and LFSCK */
 #define D_HSM          0x20000000
+#define D_SNAPSHOT     0x40000000 /* snapshot */
+#define D_LAYOUT       0x80000000
 
 #define LIBCFS_DEBUG_MASKS_NAMES {                                     \
        "trace", "inode", "super", "ext2", "malloc", "cache", "info",   \
        "ioctl", "neterror", "net", "warning", "buffs", "other",        \
        "dentry", "nettrace", "page", "dlmtrace", "error", "emerg",     \
        "ha", "rpctrace", "vfstrace", "reada", "mmap", "config",        \
-       "console", "quota", "sec", "lfsck", "hsm", NULL }
+       "console", "quota", "sec", "lfsck", "hsm", "snapshot", "layout",\
+       NULL }
 
 #define D_CANTMASK   (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)
 
@@ -173,19 +173,19 @@ struct ptldebug_header {
 #define CDEBUG_DEFAULT_MAX_DELAY (cfs_time_seconds(600))         /* jiffies */
 #define CDEBUG_DEFAULT_MIN_DELAY ((cfs_time_seconds(1) + 1) / 2) /* jiffies */
 #define CDEBUG_DEFAULT_BACKOFF   2
-typedef struct {
-        cfs_time_t      cdls_next;
-        unsigned int    cdls_delay;
-        int             cdls_count;
-} cfs_debug_limit_state_t;
+struct cfs_debug_limit_state {
+       unsigned long   cdls_next;
+       unsigned int    cdls_delay;
+       int             cdls_count;
+};
 
 struct libcfs_debug_msg_data {
-        const char               *msg_file;
-        const char               *msg_fn;
-        int                      msg_subsys;
-        int                      msg_line;
-        int                      msg_mask;
-        cfs_debug_limit_state_t  *msg_cdls;
+       const char                      *msg_file;
+       const char                      *msg_fn;
+       int                              msg_subsys;
+       int                              msg_line;
+       int                              msg_mask;
+       struct cfs_debug_limit_state    *msg_cdls;
 };
 
 #define LIBCFS_DEBUG_MSG_DATA_INIT(data, mask, cdls)        \
@@ -234,11 +234,11 @@ do {                                                                    \
 
 #  define CDEBUG(mask, format, ...) __CDEBUG(NULL, mask, format, ## __VA_ARGS__)
 
-#  define CDEBUG_LIMIT(mask, format, ...)      \
-do {                                            \
-        static cfs_debug_limit_state_t cdls;    \
-                                                \
-        __CDEBUG(&cdls, mask, format, ## __VA_ARGS__);\
+#  define CDEBUG_LIMIT(mask, format, ...)                              \
+do {                                                                   \
+       static struct cfs_debug_limit_state cdls;                       \
+                                                                       \
+       __CDEBUG(&cdls, mask, format, ## __VA_ARGS__);                  \
 } while (0)
 
 # else /* !CDEBUG_ENABLED */
@@ -267,6 +267,13 @@ do {                                                                    \
 
 #endif /* __KERNEL__ */
 
+/*
+ * Lustre Error Checksum: calculates checksum
+ * of Hex number by XORing each bit.
+ */
+#define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \
+                          ((hexnum) >> 8 & 0xf))
+
 #define CWARN(format, ...)          CDEBUG_LIMIT(D_WARNING, format, ## __VA_ARGS__)
 #define CERROR(format, ...)         CDEBUG_LIMIT(D_ERROR, format, ## __VA_ARGS__)
 #define CNETERR(format, a...)       CDEBUG_LIMIT(D_NETERROR, format, ## a)
@@ -284,13 +291,13 @@ do {                                                                    \
 #if defined(CDEBUG_ENTRY_EXIT) && defined(__KERNEL__)
 
 void libcfs_log_goto(struct libcfs_debug_msg_data *goto_data,
-                    const char *label, long_ptr_t rc);
+                    const char *label, long rc);
 
 # define GOTO(label, rc)                                               \
 do {                                                                   \
        if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) {                \
                LIBCFS_DEBUG_MSG_DATA_DECL(_goto_data, D_TRACE, NULL);  \
-               libcfs_log_goto(&_goto_data, #label, (long_ptr_t)(rc)); \
+               libcfs_log_goto(&_goto_data, #label, (long)(rc));       \
        } else {                                                        \
                (void)(rc);                                             \
        }                                                               \
@@ -322,7 +329,7 @@ do {                                                                        \
        if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) {                \
                typeof(rc) __rc = (rc);                                 \
                LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL);     \
-               libcfs_log_return(&msgdata, (long_ptr_t)__rc);          \
+               libcfs_log_return(&msgdata, (long)__rc);                \
                return __rc;                                            \
        }                                                               \
                                                                        \
@@ -363,12 +370,14 @@ extern int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
                               va_list args, const char *format2, ...)
         __attribute__ ((format (printf, 4, 5)));
 
+#ifdef __KERNEL__
 /* other external symbols that tracefile provides: */
 extern int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob,
                                   const char __user *usr_buffer,
                                   int usr_buffer_nob);
 extern int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob,
                                    const char *knl_buffer, char *append);
+#endif /* __KERNEL__ */
 
 #define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/tmp/lustre-log"