26
26
#include <linux/fs.h>
28
#define MtxMustLock(mtx) AuDebugOn(!mutex_is_locked(mtx))
28
30
#ifdef CONFIG_AUFS_DEBUG
29
#define AuDebugOn(a) BUG_ON(a)
31
/* sparse warns about pointer */
32
#define AuDebugOn(a) BUG_ON(!!(a))
30
33
extern atomic_t aufs_cond;
31
#define au_debug_on() atomic_inc(&aufs_cond)
32
#define au_debug_off() atomic_dec(&aufs_cond)
33
#define au_is_debug() atomic_read(&aufs_cond)
34
#define au_debug_on() atomic_inc_return(&aufs_cond)
35
#define au_debug_off() atomic_dec_return(&aufs_cond)
36
#define au_test_debug() atomic_read(&aufs_cond)
35
#define AuDebugOn(a) do{}while(0)
36
#define au_debug_on() do{}while(0)
37
#define au_debug_off() do{}while(0)
38
#define au_is_debug() 0
38
#define AuDebugOn(a) do {} while (0)
39
#define au_debug_on() do {} while (0)
40
#define au_debug_off() do {} while (0)
41
#define au_test_debug() 0
42
#endif /* CONFIG_AUFS_DEBUG */
41
#define MtxMustLock(mtx) AuDebugOn(!mutex_is_locked(mtx))
44
#if defined(CONFIG_AUFS_DEBUG) && defined(CONFIG_MAGIC_SYSRQ)
45
int __init au_sysrq_init(void);
46
void au_sysrq_fin(void);
48
#define au_sysrq_init() 0
49
#define au_sysrq_fin() do {} while (0)
50
#endif /* CONFIG_AUFS_DEBUG && CONFIG_MAGIC_SYSRQ */
43
52
/* ---------------------------------------------------------------------- */
47
56
#include <linux/lktr.h>
48
57
#ifdef CONFIG_AUFS_DEBUG
50
#define LktrCond unlikely((lktr_cond && lktr_cond()) || au_is_debug())
59
#define LktrCond unlikely(au_test_debug() || (lktr_cond && lktr_cond()))
53
#define LktrCond au_is_debug()
54
#define LKTRDumpVma(pre, vma, suf) do{}while(0)
55
#define LKTRDumpStack() do{}while(0)
62
#define LktrCond au_test_debug()
63
#define LKTRDumpVma(pre, vma, suf) do {} while (0)
64
#define LKTRDumpStack() do {} while (0)
56
65
#define LKTRTrace(fmt, args...) do { \
60
69
#define LKTRLabel(label) LKTRTrace("%s\n", #label)
61
70
#endif /* CONFIG_LKTR */
63
#define TraceErr(e) do { \
72
#define AuTraceErr(e) do { \
64
73
if (unlikely((e) < 0)) \
65
74
LKTRTrace("err %d\n", (int)(e)); \
67
#define TraceErrPtr(p) do { \
77
#define AuTraceErrPtr(p) do { \
69
79
LKTRTrace("err %ld\n", PTR_ERR(p)); \
71
#define TraceEnter() LKTRLabel(enter)
82
#define AuTraceEnter() LKTRLabel(enter)
73
84
/* dirty macros for debug print, use with "%.*s" and caution */
74
#define LNPair(qstr) (qstr)->len,(qstr)->name
75
#define DLNPair(d) LNPair(&(d)->d_name)
85
#define AuLNPair(qstr) (qstr)->len, (qstr)->name
86
#define AuDLNPair(d) AuLNPair(&(d)->d_name)
77
88
/* ---------------------------------------------------------------------- */
79
#define Dpri(lvl, fmt, arg...) \
90
#define AuDpri(lvl, fmt, arg...) \
80
91
printk(lvl AUFS_NAME " %s:%d:%s[%d]: " fmt, \
81
92
__func__, __LINE__, current->comm, current->pid, ##arg)
82
#define Dbg(fmt, arg...) Dpri(KERN_DEBUG, fmt, ##arg)
83
#define Warn(fmt, arg...) Dpri(KERN_WARNING, fmt, ##arg)
84
#define Warn1(fmt, arg...) do { \
85
static unsigned char c; \
86
if (!c++) Warn(fmt, ##arg); \
88
#define Err(fmt, arg...) Dpri(KERN_ERR, fmt, ##arg)
89
#define Err1(fmt, arg...) do { \
90
static unsigned char c; \
91
if (!c++) Err(fmt, ##arg); \
93
#define IOErr(fmt, arg...) Err("I/O Error, " fmt, ##arg)
94
#define IOErr1(fmt, arg...) do { \
95
static unsigned char c; \
96
if (!c++) IOErr(fmt, ##arg); \
98
#define IOErrWhck(fmt, arg...) Err("I/O Error, try whck. " fmt, ##arg)
93
#define AuDbg(fmt, arg...) AuDpri(KERN_DEBUG, fmt, ##arg)
94
#define AuInfo(fmt, arg...) AuDpri(KERN_INFO, fmt, ##arg)
95
#define AuWarn(fmt, arg...) AuDpri(KERN_WARNING, fmt, ##arg)
96
#define AuErr(fmt, arg...) AuDpri(KERN_ERR, fmt, ##arg)
97
#define AuIOErr(fmt, arg...) AuErr("I/O Error, " fmt, ##arg)
98
#define AuIOErrWhck(fmt, arg...) AuErr("I/O Error, try whck. " fmt, ##arg)
99
#define AuWarn1(fmt, arg...) do { \
100
static unsigned char c; \
101
if (!c++) AuWarn(fmt, ##arg); \
104
#define AuErr1(fmt, arg...) do { \
105
static unsigned char c; \
106
if (!c++) AuErr(fmt, ##arg); \
109
#define AuIOErr1(fmt, arg...) do { \
110
static unsigned char c; \
111
if (!c++) AuIOErr(fmt, ##arg); \
114
#define AuUnsupportMsg "This operation is not supported." \
115
" Please report me this application."
116
#define AuUnsupport(fmt, args...) do { \
117
AuErr(AuUnsupportMsg "\n" fmt, ##args); \
100
121
/* ---------------------------------------------------------------------- */
109
130
void au_dpri_file(struct file *filp);
110
131
void au_dpri_sb(struct super_block *sb);
111
132
void au_dbg_sleep(int sec);
112
#define DbgWhlist(w) do{LKTRTrace(#w "\n"); au_dpri_whlist(w);}while(0)
113
#define DbgVdir(v) do{LKTRTrace(#v "\n"); au_dpri_vdir(v);}while(0)
114
#define DbgInode(i) do{LKTRTrace(#i "\n"); au_dpri_inode(i);}while(0)
115
#define DbgDentry(d) do{LKTRTrace(#d "\n"); au_dpri_dentry(d);}while(0)
116
#define DbgFile(f) do{LKTRTrace(#f "\n"); au_dpri_file(f);}while(0)
117
#define DbgSb(sb) do{LKTRTrace(#sb "\n"); au_dpri_sb(sb);}while(0)
118
#define DbgSleep(sec) do{Dbg("sleep %d sec\n", sec); au_dbg_sleep(sec);}while(0)
133
#define AuDbgWhlist(w) do { \
134
LKTRTrace(#w "\n"); \
138
#define AuDbgVdir(v) do { \
139
LKTRTrace(#v "\n"); \
143
#define AuDbgInode(i) do { \
144
LKTRTrace(#i "\n"); \
148
#define AuDbgDentry(d) do { \
149
LKTRTrace(#d "\n"); \
153
#define AuDbgFile(f) do { \
154
LKTRTrace(#f "\n"); \
158
#define AuDbgSb(sb) do { \
159
LKTRTrace(#sb "\n"); \
163
#define AuDbgSleep(sec) do { \
164
AuDbg("sleep %d sec\n", sec); \
120
#define DbgWhlist(w) do{}while(0)
121
#define DbgVdir(v) do{}while(0)
122
#define DbgInode(i) do{}while(0)
123
#define DbgDentry(d) do{}while(0)
124
#define DbgFile(f) do{}while(0)
125
#define DbgSb(sb) do{}while(0)
126
#define DbgSleep(sec) do{}while(0)
168
#define AuDbgWhlist(w) do {} while (0)
169
#define AuDbgVdir(v) do {} while (0)
170
#define AuDbgInode(i) do {} while (0)
171
#define AuDbgDentry(d) do {} while (0)
172
#define AuDbgFile(f) do {} while (0)
173
#define AuDbgSb(sb) do {} while (0)
174
#define AuDbgSleep(sec) do {} while (0)
175
#endif /* CONFIG_AUFS_DEBUG */
129
177
#endif /* __KERNEL__ */
130
178
#endif /* __AUFS_DEBUG_H__ */