lops.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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_databuf_lops;
  23. extern const struct gfs2_log_operations *gfs2_log_ops[];
  24. extern void gfs2_log_write_page(struct gfs2_sbd *sdp, struct page *page);
  25. extern void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int rw);
  26. extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
  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_before_commit(struct gfs2_sbd *sdp,
  40. struct gfs2_trans *tr)
  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, tr);
  46. }
  47. static inline void lops_after_commit(struct gfs2_sbd *sdp,
  48. struct gfs2_trans *tr)
  49. {
  50. int x;
  51. for (x = 0; gfs2_log_ops[x]; x++)
  52. if (gfs2_log_ops[x]->lo_after_commit)
  53. gfs2_log_ops[x]->lo_after_commit(sdp, tr);
  54. }
  55. static inline void lops_before_scan(struct gfs2_jdesc *jd,
  56. struct gfs2_log_header_host *head,
  57. unsigned int pass)
  58. {
  59. int x;
  60. for (x = 0; gfs2_log_ops[x]; x++)
  61. if (gfs2_log_ops[x]->lo_before_scan)
  62. gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
  63. }
  64. static inline int lops_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
  65. struct gfs2_log_descriptor *ld,
  66. __be64 *ptr,
  67. unsigned int pass)
  68. {
  69. int x, error;
  70. for (x = 0; gfs2_log_ops[x]; x++)
  71. if (gfs2_log_ops[x]->lo_scan_elements) {
  72. error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
  73. ld, ptr, pass);
  74. if (error)
  75. return error;
  76. }
  77. return 0;
  78. }
  79. static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
  80. unsigned int pass)
  81. {
  82. int x;
  83. for (x = 0; gfs2_log_ops[x]; x++)
  84. if (gfs2_log_ops[x]->lo_before_scan)
  85. gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
  86. }
  87. #endif /* __LOPS_DOT_H__ */