aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/util.h
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2006-01-16 11:50:04 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2006-01-16 11:50:04 -0500
commitb3b94faa5fe5968827ba0640ee9fba4b3e7f736e (patch)
tree70bd6068b050d2c46e338484f8b03fae4365c6c3 /fs/gfs2/util.h
parentf7825dcf8c7301cfd3724eb40c5b443cc85ab7b8 (diff)
[GFS2] The core of GFS2
This patch contains all the core files for GFS2. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/util.h')
-rw-r--r--fs/gfs2/util.h180
1 files changed, 180 insertions, 0 deletions
diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h
new file mode 100644
index 000000000000..21466fe9bf43
--- /dev/null
+++ b/fs/gfs2/util.h
@@ -0,0 +1,180 @@
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
13uint32_t gfs2_disk_hash(const char *data, int len);
14
15
16#define fs_printk(level, fs, fmt, arg...) \
17 printk(level "GFS2: fsid=%s: " fmt , (fs)->sd_fsname , ## arg)
18
19#define fs_info(fs, fmt, arg...) \
20 fs_printk(KERN_INFO , fs , fmt , ## arg)
21
22#define fs_warn(fs, fmt, arg...) \
23 fs_printk(KERN_WARNING , fs , fmt , ## arg)
24
25#define fs_err(fs, fmt, arg...) \
26 fs_printk(KERN_ERR, fs , fmt , ## arg)
27
28
29void gfs2_assert_i(struct gfs2_sbd *sdp);
30
31#define gfs2_assert(sdp, assertion) \
32do { \
33 if (unlikely(!(assertion))) { \
34 gfs2_assert_i(sdp); \
35 BUG(); \
36 } \
37} while (0)
38
39
40int 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, \
45 __FUNCTION__, __FILE__, __LINE__))
46
47
48int 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, \
53 __FUNCTION__, __FILE__, __LINE__))
54
55
56int 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) \
60gfs2_consist_i((sdp), 0, __FUNCTION__, __FILE__, __LINE__)
61
62
63int 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) \
67gfs2_consist_inode_i((ip), 0, __FUNCTION__, __FILE__, __LINE__)
68
69
70int 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) \
74gfs2_consist_rgrpd_i((rgd), 0, __FUNCTION__, __FILE__, __LINE__)
75
76
77int 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
81static inline int gfs2_meta_check_i(struct gfs2_sbd *sdp,
82 struct buffer_head *bh,
83 const char *function,
84 char *file, unsigned int line)
85{
86 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
87 uint32_t magic = mh->mh_magic;
88 magic = be32_to_cpu(magic);
89 if (unlikely(magic != GFS2_MAGIC))
90 return gfs2_meta_check_ii(sdp, bh, "magic number", function,
91 file, line);
92 return 0;
93}
94
95#define gfs2_meta_check(sdp, bh) \
96gfs2_meta_check_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__)
97
98
99int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
100 uint16_t type, uint16_t t,
101 const char *function,
102 char *file, unsigned int line);
103
104static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
105 struct buffer_head *bh,
106 uint16_t type,
107 const char *function,
108 char *file, unsigned int line)
109{
110 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
111 uint32_t magic = mh->mh_magic;
112 uint16_t t = mh->mh_type;
113 magic = be32_to_cpu(magic);
114 if (unlikely(magic != GFS2_MAGIC))
115 return gfs2_meta_check_ii(sdp, bh, "magic number", function,
116 file, line);
117 t = be16_to_cpu(t);
118 if (unlikely(t != type))
119 return gfs2_metatype_check_ii(sdp, bh, type, t, function,
120 file, line);
121 return 0;
122}
123
124#define gfs2_metatype_check(sdp, bh, type) \
125gfs2_metatype_check_i((sdp), (bh), (type), __FUNCTION__, __FILE__, __LINE__)
126
127static inline void gfs2_metatype_set(struct buffer_head *bh, uint16_t type,
128 uint16_t format)
129{
130 struct gfs2_meta_header *mh;
131 mh = (struct gfs2_meta_header *)bh->b_data;
132 mh->mh_type = cpu_to_be16(type);
133 mh->mh_format = cpu_to_be16(format);
134}
135
136
137int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function,
138 char *file, unsigned int line);
139
140#define gfs2_io_error(sdp) \
141gfs2_io_error_i((sdp), __FUNCTION__, __FILE__, __LINE__);
142
143
144int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
145 const char *function, char *file, unsigned int line);
146
147#define gfs2_io_error_bh(sdp, bh) \
148gfs2_io_error_bh_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__);
149
150
151extern kmem_cache_t *gfs2_glock_cachep;
152extern kmem_cache_t *gfs2_inode_cachep;
153extern kmem_cache_t *gfs2_bufdata_cachep;
154
155struct gfs2_user_buffer {
156 char __user *ub_data;
157 unsigned int ub_size;
158 unsigned int ub_count;
159};
160
161int gfs2_add_bh_to_ub(struct gfs2_user_buffer *ub, struct buffer_head *bh);
162
163static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
164 unsigned int *p)
165{
166 unsigned int x;
167 spin_lock(&gt->gt_spin);
168 x = *p;
169 spin_unlock(&gt->gt_spin);
170 return x;
171}
172
173#define gfs2_tune_get(sdp, field) \
174gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
175
176void gfs2_icbit_munge(struct gfs2_sbd *sdp, unsigned char **bitmap,
177 unsigned int bit, int new_value);
178
179#endif /* __UTIL_DOT_H__ */
180