lops.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. extern const struct gfs2_log_operations gfs2_glock_lops;
  14. extern const struct gfs2_log_operations gfs2_buf_lops;
  15. extern const struct gfs2_log_operations gfs2_revoke_lops;
  16. extern const struct gfs2_log_operations gfs2_rg_lops;
  17. extern const struct gfs2_log_operations gfs2_databuf_lops;
  18. extern const struct gfs2_log_operations *gfs2_log_ops[];
  19. static inline void lops_init_le(struct gfs2_log_element *le,
  20. const struct gfs2_log_operations *lops)
  21. {
  22. INIT_LIST_HEAD(&le->le_list);
  23. le->le_ops = lops;
  24. }
  25. static inline void lops_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
  26. {
  27. if (le->le_ops->lo_add)
  28. le->le_ops->lo_add(sdp, le);
  29. }
  30. static inline void lops_incore_commit(struct gfs2_sbd *sdp,
  31. struct gfs2_trans *tr)
  32. {
  33. int x;
  34. for (x = 0; gfs2_log_ops[x]; x++)
  35. if (gfs2_log_ops[x]->lo_incore_commit)
  36. gfs2_log_ops[x]->lo_incore_commit(sdp, tr);
  37. }
  38. static inline void lops_before_commit(struct gfs2_sbd *sdp)
  39. {
  40. int x;
  41. for (x = 0; gfs2_log_ops[x]; x++)
  42. if (gfs2_log_ops[x]->lo_before_commit)
  43. gfs2_log_ops[x]->lo_before_commit(sdp);
  44. }
  45. static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
  46. {
  47. int x;
  48. for (x = 0; gfs2_log_ops[x]; x++)
  49. if (gfs2_log_ops[x]->lo_after_commit)
  50. gfs2_log_ops[x]->lo_after_commit(sdp, ai);
  51. }
  52. static inline void lops_before_scan(struct gfs2_jdesc *jd,
  53. struct gfs2_log_header *head,
  54. unsigned int pass)
  55. {
  56. int x;
  57. for (x = 0; gfs2_log_ops[x]; x++)
  58. if (gfs2_log_ops[x]->lo_before_scan)
  59. gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
  60. }
  61. static inline int lops_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
  62. struct gfs2_log_descriptor *ld,
  63. __be64 *ptr,
  64. unsigned int pass)
  65. {
  66. int x, error;
  67. for (x = 0; gfs2_log_ops[x]; x++)
  68. if (gfs2_log_ops[x]->lo_scan_elements) {
  69. error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
  70. ld, ptr, pass);
  71. if (error)
  72. return error;
  73. }
  74. return 0;
  75. }
  76. static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
  77. unsigned int pass)
  78. {
  79. int x;
  80. for (x = 0; gfs2_log_ops[x]; x++)
  81. if (gfs2_log_ops[x]->lo_before_scan)
  82. gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
  83. }
  84. #endif /* __LOPS_DOT_H__ */