lops.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 __LOPS_DOT_H__
  10. #define __LOPS_DOT_H__
  11. #include <linux/list.h>
  12. #include "incore.h"
  13. #define BUF_OFFSET \
  14. ((sizeof(struct gfs2_log_descriptor) + sizeof(__be64) - 1) & \
  15. ~(sizeof(__be64) - 1))
  16. #define DATABUF_OFFSET \
  17. ((sizeof(struct gfs2_log_descriptor) + (2 * sizeof(__be64) - 1)) & \
  18. ~(2 * sizeof(__be64) - 1))
  19. extern const struct gfs2_log_operations gfs2_glock_lops;
  20. extern const struct gfs2_log_operations gfs2_buf_lops;
  21. extern const struct gfs2_log_operations gfs2_revoke_lops;
  22. extern const struct gfs2_log_operations gfs2_rg_lops;
  23. extern const struct gfs2_log_operations gfs2_databuf_lops;
  24. extern const struct gfs2_log_operations *gfs2_log_ops[];
  25. static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
  26. {
  27. unsigned int limit;
  28. limit = (sdp->sd_sb.sb_bsize - BUF_OFFSET) / sizeof(__be64);
  29. return limit;
  30. }
  31. static inline unsigned int databuf_limit(struct gfs2_sbd *sdp)
  32. {
  33. unsigned int limit;
  34. limit = (sdp->sd_sb.sb_bsize - DATABUF_OFFSET) / (2 * sizeof(__be64));
  35. return limit;
  36. }
  37. static inline void lops_init_le(struct gfs2_log_element *le,
  38. const struct gfs2_log_operations *lops)
  39. {
  40. INIT_LIST_HEAD(&le->le_list);
  41. le->le_ops = lops;
  42. }
  43. static inline void lops_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
  44. {
  45. if (le->le_ops->lo_add)
  46. le->le_ops->lo_add(sdp, le);
  47. }
  48. static inline void lops_incore_commit(struct gfs2_sbd *sdp,
  49. struct gfs2_trans *tr)
  50. {
  51. int x;
  52. for (x = 0; gfs2_log_ops[x]; x++)
  53. if (gfs2_log_ops[x]->lo_incore_commit)
  54. gfs2_log_ops[x]->lo_incore_commit(sdp, tr);
  55. }
  56. static inline void lops_before_commit(struct gfs2_sbd *sdp)
  57. {
  58. int x;
  59. for (x = 0; gfs2_log_ops[x]; x++)
  60. if (gfs2_log_ops[x]->lo_before_commit)
  61. gfs2_log_ops[x]->lo_before_commit(sdp);
  62. }
  63. static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
  64. {
  65. int x;
  66. for (x = 0; gfs2_log_ops[x]; x++)
  67. if (gfs2_log_ops[x]->lo_after_commit)
  68. gfs2_log_ops[x]->lo_after_commit(sdp, ai);
  69. }
  70. static inline void lops_before_scan(struct gfs2_jdesc *jd,
  71. struct gfs2_log_header_host *head,
  72. unsigned int pass)
  73. {
  74. int x;
  75. for (x = 0; gfs2_log_ops[x]; x++)
  76. if (gfs2_log_ops[x]->lo_before_scan)
  77. gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
  78. }
  79. static inline int lops_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
  80. struct gfs2_log_descriptor *ld,
  81. __be64 *ptr,
  82. unsigned int pass)
  83. {
  84. int x, error;
  85. for (x = 0; gfs2_log_ops[x]; x++)
  86. if (gfs2_log_ops[x]->lo_scan_elements) {
  87. error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
  88. ld, ptr, pass);
  89. if (error)
  90. return error;
  91. }
  92. return 0;
  93. }
  94. static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
  95. unsigned int pass)
  96. {
  97. int x;
  98. for (x = 0; gfs2_log_ops[x]; x++)
  99. if (gfs2_log_ops[x]->lo_before_scan)
  100. gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
  101. }
  102. #endif /* __LOPS_DOT_H__ */