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