2
* Copyright (C) 2005-2009 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/kernel.h> */
33
#include <linux/delay.h>
34
/* #include <linux/kd.h> */
35
/* #include <linux/vt_kern.h> */
36
#include <linux/sysrq.h>
37
#include <linux/aufs_type.h>
39
#include <asm/system.h>
41
#ifdef CONFIG_AUFS_DEBUG
42
#define AuDebugOn(a) BUG_ON(a)
44
/* module parameter */
45
extern int aufs_debug;
46
static inline void au_debug(int n)
52
static inline int au_debug_test(void)
57
#define AuDebugOn(a) do {} while (0)
58
#define au_debug() do {} while (0)
59
static inline int au_debug_test(void)
63
#endif /* CONFIG_AUFS_DEBUG */
65
/* ---------------------------------------------------------------------- */
69
#define AuDbg(fmt, ...) do { \
70
if (au_debug_test()) \
71
pr_debug("DEBUG: " fmt, ##__VA_ARGS__); \
73
#define AuLabel(l) AuDbg(#l "\n")
74
#define AuIOErr(fmt, ...) pr_err("I/O Error, " fmt, ##__VA_ARGS__)
75
#define AuWarn1(fmt, ...) do { \
76
static unsigned char _c; \
78
pr_warning(fmt, ##__VA_ARGS__); \
81
#define AuErr1(fmt, ...) do { \
82
static unsigned char _c; \
84
pr_err(fmt, ##__VA_ARGS__); \
87
#define AuIOErr1(fmt, ...) do { \
88
static unsigned char _c; \
90
AuIOErr(fmt, ##__VA_ARGS__); \
93
#define AuUnsupportMsg "This operation is not supported." \
94
" Please report this application to aufs-users ML."
95
#define AuUnsupport(fmt, ...) do { \
96
pr_err(AuUnsupportMsg "\n" fmt, ##__VA_ARGS__); \
100
#define AuTraceErr(e) do { \
101
if (unlikely((e) < 0)) \
102
AuDbg("err %d\n", (int)(e)); \
105
#define AuTraceErrPtr(p) do { \
107
AuDbg("err %ld\n", PTR_ERR(p)); \
110
/* dirty macros for debug print, use with "%.*s" and caution */
111
#define AuLNPair(qstr) (qstr)->len, (qstr)->name
112
#define AuDLNPair(d) AuLNPair(&(d)->d_name)
114
/* ---------------------------------------------------------------------- */
119
#ifdef CONFIG_AUFS_DEBUG
120
extern char *au_plevel;
122
void au_dpri_whlist(struct au_nhash *whlist);
124
void au_dpri_vdir(struct au_vdir *vdir);
126
void au_dpri_inode(struct inode *inode);
127
void au_dpri_dentry(struct dentry *dentry);
129
void au_dpri_file(struct file *filp);
131
void au_dpri_sb(struct super_block *sb);
133
void au_dbg_sleep_jiffy(int jiffy);
135
void au_dbg_iattr(struct iattr *ia);
137
void au_dbg_verify_dir_parent(struct dentry *dentry, unsigned int sigen);
138
void au_dbg_verify_nondir_parent(struct dentry *dentry, unsigned int sigen);
139
void au_dbg_verify_gen(struct dentry *parent, unsigned int sigen);
140
void au_dbg_verify_hf(struct au_finfo *finfo);
141
void au_dbg_verify_kthread(void);
143
int __init au_debug_init(void);
144
void au_debug_sbinfo_init(struct au_sbinfo *sbinfo);
145
#define AuDbgWhlist(w) do { \
150
#define AuDbgVdir(v) do { \
155
#define AuDbgInode(i) do { \
160
#define AuDbgDentry(d) do { \
165
#define AuDbgFile(f) do { \
170
#define AuDbgSb(sb) do { \
175
#define AuDbgSleep(sec) do { \
176
AuDbg("sleep %d sec\n", sec); \
180
#define AuDbgSleepJiffy(jiffy) do { \
181
AuDbg("sleep %d jiffies\n", jiffy); \
182
au_dbg_sleep_jiffy(jiffy); \
185
#define AuDbgIAttr(ia) do { \
186
AuDbg("ia_valid 0x%x\n", (ia)->ia_valid); \
190
static inline void au_dbg_verify_dir_parent(struct dentry *dentry,
195
static inline void au_dbg_verify_nondir_parent(struct dentry *dentry,
200
static inline void au_dbg_verify_gen(struct dentry *parent, unsigned int sigen)
204
static inline void au_dbg_verify_hf(struct au_finfo *finfo)
208
static inline void au_dbg_verify_kthread(void)
213
static inline int au_debug_init(void)
217
static inline void au_debug_sbinfo_init(struct au_sbinfo *sbinfo)
221
#define AuDbgWhlist(w) do {} while (0)
222
#define AuDbgVdir(v) do {} while (0)
223
#define AuDbgInode(i) do {} while (0)
224
#define AuDbgDentry(d) do {} while (0)
225
#define AuDbgFile(f) do {} while (0)
226
#define AuDbgSb(sb) do {} while (0)
227
#define AuDbgSleep(sec) do {} while (0)
228
#define AuDbgSleepJiffy(jiffy) do {} while (0)
229
#define AuDbgIAttr(ia) do {} while (0)
230
#endif /* CONFIG_AUFS_DEBUG */
232
/* ---------------------------------------------------------------------- */
234
#ifdef CONFIG_AUFS_MAGIC_SYSRQ
235
int __init au_sysrq_init(void);
236
void au_sysrq_fin(void);
238
#ifdef CONFIG_HW_CONSOLE
239
#define au_dbg_blocked() do { \
241
handle_sysrq('w', vc_cons[fg_console].d->vc_tty); \
244
#define au_dbg_blocked() do {} while (0)
248
static inline int au_sysrq_init(void)
252
#define au_sysrq_fin() do {} while (0)
253
#define au_dbg_blocked() do {} while (0)
254
#endif /* CONFIG_AUFS_MAGIC_SYSRQ */
256
#endif /* __KERNEL__ */
257
#endif /* __AUFS_DEBUG_H__ */