[GFS2] Add back missing BUG()
[deliverable/linux.git] / fs / gfs2 / util.h
CommitLineData
b3b94faa
DT
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License v.2.
8 */
9
10#ifndef __UTIL_DOT_H__
11#define __UTIL_DOT_H__
12
b3b94faa
DT
13
14#define fs_printk(level, fs, fmt, arg...) \
15 printk(level "GFS2: fsid=%s: " fmt , (fs)->sd_fsname , ## arg)
16
17#define fs_info(fs, fmt, arg...) \
18 fs_printk(KERN_INFO , fs , fmt , ## arg)
19
20#define fs_warn(fs, fmt, arg...) \
21 fs_printk(KERN_WARNING , fs , fmt , ## arg)
22
23#define fs_err(fs, fmt, arg...) \
24 fs_printk(KERN_ERR, fs , fmt , ## arg)
25
26
27void gfs2_assert_i(struct gfs2_sbd *sdp);
28
29#define gfs2_assert(sdp, assertion) \
30do { \
31 if (unlikely(!(assertion))) { \
32 gfs2_assert_i(sdp); \
b3b94faa
DT
33 } \
34} while (0)
35
36
37int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
38 const char *function, char *file, unsigned int line);
39
40#define gfs2_assert_withdraw(sdp, assertion) \
41((likely(assertion)) ? 0 : gfs2_assert_withdraw_i((sdp), #assertion, \
42 __FUNCTION__, __FILE__, __LINE__))
43
44
45int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
46 const char *function, char *file, unsigned int line);
47
48#define gfs2_assert_warn(sdp, assertion) \
49((likely(assertion)) ? 0 : gfs2_assert_warn_i((sdp), #assertion, \
50 __FUNCTION__, __FILE__, __LINE__))
51
52
53int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide,
54 const char *function, char *file, unsigned int line);
55
56#define gfs2_consist(sdp) \
57gfs2_consist_i((sdp), 0, __FUNCTION__, __FILE__, __LINE__)
58
59
60int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide,
61 const char *function, char *file, unsigned int line);
62
63#define gfs2_consist_inode(ip) \
64gfs2_consist_inode_i((ip), 0, __FUNCTION__, __FILE__, __LINE__)
65
66
67int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide,
68 const char *function, char *file, unsigned int line);
69
70#define gfs2_consist_rgrpd(rgd) \
71gfs2_consist_rgrpd_i((rgd), 0, __FUNCTION__, __FILE__, __LINE__)
72
73
74int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
75 const char *type, const char *function,
76 char *file, unsigned int line);
77
78static inline int gfs2_meta_check_i(struct gfs2_sbd *sdp,
79 struct buffer_head *bh,
80 const char *function,
81 char *file, unsigned int line)
82{
83 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
84 uint32_t magic = mh->mh_magic;
85 magic = be32_to_cpu(magic);
86 if (unlikely(magic != GFS2_MAGIC))
87 return gfs2_meta_check_ii(sdp, bh, "magic number", function,
88 file, line);
89 return 0;
90}
91
92#define gfs2_meta_check(sdp, bh) \
93gfs2_meta_check_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__)
94
95
96int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
97 uint16_t type, uint16_t t,
98 const char *function,
99 char *file, unsigned int line);
100
101static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
102 struct buffer_head *bh,
103 uint16_t type,
104 const char *function,
105 char *file, unsigned int line)
106{
107 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
108 uint32_t magic = mh->mh_magic;
e3167ded 109 uint16_t t = be32_to_cpu(mh->mh_type);
b3b94faa
DT
110 magic = be32_to_cpu(magic);
111 if (unlikely(magic != GFS2_MAGIC))
112 return gfs2_meta_check_ii(sdp, bh, "magic number", function,
113 file, line);
b3b94faa
DT
114 if (unlikely(t != type))
115 return gfs2_metatype_check_ii(sdp, bh, type, t, function,
116 file, line);
117 return 0;
118}
119
120#define gfs2_metatype_check(sdp, bh, type) \
121gfs2_metatype_check_i((sdp), (bh), (type), __FUNCTION__, __FILE__, __LINE__)
122
123static inline void gfs2_metatype_set(struct buffer_head *bh, uint16_t type,
124 uint16_t format)
125{
126 struct gfs2_meta_header *mh;
127 mh = (struct gfs2_meta_header *)bh->b_data;
e3167ded
SW
128 mh->mh_type = cpu_to_be32(type);
129 mh->mh_format = cpu_to_be32(format);
b3b94faa
DT
130}
131
132
133int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function,
134 char *file, unsigned int line);
135
136#define gfs2_io_error(sdp) \
137gfs2_io_error_i((sdp), __FUNCTION__, __FILE__, __LINE__);
138
139
140int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
141 const char *function, char *file, unsigned int line);
142
143#define gfs2_io_error_bh(sdp, bh) \
144gfs2_io_error_bh_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__);
145
146
147extern kmem_cache_t *gfs2_glock_cachep;
148extern kmem_cache_t *gfs2_inode_cachep;
149extern kmem_cache_t *gfs2_bufdata_cachep;
150
b3b94faa
DT
151static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
152 unsigned int *p)
153{
154 unsigned int x;
155 spin_lock(&gt->gt_spin);
156 x = *p;
157 spin_unlock(&gt->gt_spin);
158 return x;
159}
160
161#define gfs2_tune_get(sdp, field) \
162gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
163
164void gfs2_icbit_munge(struct gfs2_sbd *sdp, unsigned char **bitmap,
165 unsigned int bit, int new_value);
166
167#endif /* __UTIL_DOT_H__ */
168
This page took 0.036669 seconds and 5 git commands to generate.