0001
0002
0003
0004
0005
0006
0007 #ifndef __UTIL_DOT_H__
0008 #define __UTIL_DOT_H__
0009
0010 #ifdef pr_fmt
0011 #undef pr_fmt
0012 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0013 #endif
0014
0015 #include <linux/mempool.h>
0016
0017 #include "incore.h"
0018
0019 #define fs_emerg(fs, fmt, ...) \
0020 pr_emerg("fsid=%s: " fmt, (fs)->sd_fsname, ##__VA_ARGS__)
0021 #define fs_warn(fs, fmt, ...) \
0022 pr_warn("fsid=%s: " fmt, (fs)->sd_fsname, ##__VA_ARGS__)
0023 #define fs_err(fs, fmt, ...) \
0024 pr_err("fsid=%s: " fmt, (fs)->sd_fsname, ##__VA_ARGS__)
0025 #define fs_info(fs, fmt, ...) \
0026 pr_info("fsid=%s: " fmt, (fs)->sd_fsname, ##__VA_ARGS__)
0027
0028 void gfs2_assert_i(struct gfs2_sbd *sdp);
0029
0030 #define gfs2_assert(sdp, assertion) \
0031 do { \
0032 if (unlikely(!(assertion))) { \
0033 gfs2_assert_i(sdp); \
0034 BUG(); \
0035 } \
0036 } while (0)
0037
0038
0039 void gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
0040 const char *function, char *file, unsigned int line,
0041 bool delayed);
0042
0043 #define gfs2_assert_withdraw(sdp, assertion) \
0044 ({ \
0045 bool _bool = (assertion); \
0046 if (unlikely(!_bool)) \
0047 gfs2_assert_withdraw_i((sdp), #assertion, \
0048 __func__, __FILE__, __LINE__, false); \
0049 !_bool; \
0050 })
0051
0052 #define gfs2_assert_withdraw_delayed(sdp, assertion) \
0053 ({ \
0054 bool _bool = (assertion); \
0055 if (unlikely(!_bool)) \
0056 gfs2_assert_withdraw_i((sdp), #assertion, \
0057 __func__, __FILE__, __LINE__, true); \
0058 !_bool; \
0059 })
0060
0061 void gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
0062 const char *function, char *file, unsigned int line);
0063
0064 #define gfs2_assert_warn(sdp, assertion) \
0065 ({ \
0066 bool _bool = (assertion); \
0067 if (unlikely(!_bool)) \
0068 gfs2_assert_warn_i((sdp), #assertion, \
0069 __func__, __FILE__, __LINE__); \
0070 !_bool; \
0071 })
0072
0073 void gfs2_consist_i(struct gfs2_sbd *sdp,
0074 const char *function, char *file, unsigned int line);
0075
0076 #define gfs2_consist(sdp) \
0077 gfs2_consist_i((sdp), __func__, __FILE__, __LINE__)
0078
0079
0080 void gfs2_consist_inode_i(struct gfs2_inode *ip,
0081 const char *function, char *file, unsigned int line);
0082
0083 #define gfs2_consist_inode(ip) \
0084 gfs2_consist_inode_i((ip), __func__, __FILE__, __LINE__)
0085
0086
0087 void gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd,
0088 const char *function, char *file, unsigned int line);
0089
0090 #define gfs2_consist_rgrpd(rgd) \
0091 gfs2_consist_rgrpd_i((rgd), __func__, __FILE__, __LINE__)
0092
0093
0094 int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
0095 const char *type, const char *function,
0096 char *file, unsigned int line);
0097
0098 static inline int gfs2_meta_check(struct gfs2_sbd *sdp,
0099 struct buffer_head *bh)
0100 {
0101 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
0102 u32 magic = be32_to_cpu(mh->mh_magic);
0103 if (unlikely(magic != GFS2_MAGIC)) {
0104 fs_err(sdp, "Magic number missing at %llu\n",
0105 (unsigned long long)bh->b_blocknr);
0106 return -EIO;
0107 }
0108 return 0;
0109 }
0110
0111 int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
0112 u16 type, u16 t,
0113 const char *function,
0114 char *file, unsigned int line);
0115
0116 static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
0117 struct buffer_head *bh,
0118 u16 type,
0119 const char *function,
0120 char *file, unsigned int line)
0121 {
0122 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
0123 u32 magic = be32_to_cpu(mh->mh_magic);
0124 u16 t = be32_to_cpu(mh->mh_type);
0125 if (unlikely(magic != GFS2_MAGIC))
0126 return gfs2_meta_check_ii(sdp, bh, "magic number", function,
0127 file, line);
0128 if (unlikely(t != type))
0129 return gfs2_metatype_check_ii(sdp, bh, type, t, function,
0130 file, line);
0131 return 0;
0132 }
0133
0134 #define gfs2_metatype_check(sdp, bh, type) \
0135 gfs2_metatype_check_i((sdp), (bh), (type), __func__, __FILE__, __LINE__)
0136
0137 static inline void gfs2_metatype_set(struct buffer_head *bh, u16 type,
0138 u16 format)
0139 {
0140 struct gfs2_meta_header *mh;
0141 mh = (struct gfs2_meta_header *)bh->b_data;
0142 mh->mh_type = cpu_to_be32(type);
0143 mh->mh_format = cpu_to_be32(format);
0144 }
0145
0146
0147 int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function,
0148 char *file, unsigned int line);
0149
0150 extern int check_journal_clean(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
0151 bool verbose);
0152 extern int gfs2_freeze_lock(struct gfs2_sbd *sdp,
0153 struct gfs2_holder *freeze_gh, int caller_flags);
0154 extern void gfs2_freeze_unlock(struct gfs2_holder *freeze_gh);
0155
0156 #define gfs2_io_error(sdp) \
0157 gfs2_io_error_i((sdp), __func__, __FILE__, __LINE__)
0158
0159
0160 void gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
0161 const char *function, char *file, unsigned int line,
0162 bool withdraw);
0163
0164 #define gfs2_io_error_bh_wd(sdp, bh) \
0165 gfs2_io_error_bh_i((sdp), (bh), __func__, __FILE__, __LINE__, true)
0166
0167 #define gfs2_io_error_bh(sdp, bh) \
0168 gfs2_io_error_bh_i((sdp), (bh), __func__, __FILE__, __LINE__, false)
0169
0170
0171 extern struct kmem_cache *gfs2_glock_cachep;
0172 extern struct kmem_cache *gfs2_glock_aspace_cachep;
0173 extern struct kmem_cache *gfs2_inode_cachep;
0174 extern struct kmem_cache *gfs2_bufdata_cachep;
0175 extern struct kmem_cache *gfs2_rgrpd_cachep;
0176 extern struct kmem_cache *gfs2_quotad_cachep;
0177 extern struct kmem_cache *gfs2_qadata_cachep;
0178 extern struct kmem_cache *gfs2_trans_cachep;
0179 extern mempool_t *gfs2_page_pool;
0180 extern struct workqueue_struct *gfs2_control_wq;
0181
0182 static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
0183 unsigned int *p)
0184 {
0185 unsigned int x;
0186 spin_lock(>->gt_spin);
0187 x = *p;
0188 spin_unlock(>->gt_spin);
0189 return x;
0190 }
0191
0192
0193
0194
0195
0196 static inline void gfs2_withdraw_delayed(struct gfs2_sbd *sdp)
0197 {
0198 set_bit(SDF_WITHDRAWING, &sdp->sd_flags);
0199 }
0200
0201
0202
0203
0204
0205 static inline bool gfs2_withdrawn(struct gfs2_sbd *sdp)
0206 {
0207 return test_bit(SDF_WITHDRAWN, &sdp->sd_flags) ||
0208 test_bit(SDF_WITHDRAWING, &sdp->sd_flags);
0209 }
0210
0211
0212
0213
0214
0215 static inline bool gfs2_withdrawing(struct gfs2_sbd *sdp)
0216 {
0217 return test_bit(SDF_WITHDRAWING, &sdp->sd_flags) &&
0218 !test_bit(SDF_WITHDRAWN, &sdp->sd_flags);
0219 }
0220
0221 static inline bool gfs2_withdraw_in_prog(struct gfs2_sbd *sdp)
0222 {
0223 return test_bit(SDF_WITHDRAW_IN_PROG, &sdp->sd_flags);
0224 }
0225
0226 #define gfs2_tune_get(sdp, field) \
0227 gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
0228
0229 __printf(2, 3)
0230 void gfs2_lm(struct gfs2_sbd *sdp, const char *fmt, ...);
0231 int gfs2_withdraw(struct gfs2_sbd *sdp);
0232
0233 #endif