lkml.org 
[lkml]   [2021]   [Jan]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH v2 2/4] jbd2: introduce some new log interfaces
Date
From: Chunguang Xu <brookxu@tencent.com>

Compared to directly using numbers to indicate levels, using abstract
error, warn, notice, info, debug to indicate levels may be more
convenient for code reading and writing. Similar to other kernel
modules, some basic log interfaces are introduced.

Signed-off-by: Chunguang Xu <brookxu@tencent.com>
---
include/linux/jbd2.h | 59 +++++++++++++++++++++++++++++++-------------
1 file changed, 42 insertions(+), 17 deletions(-)

diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 600a2ea8324a..b33bb5681cae 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -47,23 +47,6 @@
*/
#define JBD2_DEFAULT_MAX_COMMIT_AGE 5

-#ifdef CONFIG_JBD2_DEBUG
-/*
- * Define JBD2_EXPENSIVE_CHECKING to enable more expensive internal
- * consistency checks. By default we don't do this unless
- * CONFIG_JBD2_DEBUG is on.
- */
-#define JBD2_EXPENSIVE_CHECKING
-extern ushort jbd2_journal_enable_debug;
-void __jbd2_debug(int level, const char *file, const char *func,
- unsigned int line, const char *fmt, ...);
-
-#define jbd_debug(n, fmt, a...) \
- __jbd2_debug((n), __FILE__, __func__, __LINE__, (fmt), ##a)
-#else
-#define jbd_debug(n, fmt, a...) /**/
-#endif
-
extern void *jbd2_alloc(size_t size, gfp_t flags);
extern void jbd2_free(void *ptr, size_t size);

@@ -104,6 +87,48 @@ typedef struct jbd2_journal_handle handle_t; /* Atomic operation type */
* This is an opaque datatype.
**/
typedef struct journal_s journal_t; /* Journal control structure */
+
+#ifdef CONFIG_JBD2_DEBUG
+/*
+ * Define JBD2_EXPENSIVE_CHECKING to enable more expensive internal
+ * consistency checks. By default we don't do this unless
+ * CONFIG_JBD2_DEBUG is on.
+ */
+#define JBD2_EXPENSIVE_CHECKING
+extern ushort jbd2_journal_enable_debug;
+void jbd2_log(int level, journal_t *j, const char *file, const char *func,
+ unsigned int line, const char *fmt, ...);
+
+#define JBD2_ERR 1 /* error conditions */
+#define JBD2_WARN 2 /* warning conditions */
+#define JBD2_NOTICE 3 /* normal but significant condition */
+#define JBD2_INFO 4 /* informational */
+#define JBD2_DEBUG 5 /* debug-level messages */
+
+#define jbd2_err(j, fmt, a...) \
+ jbd2_log(JBD2_ERR, j, __FILE__, __func__, __LINE__, (fmt), ##a)
+
+#define jbd2_warn(j, fmt, a...) \
+ jbd2_log(JBD2_WARN, j, __FILE__, __func__, __LINE__, (fmt), ##a)
+
+#define jbd2_notice(j, fmt, a...) \
+ jbd2_log(JBD2_NOTICE, j, __FILE__, __func__, __LINE__, (fmt), ##a)
+
+#define jbd2_info(j, fmt, a...) \
+ jbd2_log(JBD2_INFO, j, __FILE__, __func__, __LINE__, (fmt), ##a)
+
+#define jbd2_debug(j, fmt, a...) \
+ jbd2_log(JBD2_DEBUG, j, __FILE__, __func__, __LINE__, (fmt), ##a)
+
+#else
+
+#define jbd2_err(j, fmt, a...)
+#define jbd2_warn(j, fmt, a...)
+#define jbd2_notice(j, fmt, a...)
+#define jbd2_info(j, fmt, a...)
+#define jbd2_debug(j, fmt, a...)
+
+#endif
#endif

/*
--
2.30.0
\
 
 \ /
  Last update: 2021-01-23 13:03    [W:0.147 / U:1.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site