18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) International Business Machines Corp., 2000-2002 48c2ecf20Sopenharmony_ci * Portions Copyright (C) Christoph Hellwig, 2001-2002 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef _H_JFS_DEBUG 78c2ecf20Sopenharmony_ci#define _H_JFS_DEBUG 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci/* 108c2ecf20Sopenharmony_ci * jfs_debug.h 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * global debug message, data structure/macro definitions 138c2ecf20Sopenharmony_ci * under control of CONFIG_JFS_DEBUG, CONFIG_JFS_STATISTICS; 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* 178c2ecf20Sopenharmony_ci * Create /proc/fs/jfs if procfs is enabled andeither 188c2ecf20Sopenharmony_ci * CONFIG_JFS_DEBUG or CONFIG_JFS_STATISTICS is defined 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci#if defined(CONFIG_PROC_FS) && (defined(CONFIG_JFS_DEBUG) || defined(CONFIG_JFS_STATISTICS)) 218c2ecf20Sopenharmony_ci#define PROC_FS_JFS 228c2ecf20Sopenharmony_ciextern void jfs_proc_init(void); 238c2ecf20Sopenharmony_ciextern void jfs_proc_clean(void); 248c2ecf20Sopenharmony_ci#endif 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* 278c2ecf20Sopenharmony_ci * assert with traditional printf/panic 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_ci#define assert(p) do { \ 308c2ecf20Sopenharmony_ci if (!(p)) { \ 318c2ecf20Sopenharmony_ci printk(KERN_CRIT "BUG at %s:%d assert(%s)\n", \ 328c2ecf20Sopenharmony_ci __FILE__, __LINE__, #p); \ 338c2ecf20Sopenharmony_ci BUG(); \ 348c2ecf20Sopenharmony_ci } \ 358c2ecf20Sopenharmony_ci} while (0) 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* 388c2ecf20Sopenharmony_ci * debug ON 398c2ecf20Sopenharmony_ci * -------- 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_ci#ifdef CONFIG_JFS_DEBUG 428c2ecf20Sopenharmony_ci#define ASSERT(p) assert(p) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* printk verbosity */ 458c2ecf20Sopenharmony_ci#define JFS_LOGLEVEL_ERR 1 468c2ecf20Sopenharmony_ci#define JFS_LOGLEVEL_WARN 2 478c2ecf20Sopenharmony_ci#define JFS_LOGLEVEL_DEBUG 3 488c2ecf20Sopenharmony_ci#define JFS_LOGLEVEL_INFO 4 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ciextern int jfsloglevel; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciint jfs_txanchor_proc_show(struct seq_file *m, void *v); 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* information message: e.g., configuration, major event */ 558c2ecf20Sopenharmony_ci#define jfs_info(fmt, arg...) do { \ 568c2ecf20Sopenharmony_ci if (jfsloglevel >= JFS_LOGLEVEL_INFO) \ 578c2ecf20Sopenharmony_ci printk(KERN_INFO fmt "\n", ## arg); \ 588c2ecf20Sopenharmony_ci} while (0) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/* debug message: ad hoc */ 618c2ecf20Sopenharmony_ci#define jfs_debug(fmt, arg...) do { \ 628c2ecf20Sopenharmony_ci if (jfsloglevel >= JFS_LOGLEVEL_DEBUG) \ 638c2ecf20Sopenharmony_ci printk(KERN_DEBUG fmt "\n", ## arg); \ 648c2ecf20Sopenharmony_ci} while (0) 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* warn message: */ 678c2ecf20Sopenharmony_ci#define jfs_warn(fmt, arg...) do { \ 688c2ecf20Sopenharmony_ci if (jfsloglevel >= JFS_LOGLEVEL_WARN) \ 698c2ecf20Sopenharmony_ci printk(KERN_WARNING fmt "\n", ## arg); \ 708c2ecf20Sopenharmony_ci} while (0) 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci/* error event message: e.g., i/o error */ 738c2ecf20Sopenharmony_ci#define jfs_err(fmt, arg...) do { \ 748c2ecf20Sopenharmony_ci if (jfsloglevel >= JFS_LOGLEVEL_ERR) \ 758c2ecf20Sopenharmony_ci printk(KERN_ERR fmt "\n", ## arg); \ 768c2ecf20Sopenharmony_ci} while (0) 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* 798c2ecf20Sopenharmony_ci * debug OFF 808c2ecf20Sopenharmony_ci * --------- 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_ci#else /* CONFIG_JFS_DEBUG */ 838c2ecf20Sopenharmony_ci#define ASSERT(p) do {} while (0) 848c2ecf20Sopenharmony_ci#define jfs_info(fmt, arg...) do {} while (0) 858c2ecf20Sopenharmony_ci#define jfs_debug(fmt, arg...) do {} while (0) 868c2ecf20Sopenharmony_ci#define jfs_warn(fmt, arg...) do {} while (0) 878c2ecf20Sopenharmony_ci#define jfs_err(fmt, arg...) do {} while (0) 888c2ecf20Sopenharmony_ci#endif /* CONFIG_JFS_DEBUG */ 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/* 918c2ecf20Sopenharmony_ci * statistics 928c2ecf20Sopenharmony_ci * ---------- 938c2ecf20Sopenharmony_ci */ 948c2ecf20Sopenharmony_ci#ifdef CONFIG_JFS_STATISTICS 958c2ecf20Sopenharmony_ciint jfs_lmstats_proc_show(struct seq_file *m, void *v); 968c2ecf20Sopenharmony_ciint jfs_txstats_proc_show(struct seq_file *m, void *v); 978c2ecf20Sopenharmony_ciint jfs_mpstat_proc_show(struct seq_file *m, void *v); 988c2ecf20Sopenharmony_ciint jfs_xtstat_proc_show(struct seq_file *m, void *v); 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#define INCREMENT(x) ((x)++) 1018c2ecf20Sopenharmony_ci#define DECREMENT(x) ((x)--) 1028c2ecf20Sopenharmony_ci#define HIGHWATERMARK(x,y) ((x) = max((x), (y))) 1038c2ecf20Sopenharmony_ci#else 1048c2ecf20Sopenharmony_ci#define INCREMENT(x) 1058c2ecf20Sopenharmony_ci#define DECREMENT(x) 1068c2ecf20Sopenharmony_ci#define HIGHWATERMARK(x,y) 1078c2ecf20Sopenharmony_ci#endif /* CONFIG_JFS_STATISTICS */ 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#endif /* _H_JFS_DEBUG */ 110