~ubuntu-branches/ubuntu/vivid/aufs/vivid

« back to all changes in this revision

Viewing changes to fs/aufs/debug.h

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2007-12-15 23:32:51 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20071215233251-2vgs2lmg8mai5d9e
Tags: 0+20071211-1ubuntu1
* Merge from debian unstable (LP: #175705), remaining changes:
  - Fix for Ubuntu Kernels (updated)
* patches/01_vserver.dpatch: Removed
* patches/06_ubuntu.dpatch: Added (update of ubuntu patch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 */
18
18
 
19
 
/* $Id: debug.h,v 1.33 2007/06/04 02:17:34 sfjro Exp $ */
 
19
/* $Id: debug.h,v 1.40 2007/10/15 01:26:33 sfjro Exp $ */
20
20
 
21
21
#ifndef __AUFS_DEBUG_H__
22
22
#define __AUFS_DEBUG_H__
25
25
 
26
26
#include <linux/fs.h>
27
27
 
 
28
#define MtxMustLock(mtx)        AuDebugOn(!mutex_is_locked(mtx))
 
29
 
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)
34
37
#else
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
39
 
#endif
 
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 */
40
43
 
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);
 
47
#else
 
48
#define au_sysrq_init()         0
 
49
#define au_sysrq_fin()          do {} while (0)
 
50
#endif /* CONFIG_AUFS_DEBUG && CONFIG_MAGIC_SYSRQ */
42
51
 
43
52
/* ---------------------------------------------------------------------- */
44
53
 
47
56
#include <linux/lktr.h>
48
57
#ifdef CONFIG_AUFS_DEBUG
49
58
#undef LktrCond
50
 
#define LktrCond        unlikely((lktr_cond && lktr_cond()) || au_is_debug())
 
59
#define LktrCond        unlikely(au_test_debug() || (lktr_cond && lktr_cond()))
51
60
#endif
52
61
#else
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 { \
57
66
        if (LktrCond) \
58
 
                Dbg(fmt, ##args); \
 
67
                AuDbg(fmt, ##args); \
59
68
} while (0)
60
69
#define LKTRLabel(label)                LKTRTrace("%s\n", #label)
61
70
#endif /* CONFIG_LKTR */
62
71
 
63
 
#define TraceErr(e) do { \
 
72
#define AuTraceErr(e) do { \
64
73
        if (unlikely((e) < 0)) \
65
74
                LKTRTrace("err %d\n", (int)(e)); \
66
75
} while (0)
67
 
#define TraceErrPtr(p) do { \
 
76
 
 
77
#define AuTraceErrPtr(p) do { \
68
78
        if (IS_ERR(p)) \
69
79
                LKTRTrace("err %ld\n", PTR_ERR(p)); \
70
80
} while (0)
71
 
#define TraceEnter()    LKTRLabel(enter)
 
81
 
 
82
#define AuTraceEnter()  LKTRLabel(enter)
72
83
 
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)
76
87
 
77
88
/* ---------------------------------------------------------------------- */
78
89
 
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); \
87
 
        } while (0)
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); \
92
 
        } while (0)
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); \
97
 
        } while (0)
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); \
 
102
} while (0)
 
103
 
 
104
#define AuErr1(fmt, arg...) do { \
 
105
        static unsigned char c; \
 
106
        if (!c++) AuErr(fmt, ##arg); \
 
107
} while (0)
 
108
 
 
109
#define AuIOErr1(fmt, arg...) do { \
 
110
        static unsigned char c; \
 
111
        if (!c++) AuIOErr(fmt, ##arg); \
 
112
} while (0)
 
113
 
 
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); \
 
118
        dump_stack(); \
 
119
} while (0)
99
120
 
100
121
/* ---------------------------------------------------------------------- */
101
122
 
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"); \
 
135
        au_dpri_whlist(w); \
 
136
} while (0)
 
137
 
 
138
#define AuDbgVdir(v) do { \
 
139
        LKTRTrace(#v "\n"); \
 
140
        au_dpri_vdir(v); \
 
141
} while (0)
 
142
 
 
143
#define AuDbgInode(i) do { \
 
144
        LKTRTrace(#i "\n"); \
 
145
        au_dpri_inode(i); \
 
146
} while (0)
 
147
 
 
148
#define AuDbgDentry(d) do { \
 
149
        LKTRTrace(#d "\n"); \
 
150
        au_dpri_dentry(d); \
 
151
} while (0)
 
152
 
 
153
#define AuDbgFile(f) do { \
 
154
        LKTRTrace(#f "\n"); \
 
155
        au_dpri_file(f); \
 
156
} while (0)
 
157
 
 
158
#define AuDbgSb(sb) do { \
 
159
        LKTRTrace(#sb "\n"); \
 
160
        au_dpri_sb(sb); \
 
161
} while (0)
 
162
 
 
163
#define AuDbgSleep(sec) do { \
 
164
        AuDbg("sleep %d sec\n", sec); \
 
165
        au_dbg_sleep(sec); \
 
166
} while (0)
119
167
#else
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)
127
 
#endif
 
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 */
128
176
 
129
177
#endif /* __KERNEL__ */
130
178
#endif /* __AUFS_DEBUG_H__ */