Commit | Line | Data |
---|---|---|
b3b94faa DT |
1 | /* |
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | |
3a8a9a10 | 3 | * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. |
b3b94faa DT |
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 | |
e9fc2aa0 | 7 | * of the GNU General Public License version 2. |
b3b94faa DT |
8 | */ |
9 | ||
10 | #ifndef __UTIL_DOT_H__ | |
11 | #define __UTIL_DOT_H__ | |
12 | ||
d77d1b58 JP |
13 | #ifdef pr_fmt |
14 | #undef pr_fmt | |
15 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | |
16 | #endif | |
17 | ||
75ca61c1 SW |
18 | #include <linux/mempool.h> |
19 | ||
f2f7ba52 | 20 | #include "incore.h" |
b3b94faa | 21 | |
d77d1b58 JP |
22 | #define fs_warn(fs, fmt, ...) \ |
23 | pr_warn("fsid=%s: " fmt, (fs)->sd_fsname, ##__VA_ARGS__) | |
24 | #define fs_err(fs, fmt, ...) \ | |
25 | pr_err("fsid=%s: " fmt, (fs)->sd_fsname, ##__VA_ARGS__) | |
26 | #define fs_info(fs, fmt, ...) \ | |
27 | pr_info("fsid=%s: " fmt, (fs)->sd_fsname, ##__VA_ARGS__) | |
b3b94faa DT |
28 | |
29 | void gfs2_assert_i(struct gfs2_sbd *sdp); | |
30 | ||
31 | #define gfs2_assert(sdp, assertion) \ | |
32 | do { \ | |
33 | if (unlikely(!(assertion))) { \ | |
34 | gfs2_assert_i(sdp); \ | |
1e09ae54 | 35 | BUG(); \ |
b3b94faa DT |
36 | } \ |
37 | } while (0) | |
38 | ||
39 | ||
40 | int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion, | |
41 | const char *function, char *file, unsigned int line); | |
42 | ||
43 | #define gfs2_assert_withdraw(sdp, assertion) \ | |
44 | ((likely(assertion)) ? 0 : gfs2_assert_withdraw_i((sdp), #assertion, \ | |
8e24eea7 | 45 | __func__, __FILE__, __LINE__)) |
b3b94faa DT |
46 | |
47 | ||
48 | int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion, | |
49 | const char *function, char *file, unsigned int line); | |
50 | ||
51 | #define gfs2_assert_warn(sdp, assertion) \ | |
52 | ((likely(assertion)) ? 0 : gfs2_assert_warn_i((sdp), #assertion, \ | |
8e24eea7 | 53 | __func__, __FILE__, __LINE__)) |
b3b94faa DT |
54 | |
55 | ||
56 | int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide, | |
57 | const char *function, char *file, unsigned int line); | |
58 | ||
59 | #define gfs2_consist(sdp) \ | |
8e24eea7 | 60 | gfs2_consist_i((sdp), 0, __func__, __FILE__, __LINE__) |
b3b94faa DT |
61 | |
62 | ||
63 | int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide, | |
64 | const char *function, char *file, unsigned int line); | |
65 | ||
66 | #define gfs2_consist_inode(ip) \ | |
8e24eea7 | 67 | gfs2_consist_inode_i((ip), 0, __func__, __FILE__, __LINE__) |
b3b94faa DT |
68 | |
69 | ||
70 | int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide, | |
71 | const char *function, char *file, unsigned int line); | |
72 | ||
73 | #define gfs2_consist_rgrpd(rgd) \ | |
8e24eea7 | 74 | gfs2_consist_rgrpd_i((rgd), 0, __func__, __FILE__, __LINE__) |
b3b94faa DT |
75 | |
76 | ||
77 | int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, | |
78 | const char *type, const char *function, | |
79 | char *file, unsigned int line); | |
80 | ||
1b8ba31a SW |
81 | static inline int gfs2_meta_check(struct gfs2_sbd *sdp, |
82 | struct buffer_head *bh) | |
b3b94faa DT |
83 | { |
84 | struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data; | |
b44b84d7 | 85 | u32 magic = be32_to_cpu(mh->mh_magic); |
1b8ba31a | 86 | if (unlikely(magic != GFS2_MAGIC)) { |
d77d1b58 | 87 | pr_err("Magic number missing at %llu\n", |
1b8ba31a SW |
88 | (unsigned long long)bh->b_blocknr); |
89 | return -EIO; | |
90 | } | |
b3b94faa DT |
91 | return 0; |
92 | } | |
93 | ||
b3b94faa | 94 | int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, |
cd915493 | 95 | u16 type, u16 t, |
b3b94faa DT |
96 | const char *function, |
97 | char *file, unsigned int line); | |
98 | ||
99 | static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp, | |
100 | struct buffer_head *bh, | |
cd915493 | 101 | u16 type, |
b3b94faa DT |
102 | const char *function, |
103 | char *file, unsigned int line) | |
104 | { | |
105 | struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data; | |
b44b84d7 | 106 | u32 magic = be32_to_cpu(mh->mh_magic); |
cd915493 | 107 | u16 t = be32_to_cpu(mh->mh_type); |
b3b94faa DT |
108 | if (unlikely(magic != GFS2_MAGIC)) |
109 | return gfs2_meta_check_ii(sdp, bh, "magic number", function, | |
110 | file, line); | |
b3b94faa DT |
111 | if (unlikely(t != type)) |
112 | return gfs2_metatype_check_ii(sdp, bh, type, t, function, | |
113 | file, line); | |
114 | return 0; | |
115 | } | |
116 | ||
117 | #define gfs2_metatype_check(sdp, bh, type) \ | |
8e24eea7 | 118 | gfs2_metatype_check_i((sdp), (bh), (type), __func__, __FILE__, __LINE__) |
b3b94faa | 119 | |
cd915493 SW |
120 | static inline void gfs2_metatype_set(struct buffer_head *bh, u16 type, |
121 | u16 format) | |
b3b94faa DT |
122 | { |
123 | struct gfs2_meta_header *mh; | |
124 | mh = (struct gfs2_meta_header *)bh->b_data; | |
e3167ded SW |
125 | mh->mh_type = cpu_to_be32(type); |
126 | mh->mh_format = cpu_to_be32(format); | |
b3b94faa DT |
127 | } |
128 | ||
129 | ||
130 | int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function, | |
131 | char *file, unsigned int line); | |
132 | ||
133 | #define gfs2_io_error(sdp) \ | |
8e24eea7 | 134 | gfs2_io_error_i((sdp), __func__, __FILE__, __LINE__); |
b3b94faa DT |
135 | |
136 | ||
137 | int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh, | |
138 | const char *function, char *file, unsigned int line); | |
139 | ||
140 | #define gfs2_io_error_bh(sdp, bh) \ | |
8e24eea7 | 141 | gfs2_io_error_bh_i((sdp), (bh), __func__, __FILE__, __LINE__); |
b3b94faa DT |
142 | |
143 | ||
e18b890b | 144 | extern struct kmem_cache *gfs2_glock_cachep; |
009d8518 | 145 | extern struct kmem_cache *gfs2_glock_aspace_cachep; |
e18b890b CL |
146 | extern struct kmem_cache *gfs2_inode_cachep; |
147 | extern struct kmem_cache *gfs2_bufdata_cachep; | |
6bdd9be6 | 148 | extern struct kmem_cache *gfs2_rgrpd_cachep; |
37b2c837 | 149 | extern struct kmem_cache *gfs2_quotad_cachep; |
36f5580b | 150 | extern struct kmem_cache *gfs2_rsrv_cachep; |
e8c92ed7 | 151 | extern mempool_t *gfs2_page_pool; |
b3b94faa | 152 | |
b3b94faa DT |
153 | static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt, |
154 | unsigned int *p) | |
155 | { | |
156 | unsigned int x; | |
157 | spin_lock(>->gt_spin); | |
158 | x = *p; | |
159 | spin_unlock(>->gt_spin); | |
160 | return x; | |
161 | } | |
162 | ||
163 | #define gfs2_tune_get(sdp, field) \ | |
164 | gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field) | |
165 | ||
da755fdb | 166 | int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...); |
b3b94faa DT |
167 | |
168 | #endif /* __UTIL_DOT_H__ */ | |
169 |