2
* Copyright (C) 2005-2008 Junjiro 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
22
* $Id: debug.h,v 1.2 2008/04/21 02:00:37 sfjro Exp $
25
#ifndef __AUFS_DEBUG_H__
26
#define __AUFS_DEBUG_H__
32
/* to debug easier, do not make it an inlined function */
33
#define MtxMustLock(mtx) AuDebugOn(!mutex_is_locked(mtx))
35
#ifdef CONFIG_AUFS_DEBUG
36
/* sparse warns about pointer */
37
#define AuDebugOn(a) BUG_ON(!!(a))
38
extern atomic_t au_cond;
39
#define au_debug_on() atomic_inc_return(&au_cond)
40
#define au_debug_off() atomic_dec_return(&au_cond)
41
static inline int au_debug_test(void)
43
return atomic_read(&au_cond);
46
#define AuDebugOn(a) do {} while (0)
47
#define au_debug_on() do {} while (0)
48
#define au_debug_off() do {} while (0)
49
static inline int au_debug_test(void)
53
#endif /* CONFIG_AUFS_DEBUG */
55
/* ---------------------------------------------------------------------- */
58
#if defined(CONFIG_LKTR) || defined(CONFIG_LKTR_MODULE)
59
#include <linux/lktr.h>
60
#ifdef CONFIG_AUFS_DEBUG
62
#define LktrCond unlikely(au_debug_test() || (lktr_cond && lktr_cond()))
65
#define LktrCond au_debug_test()
66
#define LKTRDumpVma(pre, vma, suf) do {} while (0)
67
#define LKTRDumpStack() do {} while (0)
68
#define LKTRTrace(fmt, args...) do { \
72
#define LKTRLabel(label) LKTRTrace("%s\n", #label)
73
#endif /* CONFIG_LKTR */
75
#define AuTraceErr(e) do { \
76
if (unlikely((e) < 0)) \
77
LKTRTrace("err %d\n", (int)(e)); \
80
#define AuTraceErrPtr(p) do { \
82
LKTRTrace("err %ld\n", PTR_ERR(p)); \
85
#define AuTraceEnter() LKTRLabel(enter)
87
/* dirty macros for debug print, use with "%.*s" and caution */
88
#define AuLNPair(qstr) (qstr)->len, (qstr)->name
89
#define AuDLNPair(d) AuLNPair(&(d)->d_name)
91
/* ---------------------------------------------------------------------- */
93
#define AuDpri(lvl, fmt, arg...) \
94
printk(lvl AUFS_NAME " %s:%d:%s[%d]: " fmt, \
95
__func__, __LINE__, current->comm, current->pid, ##arg)
96
#define AuDbg(fmt, arg...) AuDpri(KERN_DEBUG, fmt, ##arg)
97
#define AuInfo(fmt, arg...) AuDpri(KERN_INFO, fmt, ##arg)
98
#define AuWarn(fmt, arg...) AuDpri(KERN_WARNING, fmt, ##arg)
99
#define AuErr(fmt, arg...) AuDpri(KERN_ERR, fmt, ##arg)
100
#define AuIOErr(fmt, arg...) AuErr("I/O Error, " fmt, ##arg)
101
#define AuIOErrWhck(fmt, arg...) AuErr("I/O Error, try whck. " fmt, ##arg)
102
#define AuWarn1(fmt, arg...) do { \
103
static unsigned char _c; \
104
if (!_c++) AuWarn(fmt, ##arg); \
107
#define AuErr1(fmt, arg...) do { \
108
static unsigned char _c; \
109
if (!_c++) AuErr(fmt, ##arg); \
112
#define AuIOErr1(fmt, arg...) do { \
113
static unsigned char _c; \
114
if (!_c++) AuIOErr(fmt, ##arg); \
117
#define AuUnsupportMsg "This operation is not supported." \
118
" Please report this application to aufs-users ML."
119
#define AuUnsupport(fmt, args...) do { \
120
AuErr(AuUnsupportMsg "\n" fmt, ##args); \
124
/* ---------------------------------------------------------------------- */
127
#ifdef CONFIG_AUFS_DEBUG
128
extern char *au_plevel;
130
void au_dpri_whlist(struct au_nhash *whlist);
132
void au_dpri_vdir(struct au_vdir *vdir);
133
void au_dpri_inode(struct inode *inode);
134
void au_dpri_dentry(struct dentry *dentry);
135
void au_dpri_file(struct file *filp);
136
void au_dpri_sb(struct super_block *sb);
137
void au_dbg_sleep(int sec);
138
int __init au_debug_init(void);
139
void au_debug_sbinfo_init(struct au_sbinfo *sbinfo);
140
#define AuDbgWhlist(w) do { \
141
LKTRTrace(#w "\n"); \
145
#define AuDbgVdir(v) do { \
146
LKTRTrace(#v "\n"); \
150
#define AuDbgInode(i) do { \
151
LKTRTrace(#i "\n"); \
155
#define AuDbgDentry(d) do { \
156
LKTRTrace(#d "\n"); \
160
#define AuDbgFile(f) do { \
161
LKTRTrace(#f "\n"); \
165
#define AuDbgSb(sb) do { \
166
LKTRTrace(#sb "\n"); \
170
#define AuDbgSleep(sec) do { \
171
AuDbg("sleep %d sec\n", sec); \
175
static inline int au_debug_init(void)
179
static inline void au_debug_sbinfo_init(struct au_sbinfo *sbinfo)
183
#define AuDbgWhlist(w) do {} while (0)
184
#define AuDbgVdir(v) do {} while (0)
185
#define AuDbgInode(i) do {} while (0)
186
#define AuDbgDentry(d) do {} while (0)
187
#define AuDbgFile(f) do {} while (0)
188
#define AuDbgSb(sb) do {} while (0)
189
#define AuDbgSleep(sec) do {} while (0)
190
#endif /* CONFIG_AUFS_DEBUG */
193
#define AuDbgSleep_UdbaRace() AuDbgSleep(DbgUdbaRace)
195
#define AuDbgSleep_UdbaRace() do {} while (0)
198
#ifdef CONFIG_AUFS_MAGIC_SYSRQ
199
int __init au_sysrq_init(void);
200
void au_sysrq_fin(void);
202
static inline int au_sysrq_init(void)
206
#define au_sysrq_fin() do {} while (0)
209
#endif /* __KERNEL__ */
210
#endif /* __AUFS_DEBUG_H__ */