162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) International Business Machines Corp., 2000-2002 462306a36Sopenharmony_ci * Portions Copyright (C) Christoph Hellwig, 2001-2002 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef _H_JFS_DEBUG 762306a36Sopenharmony_ci#define _H_JFS_DEBUG 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* 1062306a36Sopenharmony_ci * jfs_debug.h 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * global debug message, data structure/macro definitions 1362306a36Sopenharmony_ci * under control of CONFIG_JFS_DEBUG, CONFIG_JFS_STATISTICS; 1462306a36Sopenharmony_ci */ 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* 1762306a36Sopenharmony_ci * Create /proc/fs/jfs if procfs is enabled andeither 1862306a36Sopenharmony_ci * CONFIG_JFS_DEBUG or CONFIG_JFS_STATISTICS is defined 1962306a36Sopenharmony_ci */ 2062306a36Sopenharmony_ci#if defined(CONFIG_PROC_FS) && (defined(CONFIG_JFS_DEBUG) || defined(CONFIG_JFS_STATISTICS)) 2162306a36Sopenharmony_ci#define PROC_FS_JFS 2262306a36Sopenharmony_ciextern void jfs_proc_init(void); 2362306a36Sopenharmony_ciextern void jfs_proc_clean(void); 2462306a36Sopenharmony_ci#endif 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* 2762306a36Sopenharmony_ci * assert with traditional printf/panic 2862306a36Sopenharmony_ci */ 2962306a36Sopenharmony_ci#define assert(p) do { \ 3062306a36Sopenharmony_ci if (!(p)) { \ 3162306a36Sopenharmony_ci printk(KERN_CRIT "BUG at %s:%d assert(%s)\n", \ 3262306a36Sopenharmony_ci __FILE__, __LINE__, #p); \ 3362306a36Sopenharmony_ci BUG(); \ 3462306a36Sopenharmony_ci } \ 3562306a36Sopenharmony_ci} while (0) 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci/* 3862306a36Sopenharmony_ci * debug ON 3962306a36Sopenharmony_ci * -------- 4062306a36Sopenharmony_ci */ 4162306a36Sopenharmony_ci#ifdef CONFIG_JFS_DEBUG 4262306a36Sopenharmony_ci#define ASSERT(p) assert(p) 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci/* printk verbosity */ 4562306a36Sopenharmony_ci#define JFS_LOGLEVEL_ERR 1 4662306a36Sopenharmony_ci#define JFS_LOGLEVEL_WARN 2 4762306a36Sopenharmony_ci#define JFS_LOGLEVEL_DEBUG 3 4862306a36Sopenharmony_ci#define JFS_LOGLEVEL_INFO 4 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ciextern int jfsloglevel; 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ciint jfs_txanchor_proc_show(struct seq_file *m, void *v); 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci/* information message: e.g., configuration, major event */ 5562306a36Sopenharmony_ci#define jfs_info(fmt, arg...) do { \ 5662306a36Sopenharmony_ci if (jfsloglevel >= JFS_LOGLEVEL_INFO) \ 5762306a36Sopenharmony_ci printk(KERN_INFO fmt "\n", ## arg); \ 5862306a36Sopenharmony_ci} while (0) 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci/* debug message: ad hoc */ 6162306a36Sopenharmony_ci#define jfs_debug(fmt, arg...) do { \ 6262306a36Sopenharmony_ci if (jfsloglevel >= JFS_LOGLEVEL_DEBUG) \ 6362306a36Sopenharmony_ci printk(KERN_DEBUG fmt "\n", ## arg); \ 6462306a36Sopenharmony_ci} while (0) 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci/* warn message: */ 6762306a36Sopenharmony_ci#define jfs_warn(fmt, arg...) do { \ 6862306a36Sopenharmony_ci if (jfsloglevel >= JFS_LOGLEVEL_WARN) \ 6962306a36Sopenharmony_ci printk(KERN_WARNING fmt "\n", ## arg); \ 7062306a36Sopenharmony_ci} while (0) 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* error event message: e.g., i/o error */ 7362306a36Sopenharmony_ci#define jfs_err(fmt, arg...) do { \ 7462306a36Sopenharmony_ci if (jfsloglevel >= JFS_LOGLEVEL_ERR) \ 7562306a36Sopenharmony_ci printk(KERN_ERR fmt "\n", ## arg); \ 7662306a36Sopenharmony_ci} while (0) 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci/* 7962306a36Sopenharmony_ci * debug OFF 8062306a36Sopenharmony_ci * --------- 8162306a36Sopenharmony_ci */ 8262306a36Sopenharmony_ci#else /* CONFIG_JFS_DEBUG */ 8362306a36Sopenharmony_ci#define ASSERT(p) do {} while (0) 8462306a36Sopenharmony_ci#define jfs_info(fmt, arg...) do {} while (0) 8562306a36Sopenharmony_ci#define jfs_debug(fmt, arg...) do {} while (0) 8662306a36Sopenharmony_ci#define jfs_warn(fmt, arg...) do {} while (0) 8762306a36Sopenharmony_ci#define jfs_err(fmt, arg...) do {} while (0) 8862306a36Sopenharmony_ci#endif /* CONFIG_JFS_DEBUG */ 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci/* 9162306a36Sopenharmony_ci * statistics 9262306a36Sopenharmony_ci * ---------- 9362306a36Sopenharmony_ci */ 9462306a36Sopenharmony_ci#ifdef CONFIG_JFS_STATISTICS 9562306a36Sopenharmony_ciint jfs_lmstats_proc_show(struct seq_file *m, void *v); 9662306a36Sopenharmony_ciint jfs_txstats_proc_show(struct seq_file *m, void *v); 9762306a36Sopenharmony_ciint jfs_mpstat_proc_show(struct seq_file *m, void *v); 9862306a36Sopenharmony_ciint jfs_xtstat_proc_show(struct seq_file *m, void *v); 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#define INCREMENT(x) ((x)++) 10162306a36Sopenharmony_ci#define DECREMENT(x) ((x)--) 10262306a36Sopenharmony_ci#define HIGHWATERMARK(x,y) ((x) = max((x), (y))) 10362306a36Sopenharmony_ci#else 10462306a36Sopenharmony_ci#define INCREMENT(x) 10562306a36Sopenharmony_ci#define DECREMENT(x) 10662306a36Sopenharmony_ci#define HIGHWATERMARK(x,y) 10762306a36Sopenharmony_ci#endif /* CONFIG_JFS_STATISTICS */ 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#endif /* _H_JFS_DEBUG */ 110