2 * Copyright (C) 2005-2011 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, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * debug print functions
23 #ifndef __AUFS_DEBUG_H__
24 #define __AUFS_DEBUG_H__
28 #include <asm/system.h>
29 #include <linux/bug.h>
30 /* #include <linux/err.h> */
31 #include <linux/init.h>
32 #include <linux/module.h>
33 #include <linux/kallsyms.h>
34 /* #include <linux/kernel.h> */
35 #include <linux/delay.h>
36 /* #include <linux/kd.h> */
37 #include <linux/sysrq.h>
38 #include <linux/aufs_type.h>
40 #ifdef CONFIG_AUFS_DEBUG
41 #define AuDebugOn(a) BUG_ON(a)
43 /* module parameter */
44 extern int aufs_debug
;
45 static inline void au_debug(int n
)
51 static inline int au_debug_test(void)
56 #define AuDebugOn(a) do {} while (0)
57 AuStubVoid(au_debug
, int n
)
58 AuStubInt0(au_debug_test
, void)
59 #endif /* CONFIG_AUFS_DEBUG */
61 /* ---------------------------------------------------------------------- */
65 #define AuDbg(fmt, ...) do { \
66 if (au_debug_test()) \
67 pr_debug("DEBUG: " fmt, ##__VA_ARGS__); \
69 #define AuLabel(l) AuDbg(#l "\n")
70 #define AuIOErr(fmt, ...) pr_err("I/O Error, " fmt, ##__VA_ARGS__)
71 #define AuWarn1(fmt, ...) do { \
72 static unsigned char _c; \
74 pr_warning(fmt, ##__VA_ARGS__); \
77 #define AuErr1(fmt, ...) do { \
78 static unsigned char _c; \
80 pr_err(fmt, ##__VA_ARGS__); \
83 #define AuIOErr1(fmt, ...) do { \
84 static unsigned char _c; \
86 AuIOErr(fmt, ##__VA_ARGS__); \
89 #define AuUnsupportMsg "This operation is not supported." \
90 " Please report this application to aufs-users ML."
91 #define AuUnsupport(fmt, ...) do { \
92 pr_err(AuUnsupportMsg "\n" fmt, ##__VA_ARGS__); \
96 #define AuTraceErr(e) do { \
97 if (unlikely((e) < 0)) \
98 AuDbg("err %d\n", (int)(e)); \
101 #define AuTraceErrPtr(p) do { \
103 AuDbg("err %ld\n", PTR_ERR(p)); \
106 /* dirty macros for debug print, use with "%.*s" and caution */
107 #define AuLNPair(qstr) (qstr)->len, (qstr)->name
108 #define AuDLNPair(d) AuLNPair(&(d)->d_name)
110 /* ---------------------------------------------------------------------- */
115 #ifdef CONFIG_AUFS_DEBUG
116 extern char *au_plevel
;
118 void au_dpri_whlist(struct au_nhash
*whlist
);
120 void au_dpri_vdir(struct au_vdir
*vdir
);
122 void au_dpri_inode(struct inode
*inode
);
123 void au_dpri_dalias(struct inode
*inode
);
124 void au_dpri_dentry(struct dentry
*dentry
);
126 void au_dpri_file(struct file
*filp
);
128 void au_dpri_sb(struct super_block
*sb
);
130 void au_dbg_sleep_jiffy(int jiffy
);
132 void au_dbg_iattr(struct iattr
*ia
);
134 #define au_dbg_verify_dinode(d) __au_dbg_verify_dinode(d, __func__, __LINE__)
135 void __au_dbg_verify_dinode(struct dentry
*dentry
, const char *func
, int line
);
136 void au_dbg_verify_dir_parent(struct dentry
*dentry
, unsigned int sigen
);
137 void au_dbg_verify_nondir_parent(struct dentry
*dentry
, unsigned int sigen
);
138 void au_dbg_verify_gen(struct dentry
*parent
, unsigned int sigen
);
139 void au_dbg_verify_kthread(void);
141 int __init
au_debug_init(void);
142 void au_debug_sbinfo_init(struct au_sbinfo
*sbinfo
);
143 #define AuDbgWhlist(w) do { \
148 #define AuDbgVdir(v) do { \
153 #define AuDbgInode(i) do { \
158 #define AuDbgDAlias(i) do { \
163 #define AuDbgDentry(d) do { \
168 #define AuDbgFile(f) do { \
173 #define AuDbgSb(sb) do { \
178 #define AuDbgSleep(sec) do { \
179 AuDbg("sleep %d sec\n", sec); \
183 #define AuDbgSleepJiffy(jiffy) do { \
184 AuDbg("sleep %d jiffies\n", jiffy); \
185 au_dbg_sleep_jiffy(jiffy); \
188 #define AuDbgIAttr(ia) do { \
189 AuDbg("ia_valid 0x%x\n", (ia)->ia_valid); \
193 #define AuDbgSym(addr) do { \
194 char sym[KSYM_SYMBOL_LEN]; \
195 sprint_symbol(sym, (unsigned long)addr); \
196 AuDbg("%s\n", sym); \
199 #define AuInfoSym(addr) do { \
200 char sym[KSYM_SYMBOL_LEN]; \
201 sprint_symbol(sym, (unsigned long)addr); \
202 AuInfo("%s\n", sym); \
205 AuStubVoid(au_dbg_verify_dinode
, struct dentry
*dentry
)
206 AuStubVoid(au_dbg_verify_dir_parent
, struct dentry
*dentry
, unsigned int sigen
)
207 AuStubVoid(au_dbg_verify_nondir_parent
, struct dentry
*dentry
,
209 AuStubVoid(au_dbg_verify_gen
, struct dentry
*parent
, unsigned int sigen
)
210 AuStubVoid(au_dbg_verify_kthread
, void)
211 AuStubInt0(__init au_debug_init
, void)
212 AuStubVoid(au_debug_sbinfo_init
, struct au_sbinfo
*sbinfo
)
214 #define AuDbgWhlist(w) do {} while (0)
215 #define AuDbgVdir(v) do {} while (0)
216 #define AuDbgInode(i) do {} while (0)
217 #define AuDbgDAlias(i) do {} while (0)
218 #define AuDbgDentry(d) do {} while (0)
219 #define AuDbgFile(f) do {} while (0)
220 #define AuDbgSb(sb) do {} while (0)
221 #define AuDbgSleep(sec) do {} while (0)
222 #define AuDbgSleepJiffy(jiffy) do {} while (0)
223 #define AuDbgIAttr(ia) do {} while (0)
224 #define AuDbgSym(addr) do {} while (0)
225 #define AuInfoSym(addr) do {} while (0)
226 #endif /* CONFIG_AUFS_DEBUG */
228 /* ---------------------------------------------------------------------- */
230 #ifdef CONFIG_AUFS_MAGIC_SYSRQ
231 int __init
au_sysrq_init(void);
232 void au_sysrq_fin(void);
234 #ifdef CONFIG_HW_CONSOLE
235 #define au_dbg_blocked() do { \
240 AuStubVoid(au_dbg_blocked
, void)
244 AuStubInt0(__init au_sysrq_init
, void)
245 AuStubVoid(au_sysrq_fin
, void)
246 AuStubVoid(au_dbg_blocked
, void)
247 #endif /* CONFIG_AUFS_MAGIC_SYSRQ */
249 #endif /* __KERNEL__ */
250 #endif /* __AUFS_DEBUG_H__ */