lops.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
  28. static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
  29. {
  30. unsigned int limit;
  31. limit = (sdp->sd_sb.sb_bsize - BUF_OFFSET) / sizeof(__be64);
  32. return limit;
  33. }
  34. static inline unsigned int databuf_limit(struct gfs2_sbd *sdp)
  35. {
  36. unsigned int limit;
  37. limit = (sdp->sd_sb.sb_bsize - DATABUF_OFFSET) / (2 * sizeof(__be64));
  38. return limit;
  39. }
  40. static inline void lops_before_commit(struct gfs2_sbd *sdp)
  41. {
  42. int x;
  43. for (x = 0; gfs2_log_ops[x]; x++)
  44. if (gfs2_log_ops[x]->lo_before_commit)
  45. gfs2_log_ops[x]->lo_before_commit(sdp);
  46. }
  47. static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
  48. {
  49. int x;
  50. for (x = 0; gfs2_log_ops[x]; x++)
  51. if (gfs2_log_ops[x]->lo_after_commit)
  52. gfs2_log_ops[x]->lo_after_commit(sdp, ai);
  53. }
  54. static inline void lops_before_scan(struct gfs2_jdesc *jd,
  55. struct gfs2_log_header_host *head,
  56. unsigned int pass)
  57. {
  58. int x;
  59. for (x = 0; gfs2_log_ops[x]; x++)
  60. if (gfs2_log_ops[x]->lo_before_scan)
  61. gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
  62. }
  63. static inline int lops_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
  64. struct gfs2_log_descriptor *ld,
  65. __be64 *ptr,
  66. unsigned int pass)
  67. {
  68. int x, error;
  69. for (x = 0; gfs2_log_ops[x]; x++)
  70. if (gfs2_log_ops[x]->lo_scan_elements) {
  71. error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
  72. ld, ptr, pass);
  73. if (error)
  74. return error;
  75. }
  76. return 0;
  77. }
  78. static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
  79. unsigned int pass)
  80. {
  81. int x;
  82. for (x = 0; gfs2_log_ops[x]; x++)
  83. if (gfs2_log_ops[x]->lo_before_scan)
  84. gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
  85. }
  86. #endif /* __LOPS_DOT_H__ */