lops.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. extern void gfs2_log_write_page(struct gfs2_sbd *sdp, struct page *page);
  26. extern void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int rw);
  27. static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
  28. {
  29. unsigned int limit;
  30. limit = (sdp->sd_sb.sb_bsize - BUF_OFFSET) / sizeof(__be64);
  31. return limit;
  32. }
  33. static inline unsigned int databuf_limit(struct gfs2_sbd *sdp)
  34. {
  35. unsigned int limit;
  36. limit = (sdp->sd_sb.sb_bsize - DATABUF_OFFSET) / (2 * sizeof(__be64));
  37. return limit;
  38. }
  39. static inline void lops_init_le(struct gfs2_bufdata *bd,
  40. const struct gfs2_log_operations *lops)
  41. {
  42. INIT_LIST_HEAD(&bd->bd_list);
  43. bd->bd_ops = lops;
  44. }
  45. static inline void lops_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
  46. {
  47. if (bd->bd_ops->lo_add)
  48. bd->bd_ops->lo_add(sdp, bd);
  49. }
  50. static inline void lops_before_commit(struct gfs2_sbd *sdp)
  51. {
  52. int x;
  53. for (x = 0; gfs2_log_ops[x]; x++)
  54. if (gfs2_log_ops[x]->lo_before_commit)
  55. gfs2_log_ops[x]->lo_before_commit(sdp);
  56. }
  57. static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
  58. {
  59. int x;
  60. for (x = 0; gfs2_log_ops[x]; x++)
  61. if (gfs2_log_ops[x]->lo_after_commit)
  62. gfs2_log_ops[x]->lo_after_commit(sdp, ai);
  63. }
  64. static inline void lops_before_scan(struct gfs2_jdesc *jd,
  65. struct gfs2_log_header_host *head,
  66. unsigned int pass)
  67. {
  68. int x;
  69. for (x = 0; gfs2_log_ops[x]; x++)
  70. if (gfs2_log_ops[x]->lo_before_scan)
  71. gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
  72. }
  73. static inline int lops_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
  74. struct gfs2_log_descriptor *ld,
  75. __be64 *ptr,
  76. unsigned int pass)
  77. {
  78. int x, error;
  79. for (x = 0; gfs2_log_ops[x]; x++)
  80. if (gfs2_log_ops[x]->lo_scan_elements) {
  81. error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
  82. ld, ptr, pass);
  83. if (error)
  84. return error;
  85. }
  86. return 0;
  87. }
  88. static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
  89. unsigned int pass)
  90. {
  91. int x;
  92. for (x = 0; gfs2_log_ops[x]; x++)
  93. if (gfs2_log_ops[x]->lo_before_scan)
  94. gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
  95. }
  96. #endif /* __LOPS_DOT_H__ */