xref: /OK3568_Linux_fs/kernel/fs/jfs/jfs_debug.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  *   Copyright (C) International Business Machines Corp., 2000-2002
4*4882a593Smuzhiyun  *   Portions Copyright (C) Christoph Hellwig, 2001-2002
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun #ifndef _H_JFS_DEBUG
7*4882a593Smuzhiyun #define _H_JFS_DEBUG
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun /*
10*4882a593Smuzhiyun  *	jfs_debug.h
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  * global debug message, data structure/macro definitions
13*4882a593Smuzhiyun  * under control of CONFIG_JFS_DEBUG, CONFIG_JFS_STATISTICS;
14*4882a593Smuzhiyun  */
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun /*
17*4882a593Smuzhiyun  * Create /proc/fs/jfs if procfs is enabled andeither
18*4882a593Smuzhiyun  * CONFIG_JFS_DEBUG or CONFIG_JFS_STATISTICS is defined
19*4882a593Smuzhiyun  */
20*4882a593Smuzhiyun #if defined(CONFIG_PROC_FS) && (defined(CONFIG_JFS_DEBUG) || defined(CONFIG_JFS_STATISTICS))
21*4882a593Smuzhiyun #define PROC_FS_JFS
22*4882a593Smuzhiyun extern void jfs_proc_init(void);
23*4882a593Smuzhiyun extern void jfs_proc_clean(void);
24*4882a593Smuzhiyun #endif
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun /*
27*4882a593Smuzhiyun  *	assert with traditional printf/panic
28*4882a593Smuzhiyun  */
29*4882a593Smuzhiyun #define assert(p) do {	\
30*4882a593Smuzhiyun 	if (!(p)) {	\
31*4882a593Smuzhiyun 		printk(KERN_CRIT "BUG at %s:%d assert(%s)\n",	\
32*4882a593Smuzhiyun 		       __FILE__, __LINE__, #p);			\
33*4882a593Smuzhiyun 		BUG();	\
34*4882a593Smuzhiyun 	}		\
35*4882a593Smuzhiyun } while (0)
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun /*
38*4882a593Smuzhiyun  *	debug ON
39*4882a593Smuzhiyun  *	--------
40*4882a593Smuzhiyun  */
41*4882a593Smuzhiyun #ifdef CONFIG_JFS_DEBUG
42*4882a593Smuzhiyun #define ASSERT(p) assert(p)
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun /* printk verbosity */
45*4882a593Smuzhiyun #define JFS_LOGLEVEL_ERR 1
46*4882a593Smuzhiyun #define JFS_LOGLEVEL_WARN 2
47*4882a593Smuzhiyun #define JFS_LOGLEVEL_DEBUG 3
48*4882a593Smuzhiyun #define JFS_LOGLEVEL_INFO 4
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun extern int jfsloglevel;
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun int jfs_txanchor_proc_show(struct seq_file *m, void *v);
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun /* information message: e.g., configuration, major event */
55*4882a593Smuzhiyun #define jfs_info(fmt, arg...) do {			\
56*4882a593Smuzhiyun 	if (jfsloglevel >= JFS_LOGLEVEL_INFO)		\
57*4882a593Smuzhiyun 		printk(KERN_INFO fmt "\n", ## arg);	\
58*4882a593Smuzhiyun } while (0)
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun /* debug message: ad hoc */
61*4882a593Smuzhiyun #define jfs_debug(fmt, arg...) do {			\
62*4882a593Smuzhiyun 	if (jfsloglevel >= JFS_LOGLEVEL_DEBUG)		\
63*4882a593Smuzhiyun 		printk(KERN_DEBUG fmt "\n", ## arg);	\
64*4882a593Smuzhiyun } while (0)
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun /* warn message: */
67*4882a593Smuzhiyun #define jfs_warn(fmt, arg...) do {			\
68*4882a593Smuzhiyun 	if (jfsloglevel >= JFS_LOGLEVEL_WARN)		\
69*4882a593Smuzhiyun 		printk(KERN_WARNING fmt "\n", ## arg);	\
70*4882a593Smuzhiyun } while (0)
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun /* error event message: e.g., i/o error */
73*4882a593Smuzhiyun #define jfs_err(fmt, arg...) do {			\
74*4882a593Smuzhiyun 	if (jfsloglevel >= JFS_LOGLEVEL_ERR)		\
75*4882a593Smuzhiyun 		printk(KERN_ERR fmt "\n", ## arg);	\
76*4882a593Smuzhiyun } while (0)
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun /*
79*4882a593Smuzhiyun  *	debug OFF
80*4882a593Smuzhiyun  *	---------
81*4882a593Smuzhiyun  */
82*4882a593Smuzhiyun #else				/* CONFIG_JFS_DEBUG */
83*4882a593Smuzhiyun #define ASSERT(p) do {} while (0)
84*4882a593Smuzhiyun #define jfs_info(fmt, arg...) do {} while (0)
85*4882a593Smuzhiyun #define jfs_debug(fmt, arg...) do {} while (0)
86*4882a593Smuzhiyun #define jfs_warn(fmt, arg...) do {} while (0)
87*4882a593Smuzhiyun #define jfs_err(fmt, arg...) do {} while (0)
88*4882a593Smuzhiyun #endif				/* CONFIG_JFS_DEBUG */
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun /*
91*4882a593Smuzhiyun  *	statistics
92*4882a593Smuzhiyun  *	----------
93*4882a593Smuzhiyun  */
94*4882a593Smuzhiyun #ifdef	CONFIG_JFS_STATISTICS
95*4882a593Smuzhiyun int jfs_lmstats_proc_show(struct seq_file *m, void *v);
96*4882a593Smuzhiyun int jfs_txstats_proc_show(struct seq_file *m, void *v);
97*4882a593Smuzhiyun int jfs_mpstat_proc_show(struct seq_file *m, void *v);
98*4882a593Smuzhiyun int jfs_xtstat_proc_show(struct seq_file *m, void *v);
99*4882a593Smuzhiyun 
100*4882a593Smuzhiyun #define	INCREMENT(x)		((x)++)
101*4882a593Smuzhiyun #define	DECREMENT(x)		((x)--)
102*4882a593Smuzhiyun #define	HIGHWATERMARK(x,y)	((x) = max((x), (y)))
103*4882a593Smuzhiyun #else
104*4882a593Smuzhiyun #define	INCREMENT(x)
105*4882a593Smuzhiyun #define	DECREMENT(x)
106*4882a593Smuzhiyun #define	HIGHWATERMARK(x,y)
107*4882a593Smuzhiyun #endif				/* CONFIG_JFS_STATISTICS */
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun #endif				/* _H_JFS_DEBUG */
110