2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
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.
10 #ifndef __UTIL_DOT_H__
11 #define __UTIL_DOT_H__
13 uint32_t gfs2_disk_hash(const char *data
, int len
);
16 #define fs_printk(level, fs, fmt, arg...) \
17 printk(level "GFS2: fsid=%s: " fmt , (fs)->sd_fsname , ## arg)
19 #define fs_info(fs, fmt, arg...) \
20 fs_printk(KERN_INFO , fs , fmt , ## arg)
22 #define fs_warn(fs, fmt, arg...) \
23 fs_printk(KERN_WARNING , fs , fmt , ## arg)
25 #define fs_err(fs, fmt, arg...) \
26 fs_printk(KERN_ERR, fs , fmt , ## arg)
29 void gfs2_assert_i(struct gfs2_sbd
*sdp
);
31 #define gfs2_assert(sdp, assertion) \
33 if (unlikely(!(assertion))) { \
40 int gfs2_assert_withdraw_i(struct gfs2_sbd
*sdp
, char *assertion
,
41 const char *function
, char *file
, unsigned int line
);
43 #define gfs2_assert_withdraw(sdp, assertion) \
44 ((likely(assertion)) ? 0 : gfs2_assert_withdraw_i((sdp), #assertion, \
45 __FUNCTION__, __FILE__, __LINE__))
48 int gfs2_assert_warn_i(struct gfs2_sbd
*sdp
, char *assertion
,
49 const char *function
, char *file
, unsigned int line
);
51 #define gfs2_assert_warn(sdp, assertion) \
52 ((likely(assertion)) ? 0 : gfs2_assert_warn_i((sdp), #assertion, \
53 __FUNCTION__, __FILE__, __LINE__))
56 int gfs2_consist_i(struct gfs2_sbd
*sdp
, int cluster_wide
,
57 const char *function
, char *file
, unsigned int line
);
59 #define gfs2_consist(sdp) \
60 gfs2_consist_i((sdp), 0, __FUNCTION__, __FILE__, __LINE__)
63 int gfs2_consist_inode_i(struct gfs2_inode
*ip
, int cluster_wide
,
64 const char *function
, char *file
, unsigned int line
);
66 #define gfs2_consist_inode(ip) \
67 gfs2_consist_inode_i((ip), 0, __FUNCTION__, __FILE__, __LINE__)
70 int gfs2_consist_rgrpd_i(struct gfs2_rgrpd
*rgd
, int cluster_wide
,
71 const char *function
, char *file
, unsigned int line
);
73 #define gfs2_consist_rgrpd(rgd) \
74 gfs2_consist_rgrpd_i((rgd), 0, __FUNCTION__, __FILE__, __LINE__)
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
);
81 static inline int gfs2_meta_check_i(struct gfs2_sbd
*sdp
,
82 struct buffer_head
*bh
,
84 char *file
, unsigned int line
)
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
,
95 #define gfs2_meta_check(sdp, bh) \
96 gfs2_meta_check_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__)
99 int 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
);
104 static inline int gfs2_metatype_check_i(struct gfs2_sbd
*sdp
,
105 struct buffer_head
*bh
,
107 const char *function
,
108 char *file
, unsigned int line
)
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
,
118 if (unlikely(t
!= type
))
119 return gfs2_metatype_check_ii(sdp
, bh
, type
, t
, function
,
124 #define gfs2_metatype_check(sdp, bh, type) \
125 gfs2_metatype_check_i((sdp), (bh), (type), __FUNCTION__, __FILE__, __LINE__)
127 static inline void gfs2_metatype_set(struct buffer_head
*bh
, uint16_t type
,
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
);
137 int gfs2_io_error_i(struct gfs2_sbd
*sdp
, const char *function
,
138 char *file
, unsigned int line
);
140 #define gfs2_io_error(sdp) \
141 gfs2_io_error_i((sdp), __FUNCTION__, __FILE__, __LINE__);
144 int gfs2_io_error_bh_i(struct gfs2_sbd
*sdp
, struct buffer_head
*bh
,
145 const char *function
, char *file
, unsigned int line
);
147 #define gfs2_io_error_bh(sdp, bh) \
148 gfs2_io_error_bh_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__);
151 extern kmem_cache_t
*gfs2_glock_cachep
;
152 extern kmem_cache_t
*gfs2_inode_cachep
;
153 extern kmem_cache_t
*gfs2_bufdata_cachep
;
155 struct gfs2_user_buffer
{
156 char __user
*ub_data
;
157 unsigned int ub_size
;
158 unsigned int ub_count
;
161 int gfs2_add_bh_to_ub(struct gfs2_user_buffer
*ub
, struct buffer_head
*bh
);
163 static inline unsigned int gfs2_tune_get_i(struct gfs2_tune
*gt
,
167 spin_lock(>
->gt_spin
);
169 spin_unlock(>
->gt_spin
);
173 #define gfs2_tune_get(sdp, field) \
174 gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
176 void gfs2_icbit_munge(struct gfs2_sbd
*sdp
, unsigned char **bitmap
,
177 unsigned int bit
, int new_value
);
179 #endif /* __UTIL_DOT_H__ */