]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - fs/aufs/debug.h
2 * Copyright (C) 2005-2016 Junjiro R. Okajima
4 * This program, aufs is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * debug print functions
22 #ifndef __AUFS_DEBUG_H__
23 #define __AUFS_DEBUG_H__
27 #include <linux/atomic.h>
28 #include <linux/module.h>
29 #include <linux/kallsyms.h>
30 #include <linux/sysrq.h>
32 #ifdef CONFIG_AUFS_DEBUG
33 #define AuDebugOn(a) BUG_ON(a)
35 /* module parameter */
36 extern atomic_t aufs_debug
;
37 static inline void au_debug_on(void)
39 atomic_inc(&aufs_debug
);
41 static inline void au_debug_off(void)
43 atomic_dec_if_positive(&aufs_debug
);
46 static inline int au_debug_test(void)
48 return atomic_read(&aufs_debug
) > 0;
51 #define AuDebugOn(a) do {} while (0)
52 AuStubVoid(au_debug_on
, void)
53 AuStubVoid(au_debug_off
, void)
54 AuStubInt0(au_debug_test
, void)
55 #endif /* CONFIG_AUFS_DEBUG */
57 #define param_check_atomic_t(name, p) __param_check(name, p, atomic_t)
59 /* ---------------------------------------------------------------------- */
63 #define AuDbg(fmt, ...) do { \
64 if (au_debug_test()) \
65 pr_debug("DEBUG: " fmt, ##__VA_ARGS__); \
67 #define AuLabel(l) AuDbg(#l "\n")
68 #define AuIOErr(fmt, ...) pr_err("I/O Error, " fmt, ##__VA_ARGS__)
69 #define AuWarn1(fmt, ...) do { \
70 static unsigned char _c; \
72 pr_warn(fmt, ##__VA_ARGS__); \
75 #define AuErr1(fmt, ...) do { \
76 static unsigned char _c; \
78 pr_err(fmt, ##__VA_ARGS__); \
81 #define AuIOErr1(fmt, ...) do { \
82 static unsigned char _c; \
84 AuIOErr(fmt, ##__VA_ARGS__); \
87 #define AuUnsupportMsg "This operation is not supported." \
88 " Please report this application to aufs-users ML."
89 #define AuUnsupport(fmt, ...) do { \
90 pr_err(AuUnsupportMsg "\n" fmt, ##__VA_ARGS__); \
94 #define AuTraceErr(e) do { \
95 if (unlikely((e) < 0)) \
96 AuDbg("err %d\n", (int)(e)); \
99 #define AuTraceErrPtr(p) do { \
101 AuDbg("err %ld\n", PTR_ERR(p)); \
104 /* dirty macros for debug print, use with "%.*s" and caution */
105 #define AuLNPair(qstr) (qstr)->len, (qstr)->name
107 /* ---------------------------------------------------------------------- */
110 #ifdef CONFIG_AUFS_DEBUG
111 extern struct mutex au_dbg_mtx
;
112 extern char *au_plevel
;
114 void au_dpri_whlist(struct au_nhash
*whlist
);
116 void au_dpri_vdir(struct au_vdir
*vdir
);
118 void au_dpri_inode(struct inode
*inode
);
119 void au_dpri_dalias(struct inode
*inode
);
120 void au_dpri_dentry(struct dentry
*dentry
);
122 void au_dpri_file(struct file
*filp
);
124 void au_dpri_sb(struct super_block
*sb
);
126 #define au_dbg_verify_dinode(d) __au_dbg_verify_dinode(d, __func__, __LINE__)
127 void __au_dbg_verify_dinode(struct dentry
*dentry
, const char *func
, int line
);
128 void au_dbg_verify_gen(struct dentry
*parent
, unsigned int sigen
);
129 void au_dbg_verify_kthread(void);
131 int __init
au_debug_init(void);
133 #define AuDbgWhlist(w) do { \
134 mutex_lock(&au_dbg_mtx); \
137 mutex_unlock(&au_dbg_mtx); \
140 #define AuDbgVdir(v) do { \
141 mutex_lock(&au_dbg_mtx); \
144 mutex_unlock(&au_dbg_mtx); \
147 #define AuDbgInode(i) do { \
148 mutex_lock(&au_dbg_mtx); \
151 mutex_unlock(&au_dbg_mtx); \
154 #define AuDbgDAlias(i) do { \
155 mutex_lock(&au_dbg_mtx); \
158 mutex_unlock(&au_dbg_mtx); \
161 #define AuDbgDentry(d) do { \
162 mutex_lock(&au_dbg_mtx); \
165 mutex_unlock(&au_dbg_mtx); \
168 #define AuDbgFile(f) do { \
169 mutex_lock(&au_dbg_mtx); \
172 mutex_unlock(&au_dbg_mtx); \
175 #define AuDbgSb(sb) do { \
176 mutex_lock(&au_dbg_mtx); \
179 mutex_unlock(&au_dbg_mtx); \
182 #define AuDbgSym(addr) do { \
183 char sym[KSYM_SYMBOL_LEN]; \
184 sprint_symbol(sym, (unsigned long)addr); \
185 AuDbg("%s\n", sym); \
188 AuStubVoid(au_dbg_verify_dinode
, struct dentry
*dentry
)
189 AuStubVoid(au_dbg_verify_gen
, struct dentry
*parent
, unsigned int sigen
)
190 AuStubVoid(au_dbg_verify_kthread
, void)
191 AuStubInt0(__init au_debug_init
, void)
193 #define AuDbgWhlist(w) do {} while (0)
194 #define AuDbgVdir(v) do {} while (0)
195 #define AuDbgInode(i) do {} while (0)
196 #define AuDbgDAlias(i) do {} while (0)
197 #define AuDbgDentry(d) do {} while (0)
198 #define AuDbgFile(f) do {} while (0)
199 #define AuDbgSb(sb) do {} while (0)
200 #define AuDbgSym(addr) do {} while (0)
201 #endif /* CONFIG_AUFS_DEBUG */
203 /* ---------------------------------------------------------------------- */
205 #ifdef CONFIG_AUFS_MAGIC_SYSRQ
206 int __init
au_sysrq_init(void);
207 void au_sysrq_fin(void);
209 #ifdef CONFIG_HW_CONSOLE
210 #define au_dbg_blocked() do { \
215 AuStubVoid(au_dbg_blocked
, void)
219 AuStubInt0(__init au_sysrq_init
, void)
220 AuStubVoid(au_sysrq_fin
, void)
221 AuStubVoid(au_dbg_blocked
, void)
222 #endif /* CONFIG_AUFS_MAGIC_SYSRQ */
224 #endif /* __KERNEL__ */
225 #endif /* __AUFS_DEBUG_H__ */