Whamcloud - gitweb
LU-2675 cleanup: remove User Mode Linux specific code
[fs/lustre-release.git] / libcfs / include / libcfs / libcfs_debug.h
index 687755e..0e8aaa1 100644 (file)
@@ -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 Whamcloud, Inc.
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -106,7 +106,7 @@ struct ptldebug_header {
 #define S_LDLM        0x00010000
 #define S_LOV         0x00020000
 #define S_LQUOTA      0x00040000
-/* unused */
+#define S_OSD          0x00080000
 /* unused */
 /* unused */
 /* unused */
@@ -180,6 +180,16 @@ struct libcfs_debug_msg_data {
         cfs_debug_limit_state_t  *msg_cdls;
 };
 
+#define LIBCFS_DEBUG_MSG_DATA_INIT(data, mask, cdls)        \
+do {                                                        \
+        (data)->msg_subsys = DEBUG_SUBSYSTEM;               \
+        (data)->msg_file   = __FILE__;                      \
+        (data)->msg_fn     = __FUNCTION__;                  \
+        (data)->msg_line   = __LINE__;                      \
+        (data)->msg_cdls   = (cdls);                        \
+        (data)->msg_mask   = (mask);                        \
+} while (0)
+
 #define LIBCFS_DEBUG_MSG_DATA_DECL(dataname, mask, cdls)    \
         static struct libcfs_debug_msg_data dataname = {    \
                .msg_subsys = DEBUG_SUBSYSTEM,               \
@@ -204,12 +214,14 @@ static inline int cfs_cdebug_show(unsigned int mask, unsigned int subsystem)
 
 #define __CDEBUG(cdls, mask, format, ...)                               \
 do {                                                                    \
-        LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, mask, cdls);                \
+        static struct libcfs_debug_msg_data msgdata;                    \
                                                                         \
         CFS_CHECK_STACK(&msgdata, mask, cdls);                          \
                                                                         \
-        if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM))                     \
+        if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) {                   \
+                LIBCFS_DEBUG_MSG_DATA_INIT(&msgdata, mask, cdls);       \
                 libcfs_debug_msg(&msgdata, format, ## __VA_ARGS__);     \
+        }                                                               \
 } while (0)
 
 #define CDEBUG(mask, format, ...) __CDEBUG(NULL, mask, format, ## __VA_ARGS__)
@@ -288,17 +300,38 @@ do {                                                                    \
 #if defined(__GNUC__)
 
 long libcfs_log_return(struct libcfs_debug_msg_data *, long rc);
-#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,          \
-                                                     (long)(rc));       \
-        }                                                               \
-                                                                        \
-        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,         \
+                                                     (long)(rc));      \
+       }                                                               \
+                                                                       \
+       return (rc);                                                    \
 } while (0)
+#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)                                                     \
+do {                                                                   \
+       EXIT_NESTING;                                                   \
+       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);          \
+               return __rc;                                            \
+       }                                                               \
+                                                                       \
+       return (rc);                                                    \
+} while (0)
+#endif /* BITS_PER_LONG > 32 */
+
 #elif defined(_MSC_VER)
 #define RETURN(rc)                                                      \
 do {                                                                    \
@@ -350,11 +383,7 @@ extern int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob,
 extern int cfs_trace_copyout_string(char *usr_buffer, int usr_buffer_nob,
                                    const char *knl_buffer, char *append);
 
-#if defined(HAVE_BGL_SUPPORT)
-#define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/bgl/ion/tmp/lustre-log"
-#elif defined(__arch_um__)
-#define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/r/tmp/lustre-log"
-#elif defined(__WINNT__)
+#if defined(__WINNT__)
 #define LIBCFS_DEBUG_FILE_PATH_DEFAULT "\\SystemRoot\\temp\\lustre-log"
 #else
 #define LIBCFS_DEBUG_FILE_PATH_DEFAULT "/tmp/lustre-log"