/fs/gfs2/util.h

https://bitbucket.org/ysat0/linux · C Header · 172 lines · 119 code · 45 blank · 8 comment · 8 complexity · 970e56a9b20b7f8194ce7b5e7e06ad73 MD5 · raw file

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