lops.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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_init_le(struct gfs2_bufdata *bd,
  41. const struct gfs2_log_operations *lops)
  42. {
  43. INIT_LIST_HEAD(&bd->bd_list);
  44. bd->bd_ops = lops;
  45. }
  46. static inline void lops_before_commit(struct gfs2_sbd *sdp)
  47. {
  48. int x;
  49. for (x = 0; gfs2_log_ops[x]; x++)
  50. if (gfs2_log_ops[x]->lo_before_commit)
  51. gfs2_log_ops[x]->lo_before_commit(sdp);
  52. }
  53. static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
  54. {
  55. int x;
  56. for (x = 0; gfs2_log_ops[x]; x++)
  57. if (gfs2_log_ops[x]->lo_after_commit)
  58. gfs2_log_ops[x]->lo_after_commit(sdp, ai);
  59. }
  60. static inline void lops_before_scan(struct gfs2_jdesc *jd,
  61. struct gfs2_log_header_host *head,
  62. unsigned int pass)
  63. {
  64. int x;
  65. for (x = 0; gfs2_log_ops[x]; x++)
  66. if (gfs2_log_ops[x]->lo_before_scan)
  67. gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
  68. }
  69. static inline int lops_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
  70. struct gfs2_log_descriptor *ld,
  71. __be64 *ptr,
  72. unsigned int pass)
  73. {
  74. int x, error;
  75. for (x = 0; gfs2_log_ops[x]; x++)
  76. if (gfs2_log_ops[x]->lo_scan_elements) {
  77. error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
  78. ld, ptr, pass);
  79. if (error)
  80. return error;
  81. }
  82. return 0;
  83. }
  84. static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
  85. unsigned int pass)
  86. {
  87. int x;
  88. for (x = 0; gfs2_log_ops[x]; x++)
  89. if (gfs2_log_ops[x]->lo_before_scan)
  90. gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
  91. }
  92. #endif /* __LOPS_DOT_H__ */