1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
10 # define offsetof(typ,memb) ((int)((char *)&(((typ *)0)->memb)))
13 #define LOWEST_BIT_SET(x) ((x) & ~((x) - 1))
18 extern unsigned int portal_subsystem_debug;
19 extern unsigned int portal_stack;
20 extern unsigned int portal_debug;
21 extern unsigned int portal_printk;
22 extern unsigned int portal_cerror;
23 /* Debugging subsystems (32 bits, non-overlapping) */
24 #define S_UNDEFINED 0x00000001
25 #define S_MDC 0x00000002
26 #define S_MDS 0x00000004
27 #define S_OSC 0x00000008
28 #define S_OST 0x00000010
29 #define S_CLASS 0x00000020
30 #define S_LOG 0x00000040
31 #define S_LLITE 0x00000080
32 #define S_RPC 0x00000100
33 #define S_MGMT 0x00000200
34 #define S_PORTALS 0x00000400
35 #define S_SOCKNAL 0x00000800
36 #define S_QSWNAL 0x00001000
37 #define S_PINGER 0x00002000
38 #define S_FILTER 0x00004000
39 #define S_PTLBD 0x00008000
40 #define S_ECHO 0x00010000
41 #define S_LDLM 0x00020000
42 #define S_LOV 0x00040000
43 #define S_GMNAL 0x00080000
44 #define S_PTLROUTER 0x00100000
45 #define S_COBD 0x00200000
46 #define S_IBNAL 0x00400000
47 #define S_LMV 0x00800000
49 /* If you change these values, please keep portals/utils/debug.c
52 /* Debugging masks (32 bits, non-overlapping) */
53 #define D_TRACE 0x00000001 /* ENTRY/EXIT markers */
54 #define D_INODE 0x00000002
55 #define D_SUPER 0x00000004
56 #define D_EXT2 0x00000008 /* anything from ext2_debug */
57 #define D_MALLOC 0x00000010 /* print malloc, free information */
58 #define D_CACHE 0x00000020 /* cache-related items */
59 #define D_INFO 0x00000040 /* general information */
60 #define D_IOCTL 0x00000080 /* ioctl related information */
61 #define D_BLOCKS 0x00000100 /* ext2 block allocation */
62 #define D_NET 0x00000200 /* network communications */
63 #define D_WARNING 0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */
64 #define D_BUFFS 0x00000800
65 #define D_OTHER 0x00001000
66 #define D_DENTRY 0x00002000
67 #define D_PORTALS 0x00004000 /* ENTRY/EXIT markers */
68 #define D_PAGE 0x00008000 /* bulk page handling */
69 #define D_DLMTRACE 0x00010000
70 #define D_ERROR 0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */
71 #define D_EMERG 0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */
72 #define D_HA 0x00080000 /* recovery and failover */
73 #define D_RPCTRACE 0x00100000 /* for distributed debugging */
74 #define D_VFSTRACE 0x00200000
75 #define D_READA 0x00400000 /* read-ahead */
78 # include <linux/sched.h> /* THREAD_SIZE */
80 # ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */
81 # define THREAD_SIZE 8192
85 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
89 # define CDEBUG_STACK (THREAD_SIZE - \
90 ((unsigned long)__builtin_dwarf_cfa() & \
93 # define CDEBUG_STACK (THREAD_SIZE - \
94 ((unsigned long)__builtin_frame_address(0) & \
98 #define CHECK_STACK(stack) \
100 if ((stack) > 3*THREAD_SIZE/4 && (stack) > portal_stack) { \
101 portals_debug_msg(DEBUG_SUBSYSTEM, D_WARNING, \
102 __FILE__, __FUNCTION__, __LINE__, \
103 (stack),"maximum lustre stack %u\n",\
104 portal_stack = (stack)); \
108 #else /* __KERNEL__ */
109 #define CHECK_STACK(stack) do { } while(0)
110 #define CDEBUG_STACK (0L)
111 #endif /* __KERNEL__ */
114 #define CDEBUG(mask, format, a...) \
116 if (portal_cerror == 0) \
118 CHECK_STACK(CDEBUG_STACK); \
119 if (((mask) & (D_ERROR | D_EMERG | D_WARNING)) || \
120 (portal_debug & (mask) && \
121 portal_subsystem_debug & DEBUG_SUBSYSTEM)) \
122 portals_debug_msg(DEBUG_SUBSYSTEM, mask, \
123 __FILE__, __FUNCTION__, __LINE__, \
124 CDEBUG_STACK, format, ## a); \
127 #define CWARN(format, a...) CDEBUG(D_WARNING, format, ## a)
128 #define CERROR(format, a...) CDEBUG(D_ERROR, format, ## a)
129 #define CEMERG(format, a...) CDEBUG(D_EMERG, format, ## a)
131 #define GOTO(label, rc) \
133 long GOTO__ret = (long)(rc); \
134 CDEBUG(D_TRACE,"Process leaving via %s (rc=%lu : %ld : %lx)\n", \
135 #label, (unsigned long)GOTO__ret, (signed long)GOTO__ret,\
136 (signed long)GOTO__ret); \
142 typeof(rc) RETURN__ret = (rc); \
143 CDEBUG(D_TRACE, "Process leaving (rc=%lu : %ld : %lx)\n", \
144 (long)RETURN__ret, (long)RETURN__ret, (long)RETURN__ret);\
145 return RETURN__ret; \
150 CDEBUG(D_TRACE, "Process entered\n"); \
155 CDEBUG(D_TRACE, "Process leaving\n"); \
158 #define CDEBUG(mask, format, a...) do { } while (0)
159 #define CWARN(format, a...) do { } while (0)
160 #define CERROR(format, a...) printk("<3>" format, ## a)
161 #define CEMERG(format, a...) printk("<0>" format, ## a)
162 #define GOTO(label, rc) do { (void)(rc); goto label; } while (0)
163 #define RETURN(rc) return (rc)
164 #define ENTRY do { } while (0)
165 #define EXIT do { } while (0)
168 struct portal_ioctl_data {
192 __u32 ioc_plen1; /* buffers in userspace */
194 __u32 ioc_plen2; /* buffers in userspace */
202 #include <linux/list.h>
204 struct libcfs_ioctl_handler {
205 struct list_head item;
206 int (*handle_ioctl)(struct portal_ioctl_data *data,
207 unsigned int cmd, unsigned long args);
210 #define DECLARE_IOCTL_HANDLER(ident, func) \
211 struct libcfs_ioctl_handler ident = { \
212 .item = LIST_HEAD_INIT(ident.item), \
213 .handle_ioctl = func \
216 int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
217 int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
223 #endif /* _LIBCFS_H */