~ubuntu-branches/ubuntu/quantal/linux-lowlatency/quantal

« back to all changes in this revision

Viewing changes to ubuntu/aufs/debug.h

  • Committer: Package Import Robot
  • Author(s): Alessio Igor Bogani
  • Date: 2011-10-26 11:13:05 UTC
  • Revision ID: package-import@ubuntu.com-20111026111305-04kado7d1u2er2rl
Tags: 3.2.0-16.25
Add new lowlatency kernel flavour

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2005-2011 Junjiro R. Okajima
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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
 
17
 */
 
18
 
 
19
/*
 
20
 * debug print functions
 
21
 */
 
22
 
 
23
#ifndef __AUFS_DEBUG_H__
 
24
#define __AUFS_DEBUG_H__
 
25
 
 
26
#ifdef __KERNEL__
 
27
 
 
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>
 
39
 
 
40
#include <asm/system.h>
 
41
 
 
42
#ifdef CONFIG_AUFS_DEBUG
 
43
#define AuDebugOn(a)            BUG_ON(a)
 
44
 
 
45
/* module parameter */
 
46
extern int aufs_debug;
 
47
static inline void au_debug(int n)
 
48
{
 
49
        aufs_debug = n;
 
50
        smp_mb();
 
51
}
 
52
 
 
53
static inline int au_debug_test(void)
 
54
{
 
55
        return aufs_debug;
 
56
}
 
57
#else
 
58
#define AuDebugOn(a)            do {} while (0)
 
59
AuStubVoid(au_debug, int n)
 
60
AuStubInt0(au_debug_test, void)
 
61
#endif /* CONFIG_AUFS_DEBUG */
 
62
 
 
63
/* ---------------------------------------------------------------------- */
 
64
 
 
65
/* debug print */
 
66
 
 
67
#define AuDbg(fmt, ...) do { \
 
68
        if (au_debug_test()) \
 
69
                pr_debug("DEBUG: " fmt, ##__VA_ARGS__); \
 
70
} while (0)
 
71
#define AuLabel(l)              AuDbg(#l "\n")
 
72
#define AuIOErr(fmt, ...)       pr_err("I/O Error, " fmt, ##__VA_ARGS__)
 
73
#define AuWarn1(fmt, ...) do { \
 
74
        static unsigned char _c; \
 
75
        if (!_c++) \
 
76
                pr_warning(fmt, ##__VA_ARGS__); \
 
77
} while (0)
 
78
 
 
79
#define AuErr1(fmt, ...) do { \
 
80
        static unsigned char _c; \
 
81
        if (!_c++) \
 
82
                pr_err(fmt, ##__VA_ARGS__); \
 
83
} while (0)
 
84
 
 
85
#define AuIOErr1(fmt, ...) do { \
 
86
        static unsigned char _c; \
 
87
        if (!_c++) \
 
88
                AuIOErr(fmt, ##__VA_ARGS__); \
 
89
} while (0)
 
90
 
 
91
#define AuUnsupportMsg  "This operation is not supported." \
 
92
                        " Please report this application to aufs-users ML."
 
93
#define AuUnsupport(fmt, ...) do { \
 
94
        pr_err(AuUnsupportMsg "\n" fmt, ##__VA_ARGS__); \
 
95
        dump_stack(); \
 
96
} while (0)
 
97
 
 
98
#define AuTraceErr(e) do { \
 
99
        if (unlikely((e) < 0)) \
 
100
                AuDbg("err %d\n", (int)(e)); \
 
101
} while (0)
 
102
 
 
103
#define AuTraceErrPtr(p) do { \
 
104
        if (IS_ERR(p)) \
 
105
                AuDbg("err %ld\n", PTR_ERR(p)); \
 
106
} while (0)
 
107
 
 
108
/* dirty macros for debug print, use with "%.*s" and caution */
 
109
#define AuLNPair(qstr)          (qstr)->len, (qstr)->name
 
110
#define AuDLNPair(d)            AuLNPair(&(d)->d_name)
 
111
 
 
112
/* ---------------------------------------------------------------------- */
 
113
 
 
114
struct au_sbinfo;
 
115
struct au_finfo;
 
116
struct dentry;
 
117
#ifdef CONFIG_AUFS_DEBUG
 
118
extern char *au_plevel;
 
119
struct au_nhash;
 
120
void au_dpri_whlist(struct au_nhash *whlist);
 
121
struct au_vdir;
 
122
void au_dpri_vdir(struct au_vdir *vdir);
 
123
struct inode;
 
124
void au_dpri_inode(struct inode *inode);
 
125
void au_dpri_dalias(struct inode *inode);
 
126
void au_dpri_dentry(struct dentry *dentry);
 
127
struct file;
 
128
void au_dpri_file(struct file *filp);
 
129
struct super_block;
 
130
void au_dpri_sb(struct super_block *sb);
 
131
 
 
132
void au_dbg_sleep_jiffy(int jiffy);
 
133
struct iattr;
 
134
void au_dbg_iattr(struct iattr *ia);
 
135
 
 
136
#define au_dbg_verify_dinode(d) __au_dbg_verify_dinode(d, __func__, __LINE__)
 
137
void __au_dbg_verify_dinode(struct dentry *dentry, const char *func, int line);
 
138
void au_dbg_verify_dir_parent(struct dentry *dentry, unsigned int sigen);
 
139
void au_dbg_verify_nondir_parent(struct dentry *dentry, unsigned int sigen);
 
140
void au_dbg_verify_gen(struct dentry *parent, unsigned int sigen);
 
141
void au_dbg_verify_kthread(void);
 
142
 
 
143
int __init au_debug_init(void);
 
144
void au_debug_sbinfo_init(struct au_sbinfo *sbinfo);
 
145
#define AuDbgWhlist(w) do { \
 
146
        AuDbg(#w "\n"); \
 
147
        au_dpri_whlist(w); \
 
148
} while (0)
 
149
 
 
150
#define AuDbgVdir(v) do { \
 
151
        AuDbg(#v "\n"); \
 
152
        au_dpri_vdir(v); \
 
153
} while (0)
 
154
 
 
155
#define AuDbgInode(i) do { \
 
156
        AuDbg(#i "\n"); \
 
157
        au_dpri_inode(i); \
 
158
} while (0)
 
159
 
 
160
#define AuDbgDAlias(i) do { \
 
161
        AuDbg(#i "\n"); \
 
162
        au_dpri_dalias(i); \
 
163
} while (0)
 
164
 
 
165
#define AuDbgDentry(d) do { \
 
166
        AuDbg(#d "\n"); \
 
167
        au_dpri_dentry(d); \
 
168
} while (0)
 
169
 
 
170
#define AuDbgFile(f) do { \
 
171
        AuDbg(#f "\n"); \
 
172
        au_dpri_file(f); \
 
173
} while (0)
 
174
 
 
175
#define AuDbgSb(sb) do { \
 
176
        AuDbg(#sb "\n"); \
 
177
        au_dpri_sb(sb); \
 
178
} while (0)
 
179
 
 
180
#define AuDbgSleep(sec) do { \
 
181
        AuDbg("sleep %d sec\n", sec); \
 
182
        ssleep(sec); \
 
183
} while (0)
 
184
 
 
185
#define AuDbgSleepJiffy(jiffy) do { \
 
186
        AuDbg("sleep %d jiffies\n", jiffy); \
 
187
        au_dbg_sleep_jiffy(jiffy); \
 
188
} while (0)
 
189
 
 
190
#define AuDbgIAttr(ia) do { \
 
191
        AuDbg("ia_valid 0x%x\n", (ia)->ia_valid); \
 
192
        au_dbg_iattr(ia); \
 
193
} while (0)
 
194
 
 
195
#define AuDbgSym(addr) do {                             \
 
196
        char sym[KSYM_SYMBOL_LEN];                      \
 
197
        sprint_symbol(sym, (unsigned long)addr);        \
 
198
        AuDbg("%s\n", sym);                             \
 
199
} while (0)
 
200
 
 
201
#define AuInfoSym(addr) do {                            \
 
202
        char sym[KSYM_SYMBOL_LEN];                      \
 
203
        sprint_symbol(sym, (unsigned long)addr);        \
 
204
        AuInfo("%s\n", sym);                            \
 
205
} while (0)
 
206
#else
 
207
AuStubVoid(au_dbg_verify_dinode, struct dentry *dentry)
 
208
AuStubVoid(au_dbg_verify_dir_parent, struct dentry *dentry, unsigned int sigen)
 
209
AuStubVoid(au_dbg_verify_nondir_parent, struct dentry *dentry,
 
210
           unsigned int sigen)
 
211
AuStubVoid(au_dbg_verify_gen, struct dentry *parent, unsigned int sigen)
 
212
AuStubVoid(au_dbg_verify_kthread, void)
 
213
AuStubInt0(__init au_debug_init, void)
 
214
AuStubVoid(au_debug_sbinfo_init, struct au_sbinfo *sbinfo)
 
215
 
 
216
#define AuDbgWhlist(w)          do {} while (0)
 
217
#define AuDbgVdir(v)            do {} while (0)
 
218
#define AuDbgInode(i)           do {} while (0)
 
219
#define AuDbgDAlias(i)          do {} while (0)
 
220
#define AuDbgDentry(d)          do {} while (0)
 
221
#define AuDbgFile(f)            do {} while (0)
 
222
#define AuDbgSb(sb)             do {} while (0)
 
223
#define AuDbgSleep(sec)         do {} while (0)
 
224
#define AuDbgSleepJiffy(jiffy)  do {} while (0)
 
225
#define AuDbgIAttr(ia)          do {} while (0)
 
226
#define AuDbgSym(addr)          do {} while (0)
 
227
#define AuInfoSym(addr)         do {} while (0)
 
228
#endif /* CONFIG_AUFS_DEBUG */
 
229
 
 
230
/* ---------------------------------------------------------------------- */
 
231
 
 
232
#ifdef CONFIG_AUFS_MAGIC_SYSRQ
 
233
int __init au_sysrq_init(void);
 
234
void au_sysrq_fin(void);
 
235
 
 
236
#ifdef CONFIG_HW_CONSOLE
 
237
#define au_dbg_blocked() do { \
 
238
        WARN_ON(1); \
 
239
        handle_sysrq('w'); \
 
240
} while (0)
 
241
#else
 
242
AuStubVoid(au_dbg_blocked, void)
 
243
#endif
 
244
 
 
245
#else
 
246
AuStubInt0(__init au_sysrq_init, void)
 
247
AuStubVoid(au_sysrq_fin, void)
 
248
AuStubVoid(au_dbg_blocked, void)
 
249
#endif /* CONFIG_AUFS_MAGIC_SYSRQ */
 
250
 
 
251
#endif /* __KERNEL__ */
 
252
#endif /* __AUFS_DEBUG_H__ */