X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libcfs%2Finclude%2Flibcfs%2Flibcfs_debug.h;h=f390367ff512904a490d302019efece2ff1c59bb;hb=d40b3f9663c7627f0f08c4e3b5efa6cd206ca0f0;hp=bf83c898d6c92d1aff008e3954533e0d8b8705d1;hpb=c64a87cede3b070573ed0062d98fc33be34111b8;p=fs%2Flustre-release.git diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index bf83c89..f390367 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/ @@ -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 { + cfs_time_t 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) \ @@ -207,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. @@ -220,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; \ \ @@ -232,41 +232,47 @@ 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, ...) \ -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 */ +# 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 +# define CDEBUG_LIMIT CDEBUG -#endif /* !__KERNEL__ ... */ +#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__) @@ -282,7 +288,7 @@ do { \ #define LCONSOLE_EMERG(format, ...) CDEBUG(D_CONSOLE | D_EMERG, format, ## __VA_ARGS__) -#ifdef CDEBUG_ENTRY_EXIT +#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); @@ -301,10 +307,9 @@ do { \ 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, \ @@ -313,15 +318,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); \ @@ -331,21 +335,13 @@ do { \ \ return (rc); \ } while (0) -#endif /* BITS_PER_LONG > 32 */ +# 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 GOTO(label, rc) \ do { \ @@ -353,11 +349,11 @@ do { \ goto label; \ } while (0) -#define RETURN(rc) return (rc) -#define ENTRY do { } while (0) -#define EXIT do { } while (0) +# define RETURN(rc) return (rc) +# define ENTRY do { } while (0) +# define EXIT do { } while (0) -#endif /* !CDEBUG_ENTRY_EXIT */ +#endif /* CDEBUG_ENTRY_EXIT && __KERNEL__ */ #define RETURN_EXIT \ do { \ @@ -374,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"