lops.h 3.0 KB

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