]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - fs/aufs/debug.h
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2005-2021 Junjiro R. Okajima
5 * This program, aufs 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.
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 the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * debug print functions
23 #ifndef __AUFS_DEBUG_H__
24 #define __AUFS_DEBUG_H__
28 #include <linux/atomic.h>
29 #include <linux/module.h>
30 #include <linux/kallsyms.h>
31 #include <linux/sysrq.h>
33 #ifdef CONFIG_AUFS_DEBUG
34 #define AuDebugOn(a) BUG_ON(a)
36 /* module parameter */
37 extern atomic_t aufs_debug
;
38 static inline void au_debug_on(void)
40 atomic_inc(&aufs_debug
);
42 static inline void au_debug_off(void)
44 atomic_dec_if_positive(&aufs_debug
);
47 static inline int au_debug_test(void)
49 return atomic_read(&aufs_debug
) > 0;
52 #define AuDebugOn(a) do {} while (0)
53 AuStubVoid(au_debug_on
, void)
54 AuStubVoid(au_debug_off
, void)
55 AuStubInt0(au_debug_test
, void)
56 #endif /* CONFIG_AUFS_DEBUG */
58 #define param_check_atomic_t(name, p) __param_check(name, p, atomic_t)
60 /* ---------------------------------------------------------------------- */
64 #define AuDbg(fmt, ...) do { \
65 if (au_debug_test()) \
66 pr_debug("DEBUG: " fmt, ##__VA_ARGS__); \
68 #define AuLabel(l) AuDbg(#l "\n")
69 #define AuIOErr(fmt, ...) pr_err("I/O Error, " fmt, ##__VA_ARGS__)
70 #define AuWarn1(fmt, ...) do { \
71 static unsigned char _c; \
73 pr_warn(fmt, ##__VA_ARGS__); \
76 #define AuErr1(fmt, ...) do { \
77 static unsigned char _c; \
79 pr_err(fmt, ##__VA_ARGS__); \
82 #define AuIOErr1(fmt, ...) do { \
83 static unsigned char _c; \
85 AuIOErr(fmt, ##__VA_ARGS__); \
88 #define AuUnsupportMsg "This operation is not supported." \
89 " Please report this application to aufs-users ML."
90 #define AuUnsupport(fmt, ...) do { \
91 pr_err(AuUnsupportMsg "\n" fmt, ##__VA_ARGS__); \
95 #define AuTraceErr(e) do { \
96 if (unlikely((e) < 0)) \
97 AuDbg("err %d\n", (int)(e)); \
100 #define AuTraceErrPtr(p) do { \
102 AuDbg("err %ld\n", PTR_ERR(p)); \
105 /* dirty macros for debug print, use with "%.*s" and caution */
106 #define AuLNPair(qstr) (qstr)->len, (qstr)->name
108 /* ---------------------------------------------------------------------- */
111 #ifdef CONFIG_AUFS_DEBUG
112 extern struct mutex au_dbg_mtx
;
113 extern char *au_plevel
;
115 void au_dpri_whlist(struct au_nhash
*whlist
);
117 void au_dpri_vdir(struct au_vdir
*vdir
);
119 void au_dpri_inode(struct inode
*inode
);
120 void au_dpri_dalias(struct inode
*inode
);
121 void au_dpri_dentry(struct dentry
*dentry
);
123 void au_dpri_file(struct file
*filp
);
125 void au_dpri_sb(struct super_block
*sb
);
127 #define au_dbg_verify_dinode(d) __au_dbg_verify_dinode(d, __func__, __LINE__)
128 void __au_dbg_verify_dinode(struct dentry
*dentry
, const char *func
, int line
);
129 void au_dbg_verify_gen(struct dentry
*parent
, unsigned int sigen
);
130 void au_dbg_verify_kthread(void);
132 int __init
au_debug_init(void);
134 #define AuDbgWhlist(w) do { \
135 mutex_lock(&au_dbg_mtx); \
138 mutex_unlock(&au_dbg_mtx); \
141 #define AuDbgVdir(v) do { \
142 mutex_lock(&au_dbg_mtx); \
145 mutex_unlock(&au_dbg_mtx); \
148 #define AuDbgInode(i) do { \
149 mutex_lock(&au_dbg_mtx); \
152 mutex_unlock(&au_dbg_mtx); \
155 #define AuDbgDAlias(i) do { \
156 mutex_lock(&au_dbg_mtx); \
159 mutex_unlock(&au_dbg_mtx); \
162 #define AuDbgDentry(d) do { \
163 mutex_lock(&au_dbg_mtx); \
166 mutex_unlock(&au_dbg_mtx); \
169 #define AuDbgFile(f) do { \
170 mutex_lock(&au_dbg_mtx); \
173 mutex_unlock(&au_dbg_mtx); \
176 #define AuDbgSb(sb) do { \
177 mutex_lock(&au_dbg_mtx); \
180 mutex_unlock(&au_dbg_mtx); \
183 #define AuDbgSym(addr) do { \
184 char sym[KSYM_SYMBOL_LEN]; \
185 sprint_symbol(sym, (unsigned long)addr); \
186 AuDbg("%s\n", sym); \
189 AuStubVoid(au_dbg_verify_dinode
, struct dentry
*dentry
)
190 AuStubVoid(au_dbg_verify_gen
, struct dentry
*parent
, unsigned int sigen
)
191 AuStubVoid(au_dbg_verify_kthread
, void)
192 AuStubInt0(__init au_debug_init
, void)
194 #define AuDbgWhlist(w) do {} while (0)
195 #define AuDbgVdir(v) do {} while (0)
196 #define AuDbgInode(i) do {} while (0)
197 #define AuDbgDAlias(i) do {} while (0)
198 #define AuDbgDentry(d) do {} while (0)
199 #define AuDbgFile(f) do {} while (0)
200 #define AuDbgSb(sb) do {} while (0)
201 #define AuDbgSym(addr) do {} while (0)
202 #endif /* CONFIG_AUFS_DEBUG */
204 /* ---------------------------------------------------------------------- */
206 #ifdef CONFIG_AUFS_MAGIC_SYSRQ
207 int __init
au_sysrq_init(void);
208 void au_sysrq_fin(void);
210 #ifdef CONFIG_HW_CONSOLE
211 #define au_dbg_blocked() do { \
216 AuStubVoid(au_dbg_blocked
, void)
220 AuStubInt0(__init au_sysrq_init
, void)
221 AuStubVoid(au_sysrq_fin
, void)
222 AuStubVoid(au_dbg_blocked
, void)
223 #endif /* CONFIG_AUFS_MAGIC_SYSRQ */
225 #endif /* __KERNEL__ */
226 #endif /* __AUFS_DEBUG_H__ */