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