util.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  3. * Copyright (C) 2004-2006 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 version 2.
  8. */
  9. #ifndef __UTIL_DOT_H__
  10. #define __UTIL_DOT_H__
  11. #include "incore.h"
  12. #define fs_printk(level, fs, fmt, arg...) \
  13. printk(level "GFS2: fsid=%s: " fmt , (fs)->sd_fsname , ## arg)
  14. #define fs_info(fs, fmt, arg...) \
  15. fs_printk(KERN_INFO , fs , fmt , ## arg)
  16. #define fs_warn(fs, fmt, arg...) \
  17. fs_printk(KERN_WARNING , fs , fmt , ## arg)
  18. #define fs_err(fs, fmt, arg...) \
  19. fs_printk(KERN_ERR, fs , fmt , ## arg)
  20. void gfs2_assert_i(struct gfs2_sbd *sdp);
  21. #define gfs2_assert(sdp, assertion) \
  22. do { \
  23. if (unlikely(!(assertion))) { \
  24. gfs2_assert_i(sdp); \
  25. BUG(); \
  26. } \
  27. } while (0)
  28. int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
  29. const char *function, char *file, unsigned int line);
  30. #define gfs2_assert_withdraw(sdp, assertion) \
  31. ((likely(assertion)) ? 0 : gfs2_assert_withdraw_i((sdp), #assertion, \
  32. __func__, __FILE__, __LINE__))
  33. int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
  34. const char *function, char *file, unsigned int line);
  35. #define gfs2_assert_warn(sdp, assertion) \
  36. ((likely(assertion)) ? 0 : gfs2_assert_warn_i((sdp), #assertion, \
  37. __func__, __FILE__, __LINE__))
  38. int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide,
  39. const char *function, char *file, unsigned int line);
  40. #define gfs2_consist(sdp) \
  41. gfs2_consist_i((sdp), 0, __func__, __FILE__, __LINE__)
  42. int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide,
  43. const char *function, char *file, unsigned int line);
  44. #define gfs2_consist_inode(ip) \
  45. gfs2_consist_inode_i((ip), 0, __func__, __FILE__, __LINE__)
  46. int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide,
  47. const char *function, char *file, unsigned int line);
  48. #define gfs2_consist_rgrpd(rgd) \
  49. gfs2_consist_rgrpd_i((rgd), 0, __func__, __FILE__, __LINE__)
  50. int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
  51. const char *type, const char *function,
  52. char *file, unsigned int line);
  53. static inline int gfs2_meta_check_i(struct gfs2_sbd *sdp,
  54. struct buffer_head *bh,
  55. const char *function,
  56. char *file, unsigned int line)
  57. {
  58. struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
  59. u32 magic = be32_to_cpu(mh->mh_magic);
  60. if (unlikely(magic != GFS2_MAGIC))
  61. return gfs2_meta_check_ii(sdp, bh, "magic number", function,
  62. file, line);
  63. return 0;
  64. }
  65. #define gfs2_meta_check(sdp, bh) \
  66. gfs2_meta_check_i((sdp), (bh), __func__, __FILE__, __LINE__)
  67. int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
  68. u16 type, u16 t,
  69. const char *function,
  70. char *file, unsigned int line);
  71. static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
  72. struct buffer_head *bh,
  73. u16 type,
  74. const char *function,
  75. char *file, unsigned int line)
  76. {
  77. struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
  78. u32 magic = be32_to_cpu(mh->mh_magic);
  79. u16 t = be32_to_cpu(mh->mh_type);
  80. if (unlikely(magic != GFS2_MAGIC))
  81. return gfs2_meta_check_ii(sdp, bh, "magic number", function,
  82. file, line);
  83. if (unlikely(t != type))
  84. return gfs2_metatype_check_ii(sdp, bh, type, t, function,
  85. file, line);
  86. return 0;
  87. }
  88. #define gfs2_metatype_check(sdp, bh, type) \
  89. gfs2_metatype_check_i((sdp), (bh), (type), __func__, __FILE__, __LINE__)
  90. static inline void gfs2_metatype_set(struct buffer_head *bh, u16 type,
  91. u16 format)
  92. {
  93. struct gfs2_meta_header *mh;
  94. mh = (struct gfs2_meta_header *)bh->b_data;
  95. mh->mh_type = cpu_to_be32(type);
  96. mh->mh_format = cpu_to_be32(format);
  97. }
  98. int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function,
  99. char *file, unsigned int line);
  100. #define gfs2_io_error(sdp) \
  101. gfs2_io_error_i((sdp), __func__, __FILE__, __LINE__);
  102. int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
  103. const char *function, char *file, unsigned int line);
  104. #define gfs2_io_error_bh(sdp, bh) \
  105. gfs2_io_error_bh_i((sdp), (bh), __func__, __FILE__, __LINE__);
  106. extern struct kmem_cache *gfs2_glock_cachep;
  107. extern struct kmem_cache *gfs2_glock_aspace_cachep;
  108. extern struct kmem_cache *gfs2_inode_cachep;
  109. extern struct kmem_cache *gfs2_bufdata_cachep;
  110. extern struct kmem_cache *gfs2_rgrpd_cachep;
  111. extern struct kmem_cache *gfs2_quotad_cachep;
  112. static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
  113. unsigned int *p)
  114. {
  115. unsigned int x;
  116. spin_lock(&gt->gt_spin);
  117. x = *p;
  118. spin_unlock(&gt->gt_spin);
  119. return x;
  120. }
  121. #define gfs2_tune_get(sdp, field) \
  122. gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
  123. void gfs2_icbit_munge(struct gfs2_sbd *sdp, unsigned char **bitmap,
  124. unsigned int bit, int new_value);
  125. int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...);
  126. #endif /* __UTIL_DOT_H__ */