~ubuntu-branches/ubuntu/raring/aufs/raring

« back to all changes in this revision

Viewing changes to fs/aufs25/debug.h

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080506183550-0b6c974kkgc46oeh
Tags: 0+20080506-1
* New upstream release, supports Kernel 2.6.25 (Closes: #479717)
* Fix building with older Kernels (Closes: #475042)
* Update the patches 01, 04 and 07 to also patch fs/aufs25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2005-2008 Junjiro 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
 * $Id: debug.h,v 1.2 2008/04/21 02:00:37 sfjro Exp $
 
23
 */
 
24
 
 
25
#ifndef __AUFS_DEBUG_H__
 
26
#define __AUFS_DEBUG_H__
 
27
 
 
28
#ifdef __KERNEL__
 
29
 
 
30
#include <linux/fs.h>
 
31
 
 
32
/* to debug easier, do not make it an inlined function */
 
33
#define MtxMustLock(mtx)        AuDebugOn(!mutex_is_locked(mtx))
 
34
 
 
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)
 
42
{
 
43
        return atomic_read(&au_cond);
 
44
}
 
45
#else
 
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)
 
50
{
 
51
        return 0;
 
52
}
 
53
#endif /* CONFIG_AUFS_DEBUG */
 
54
 
 
55
/* ---------------------------------------------------------------------- */
 
56
 
 
57
/* debug print */
 
58
#if defined(CONFIG_LKTR) || defined(CONFIG_LKTR_MODULE)
 
59
#include <linux/lktr.h>
 
60
#ifdef CONFIG_AUFS_DEBUG
 
61
#undef LktrCond
 
62
#define LktrCond        unlikely(au_debug_test() || (lktr_cond && lktr_cond()))
 
63
#endif
 
64
#else
 
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 { \
 
69
        if (LktrCond) \
 
70
                AuDbg(fmt, ##args); \
 
71
} while (0)
 
72
#define LKTRLabel(label)                LKTRTrace("%s\n", #label)
 
73
#endif /* CONFIG_LKTR */
 
74
 
 
75
#define AuTraceErr(e) do { \
 
76
        if (unlikely((e) < 0)) \
 
77
                LKTRTrace("err %d\n", (int)(e)); \
 
78
} while (0)
 
79
 
 
80
#define AuTraceErrPtr(p) do { \
 
81
        if (IS_ERR(p)) \
 
82
                LKTRTrace("err %ld\n", PTR_ERR(p)); \
 
83
} while (0)
 
84
 
 
85
#define AuTraceEnter()  LKTRLabel(enter)
 
86
 
 
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)
 
90
 
 
91
/* ---------------------------------------------------------------------- */
 
92
 
 
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); \
 
105
} while (0)
 
106
 
 
107
#define AuErr1(fmt, arg...) do { \
 
108
        static unsigned char _c; \
 
109
        if (!_c++) AuErr(fmt, ##arg); \
 
110
} while (0)
 
111
 
 
112
#define AuIOErr1(fmt, arg...) do { \
 
113
        static unsigned char _c; \
 
114
        if (!_c++) AuIOErr(fmt, ##arg); \
 
115
} while (0)
 
116
 
 
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); \
 
121
        dump_stack(); \
 
122
} while (0)
 
123
 
 
124
/* ---------------------------------------------------------------------- */
 
125
 
 
126
struct au_sbinfo;
 
127
#ifdef CONFIG_AUFS_DEBUG
 
128
extern char *au_plevel;
 
129
struct au_nhash;
 
130
void au_dpri_whlist(struct au_nhash *whlist);
 
131
struct au_vdir;
 
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"); \
 
142
        au_dpri_whlist(w); \
 
143
} while (0)
 
144
 
 
145
#define AuDbgVdir(v) do { \
 
146
        LKTRTrace(#v "\n"); \
 
147
        au_dpri_vdir(v); \
 
148
} while (0)
 
149
 
 
150
#define AuDbgInode(i) do { \
 
151
        LKTRTrace(#i "\n"); \
 
152
        au_dpri_inode(i); \
 
153
} while (0)
 
154
 
 
155
#define AuDbgDentry(d) do { \
 
156
        LKTRTrace(#d "\n"); \
 
157
        au_dpri_dentry(d); \
 
158
} while (0)
 
159
 
 
160
#define AuDbgFile(f) do { \
 
161
        LKTRTrace(#f "\n"); \
 
162
        au_dpri_file(f); \
 
163
} while (0)
 
164
 
 
165
#define AuDbgSb(sb) do { \
 
166
        LKTRTrace(#sb "\n"); \
 
167
        au_dpri_sb(sb); \
 
168
} while (0)
 
169
 
 
170
#define AuDbgSleep(sec) do { \
 
171
        AuDbg("sleep %d sec\n", sec); \
 
172
        au_dbg_sleep(sec); \
 
173
} while (0)
 
174
#else
 
175
static inline int au_debug_init(void)
 
176
{
 
177
        return 0;
 
178
}
 
179
static inline void au_debug_sbinfo_init(struct au_sbinfo *sbinfo)
 
180
{
 
181
        /* empty */
 
182
}
 
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 */
 
191
 
 
192
#ifdef DbgUdbaRace
 
193
#define AuDbgSleep_UdbaRace()   AuDbgSleep(DbgUdbaRace)
 
194
#else
 
195
#define AuDbgSleep_UdbaRace()   do {} while (0)
 
196
#endif
 
197
 
 
198
#ifdef CONFIG_AUFS_MAGIC_SYSRQ
 
199
int __init au_sysrq_init(void);
 
200
void au_sysrq_fin(void);
 
201
#else
 
202
static inline int au_sysrq_init(void)
 
203
{
 
204
        return 0;
 
205
}
 
206
#define au_sysrq_fin()          do {} while (0)
 
207
#endif
 
208
 
 
209
#endif /* __KERNEL__ */
 
210
#endif /* __AUFS_DEBUG_H__ */