X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libcfs%2Finclude%2Flibcfs%2Flibcfs_debug.h;h=85cfea37a413c6ed0de932fe2b8868cbecef6a44;hb=0d7a6d1d8df4756aa791f3574dc36ed01c4bbf36;hp=a87894b80c2e5891e2224bf2f3291a2175796b2c;hpb=2f41b688058532248e69ff0194c27616f4dfb6d5;p=fs%2Flustre-release.git diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index a87894b..85cfea3 100644 --- a/libcfs/include/libcfs/libcfs_debug.h +++ b/libcfs/include/libcfs/libcfs_debug.h @@ -27,7 +27,7 @@ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, 2013, Intel Corporation. + * Copyright (c) 2012, 2014, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -86,75 +86,83 @@ struct ptldebug_header { #define PH_FLAG_FIRST_RECORD 1 /* Debugging subsystems (32 bits, non-overlapping) */ -/* keep these in sync with lnet/utils/debug.c and lnet/libcfs/debug.c */ -#define S_UNDEFINED 0x00000001 -#define S_MDC 0x00000002 -#define S_MDS 0x00000004 -#define S_OSC 0x00000008 -#define S_OST 0x00000010 -#define S_CLASS 0x00000020 -#define S_LOG 0x00000040 -#define S_LLITE 0x00000080 -#define S_RPC 0x00000100 -#define S_MGMT 0x00000200 -#define S_LNET 0x00000400 -#define S_LND 0x00000800 /* ALL LNDs */ -#define S_PINGER 0x00001000 -#define S_FILTER 0x00002000 +#define S_UNDEFINED 0x00000001 +#define S_MDC 0x00000002 +#define S_MDS 0x00000004 +#define S_OSC 0x00000008 +#define S_OST 0x00000010 +#define S_CLASS 0x00000020 +#define S_LOG 0x00000040 +#define S_LLITE 0x00000080 +#define S_RPC 0x00000100 +#define S_MGMT 0x00000200 +#define S_LNET 0x00000400 +#define S_LND 0x00000800 /* ALL LNDs */ +#define S_PINGER 0x00001000 +#define S_FILTER 0x00002000 /* unused */ -#define S_ECHO 0x00008000 -#define S_LDLM 0x00010000 -#define S_LOV 0x00020000 -#define S_LQUOTA 0x00040000 +#define S_ECHO 0x00008000 +#define S_LDLM 0x00010000 +#define S_LOV 0x00020000 +#define S_LQUOTA 0x00040000 #define S_OSD 0x00080000 -#define S_LFSCK 0x00100000 +#define S_LFSCK 0x00100000 /* unused */ /* unused */ -#define S_LMV 0x00800000 /* b_new_cmd */ +#define S_LMV 0x00800000 /* b_new_cmd */ /* unused */ -#define S_SEC 0x02000000 /* upcall cache */ -#define S_GSS 0x04000000 /* b_new_cmd */ +#define S_SEC 0x02000000 /* upcall cache */ +#define S_GSS 0x04000000 /* b_new_cmd */ /* unused */ -#define S_MGC 0x10000000 -#define S_MGS 0x20000000 -#define S_FID 0x40000000 /* b_new_cmd */ -#define S_FLD 0x80000000 /* b_new_cmd */ -/* keep these in sync with lnet/utils/debug.c and lnet/libcfs/debug.c */ +#define S_MGC 0x10000000 +#define S_MGS 0x20000000 +#define S_FID 0x40000000 /* b_new_cmd */ +#define S_FLD 0x80000000 /* b_new_cmd */ + +#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 } /* Debugging masks (32 bits, non-overlapping) */ -/* keep these in sync with lnet/utils/debug.c and lnet/libcfs/debug.c */ -#define D_TRACE 0x00000001 /* ENTRY/EXIT markers */ -#define D_INODE 0x00000002 -#define D_SUPER 0x00000004 -#define D_EXT2 0x00000008 /* anything from ext2_debug */ -#define D_MALLOC 0x00000010 /* print malloc, free information */ -#define D_CACHE 0x00000020 /* cache-related items */ -#define D_INFO 0x00000040 /* general information */ -#define D_IOCTL 0x00000080 /* ioctl related information */ -#define D_NETERROR 0x00000100 /* network errors */ -#define D_NET 0x00000200 /* network communications */ -#define D_WARNING 0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */ -#define D_BUFFS 0x00000800 -#define D_OTHER 0x00001000 -#define D_DENTRY 0x00002000 -#define D_NETTRACE 0x00004000 -#define D_PAGE 0x00008000 /* bulk page handling */ -#define D_DLMTRACE 0x00010000 -#define D_ERROR 0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */ -#define D_EMERG 0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */ -#define D_HA 0x00080000 /* recovery and failover */ -#define D_RPCTRACE 0x00100000 /* for distributed debugging */ -#define D_VFSTRACE 0x00200000 -#define D_READA 0x00400000 /* read-ahead */ -#define D_MMAP 0x00800000 -#define D_CONFIG 0x01000000 -#define D_CONSOLE 0x02000000 -#define D_QUOTA 0x04000000 -#define D_SEC 0x08000000 -#define D_LFSCK 0x10000000 /* For both OI scrub and LFSCK */ -/* keep these in sync with lnet/{utils,libcfs}/debug.c */ - -#define D_HSM D_TRACE +#define D_TRACE 0x00000001 /* ENTRY/EXIT markers */ +#define D_INODE 0x00000002 +#define D_SUPER 0x00000004 +#define D_EXT2 0x00000008 /* anything from ext2_debug */ +#define D_MALLOC 0x00000010 /* print malloc, free information */ +#define D_CACHE 0x00000020 /* cache-related items */ +#define D_INFO 0x00000040 /* general information */ +#define D_IOCTL 0x00000080 /* ioctl related information */ +#define D_NETERROR 0x00000100 /* network errors */ +#define D_NET 0x00000200 /* network communications */ +#define D_WARNING 0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */ +#define D_BUFFS 0x00000800 +#define D_OTHER 0x00001000 +#define D_DENTRY 0x00002000 +#define D_NETTRACE 0x00004000 +#define D_PAGE 0x00008000 /* bulk page handling */ +#define D_DLMTRACE 0x00010000 +#define D_ERROR 0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */ +#define D_EMERG 0x00040000 /* CEMERG(...) == CDEBUG (D_EMERG, ...) */ +#define D_HA 0x00080000 /* recovery and failover */ +#define D_RPCTRACE 0x00100000 /* for distributed debugging */ +#define D_VFSTRACE 0x00200000 +#define D_READA 0x00400000 /* read-ahead */ +#define D_MMAP 0x00800000 +#define D_CONFIG 0x01000000 +#define D_CONSOLE 0x02000000 +#define D_QUOTA 0x04000000 +#define D_SEC 0x08000000 +#define D_LFSCK 0x10000000 /* For both OI scrub and LFSCK */ +#define D_HSM 0x20000000 + +#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 } #define D_CANTMASK (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE) @@ -199,9 +207,9 @@ do { \ .msg_cdls = (cdls) }; \ dataname.msg_mask = (mask); -#if defined(__KERNEL__) || (defined(__arch_lib__) && !defined(LUSTRE_UTILS)) +#ifdef __KERNEL__ -#ifdef CDEBUG_ENABLED +# ifdef CDEBUG_ENABLED /** * Filters out logging messages based on mask and subsystem. @@ -212,7 +220,7 @@ static inline int cfs_cdebug_show(unsigned int mask, unsigned int subsystem) ((libcfs_debug & mask) && (libcfs_subsystem_debug & subsystem)); } -#define __CDEBUG(cdls, mask, format, ...) \ +# define __CDEBUG(cdls, mask, format, ...) \ do { \ static struct libcfs_debug_msg_data msgdata; \ \ @@ -224,41 +232,40 @@ do { \ } \ } while (0) -#define CDEBUG(mask, format, ...) __CDEBUG(NULL, mask, format, ## __VA_ARGS__) +# define CDEBUG(mask, format, ...) __CDEBUG(NULL, mask, format, ## __VA_ARGS__) -#define CDEBUG_LIMIT(mask, format, ...) \ +# define CDEBUG_LIMIT(mask, format, ...) \ do { \ static cfs_debug_limit_state_t cdls; \ \ __CDEBUG(&cdls, mask, format, ## __VA_ARGS__);\ } while (0) -#else /* !CDEBUG_ENABLED */ +# else /* !CDEBUG_ENABLED */ static inline int cfs_cdebug_show(unsigned int mask, unsigned int subsystem) { return 0; } -#define CDEBUG(mask, format, ...) (void)(0) -#define CDEBUG_LIMIT(mask, format, ...) (void)(0) -#warning "CDEBUG IS DISABLED. THIS SHOULD NEVER BE DONE FOR PRODUCTION!" -#endif +# define CDEBUG(mask, format, ...) (void)(0) +# define CDEBUG_LIMIT(mask, format, ...) (void)(0) +# warning "CDEBUG IS DISABLED. THIS SHOULD NEVER BE DONE FOR PRODUCTION!" +# endif /* CDEBUG_ENABLED */ -#else /* !__KERNEL__ && (!__arch_lib__ || LUSTRE_UTILS) */ +#else /* !__KERNEL__ */ static inline int cfs_cdebug_show(unsigned int mask, unsigned int subsystem) { return 0; } -#define CDEBUG(mask, format, ...) \ +# define CDEBUG(mask, format, ...) \ do { \ if (((mask) & D_CANTMASK) != 0) \ fprintf(stderr, "(%s:%d:%s()) " format, \ __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__);\ } while (0) -#define CDEBUG_LIMIT CDEBUG - -#endif /* !__KERNEL__ ... */ +# define CDEBUG_LIMIT CDEBUG +#endif /* __KERNEL__ */ #define CWARN(format, ...) CDEBUG_LIMIT(D_WARNING, format, ## __VA_ARGS__) #define CERROR(format, ...) CDEBUG_LIMIT(D_ERROR, format, ## __VA_ARGS__) @@ -274,36 +281,28 @@ do { \ #define LCONSOLE_EMERG(format, ...) CDEBUG(D_CONSOLE | D_EMERG, format, ## __VA_ARGS__) -#ifdef CDEBUG_ENABLED +#if defined(CDEBUG_ENTRY_EXIT) && defined(__KERNEL__) -void libcfs_log_goto(struct libcfs_debug_msg_data *, const char *, long_ptr_t); -#define GOTO(label, rc) \ -do { \ - if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ - LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ - libcfs_log_goto(&msgdata, #label, (long_ptr_t)(rc)); \ - } else { \ - (void)(rc); \ - } \ - goto label; \ -} while (0) -#else -#define GOTO(label, rc) do { ((void)(rc)); goto label; } while (0) -#endif +void libcfs_log_goto(struct libcfs_debug_msg_data *goto_data, + const char *label, long_ptr_t rc); -#ifdef CDEBUG_ENTRY_EXIT +# 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)); \ + } else { \ + (void)(rc); \ + } \ + \ + goto label; \ +} while (0) -/* - * if rc == NULL, we need to code as RETURN((void *)NULL), otherwise - * there will be a warning in osx. - */ -#if defined(__GNUC__) long libcfs_log_return(struct libcfs_debug_msg_data *, long rc); -#if BITS_PER_LONG > 32 -#define RETURN(rc) \ +# if BITS_PER_LONG > 32 +# define RETURN(rc) \ do { \ - EXIT_NESTING; \ if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ return (typeof(rc))libcfs_log_return(&msgdata, \ @@ -312,15 +311,14 @@ do { \ \ return (rc); \ } while (0) -#else /* BITS_PER_LONG == 32 */ +# else /* BITS_PER_LONG == 32 */ /* We need an on-stack variable, because we cannot case a 32-bit pointer * directly to (long long) without generating a complier warning/error, yet * casting directly to (long) will truncate 64-bit return values. The log * values will print as 32-bit values, but they always have been. LU-1436 */ -#define RETURN(rc) \ +# define RETURN(rc) \ do { \ - EXIT_NESTING; \ if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ typeof(rc) __rc = (rc); \ LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ @@ -330,37 +328,25 @@ do { \ \ return (rc); \ } while (0) -#endif /* BITS_PER_LONG > 32 */ -#elif defined(_MSC_VER) -#define RETURN(rc) \ -do { \ - CDEBUG(D_TRACE, "Process leaving.\n"); \ - EXIT_NESTING; \ - return (rc); \ -} while (0) -#else -# error "Unkown compiler" -#endif /* __GNUC__ */ +# endif /* BITS_PER_LONG > 32 */ -#define ENTRY \ -ENTRY_NESTING; \ -do { \ - CDEBUG(D_TRACE, "Process entered\n"); \ -} while (0) +# define ENTRY CDEBUG(D_TRACE, "Process entered\n") +# define EXIT CDEBUG(D_TRACE, "Process leaving\n") -#define EXIT \ -do { \ - CDEBUG(D_TRACE, "Process leaving\n"); \ - EXIT_NESTING; \ -} while(0) -#else /* !CDEBUG_ENTRY_EXIT */ +#else /* !CDEBUG_ENTRY_EXIT || !__KERNEL__ */ -#define RETURN(rc) return (rc) -#define ENTRY do { } while (0) -#define EXIT do { } while (0) +# define GOTO(label, rc) \ + do { \ + ((void)(rc)); \ + goto label; \ + } while (0) -#endif /* !CDEBUG_ENTRY_EXIT */ +# define RETURN(rc) return (rc) +# define ENTRY do { } while (0) +# define EXIT do { } while (0) + +#endif /* CDEBUG_ENTRY_EXIT && __KERNEL__ */ #define RETURN_EXIT \ do { \ @@ -379,14 +365,11 @@ extern int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, /* other external symbols that tracefile provides: */ extern int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, - const char *usr_buffer, int usr_buffer_nob); -extern int cfs_trace_copyout_string(char *usr_buffer, int usr_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); -#if defined(__WINNT__) -#define LIBCFS_DEBUG_FILE_PATH_DEFAULT "\\SystemRoot\\temp\\lustre-log" -#else #define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/tmp/lustre-log" -#endif #endif /* __LIBCFS_DEBUG_H__ */