lops.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  3. * Copyright (C) 2004-2008 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_before_commit(struct gfs2_sbd *sdp)
  49. {
  50. int x;
  51. for (x = 0; gfs2_log_ops[x]; x++)
  52. if (gfs2_log_ops[x]->lo_before_commit)
  53. gfs2_log_ops[x]->lo_before_commit(sdp);
  54. }
  55. static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
  56. {
  57. int x;
  58. for (x = 0; gfs2_log_ops[x]; x++)
  59. if (gfs2_log_ops[x]->lo_after_commit)
  60. gfs2_log_ops[x]->lo_after_commit(sdp, ai);
  61. }
  62. static inline void lops_before_scan(struct gfs2_jdesc *jd,
  63. struct gfs2_log_header_host *head,
  64. unsigned int pass)
  65. {
  66. int x;
  67. for (x = 0; gfs2_log_ops[x]; x++)
  68. if (gfs2_log_ops[x]->lo_before_scan)
  69. gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
  70. }
  71. static inline int lops_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
  72. struct gfs2_log_descriptor *ld,
  73. __be64 *ptr,
  74. unsigned int pass)
  75. {
  76. int x, error;
  77. for (x = 0; gfs2_log_ops[x]; x++)
  78. if (gfs2_log_ops[x]->lo_scan_elements) {
  79. error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
  80. ld, ptr, pass);
  81. if (error)
  82. return error;
  83. }
  84. return 0;
  85. }
  86. static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
  87. unsigned int pass)
  88. {
  89. int x;
  90. for (x = 0; gfs2_log_ops[x]; x++)
  91. if (gfs2_log_ops[x]->lo_before_scan)
  92. gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
  93. }
  94. #endif /* __LOPS_DOT_H__ */