blob: ddffbbd4d95585940c4101655120b2d0072897a0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Dave Kleikamp1868f4a2005-05-04 15:29:35 -05002 * Copyright (C) International Business Machines Corp., 2000-2002
3 * Portions Copyright (C) Christoph Hellwig, 2001-2002
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _H_JFS_DEBUG
20#define _H_JFS_DEBUG
21
22/*
23 * jfs_debug.h
24 *
25 * global debug message, data structure/macro definitions
26 * under control of CONFIG_JFS_DEBUG, CONFIG_JFS_STATISTICS;
27 */
28
29/*
30 * Create /proc/fs/jfs if procfs is enabled andeither
31 * CONFIG_JFS_DEBUG or CONFIG_JFS_STATISTICS is defined
32 */
33#if defined(CONFIG_PROC_FS) && (defined(CONFIG_JFS_DEBUG) || defined(CONFIG_JFS_STATISTICS))
Dave Kleikamp1868f4a2005-05-04 15:29:35 -050034#define PROC_FS_JFS
35extern void jfs_proc_init(void);
36extern void jfs_proc_clean(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#endif
38
39/*
40 * assert with traditional printf/panic
41 */
42#ifdef CONFIG_KERNEL_ASSERTS
43/* kgdb stuff */
44#define assert(p) KERNEL_ASSERT(#p, p)
45#else
46#define assert(p) do { \
47 if (!(p)) { \
48 printk(KERN_CRIT "BUG at %s:%d assert(%s)\n", \
49 __FILE__, __LINE__, #p); \
50 BUG(); \
51 } \
52} while (0)
53#endif
54
55/*
56 * debug ON
57 * --------
58 */
59#ifdef CONFIG_JFS_DEBUG
60#define ASSERT(p) assert(p)
61
62/* printk verbosity */
63#define JFS_LOGLEVEL_ERR 1
64#define JFS_LOGLEVEL_WARN 2
65#define JFS_LOGLEVEL_DEBUG 3
66#define JFS_LOGLEVEL_INFO 4
67
68extern int jfsloglevel;
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070extern void dump_mem(char *label, void *data, int length);
Dave Kleikamp1868f4a2005-05-04 15:29:35 -050071extern int jfs_txanchor_read(char *, char **, off_t, int, int *, void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73/* information message: e.g., configuration, major event */
74#define jfs_info(fmt, arg...) do { \
75 if (jfsloglevel >= JFS_LOGLEVEL_INFO) \
76 printk(KERN_INFO fmt "\n", ## arg); \
77} while (0)
78
79/* debug message: ad hoc */
80#define jfs_debug(fmt, arg...) do { \
81 if (jfsloglevel >= JFS_LOGLEVEL_DEBUG) \
82 printk(KERN_DEBUG fmt "\n", ## arg); \
83} while (0)
84
85/* warn message: */
86#define jfs_warn(fmt, arg...) do { \
87 if (jfsloglevel >= JFS_LOGLEVEL_WARN) \
88 printk(KERN_WARNING fmt "\n", ## arg); \
89} while (0)
90
91/* error event message: e.g., i/o error */
92#define jfs_err(fmt, arg...) do { \
93 if (jfsloglevel >= JFS_LOGLEVEL_ERR) \
94 printk(KERN_ERR fmt "\n", ## arg); \
95} while (0)
96
97/*
98 * debug OFF
99 * ---------
100 */
101#else /* CONFIG_JFS_DEBUG */
102#define dump_mem(label,data,length) do {} while (0)
103#define ASSERT(p) do {} while (0)
104#define jfs_info(fmt, arg...) do {} while (0)
105#define jfs_debug(fmt, arg...) do {} while (0)
106#define jfs_warn(fmt, arg...) do {} while (0)
107#define jfs_err(fmt, arg...) do {} while (0)
108#endif /* CONFIG_JFS_DEBUG */
109
110/*
111 * statistics
112 * ----------
113 */
114#ifdef CONFIG_JFS_STATISTICS
Dave Kleikamp1868f4a2005-05-04 15:29:35 -0500115extern int jfs_lmstats_read(char *, char **, off_t, int, int *, void *);
116extern int jfs_txstats_read(char *, char **, off_t, int, int *, void *);
117extern int jfs_mpstat_read(char *, char **, off_t, int, int *, void *);
118extern int jfs_xtstat_read(char *, char **, off_t, int, int *, void *);
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120#define INCREMENT(x) ((x)++)
121#define DECREMENT(x) ((x)--)
122#define HIGHWATERMARK(x,y) ((x) = max((x), (y)))
123#else
124#define INCREMENT(x)
125#define DECREMENT(x)
126#define HIGHWATERMARK(x,y)
127#endif /* CONFIG_JFS_STATISTICS */
128
129#endif /* _H_JFS_DEBUG */