1b3b94faaSDavid Teigland /* 2b3b94faaSDavid Teigland * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 33a8a9a10SSteven Whitehouse * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 4b3b94faaSDavid Teigland * 5b3b94faaSDavid Teigland * This copyrighted material is made available to anyone wishing to use, 6b3b94faaSDavid Teigland * modify, copy, or redistribute it subject to the terms and conditions 7e9fc2aa0SSteven Whitehouse * of the GNU General Public License version 2. 8b3b94faaSDavid Teigland */ 9b3b94faaSDavid Teigland 10b3b94faaSDavid Teigland #ifndef __LOPS_DOT_H__ 11b3b94faaSDavid Teigland #define __LOPS_DOT_H__ 12b3b94faaSDavid Teigland 13f2f7ba52SSteven Whitehouse #include <linux/list.h> 14f2f7ba52SSteven Whitehouse #include "incore.h" 15f2f7ba52SSteven Whitehouse 16*2332c443SRobert Peterson #define BUF_OFFSET \ 17*2332c443SRobert Peterson ((sizeof(struct gfs2_log_descriptor) + sizeof(__be64) - 1) & \ 18*2332c443SRobert Peterson ~(sizeof(__be64) - 1)) 19*2332c443SRobert Peterson #define DATABUF_OFFSET \ 20*2332c443SRobert Peterson ((sizeof(struct gfs2_log_descriptor) + (2 * sizeof(__be64) - 1)) & \ 21*2332c443SRobert Peterson ~(2 * sizeof(__be64) - 1)) 22*2332c443SRobert Peterson 23b09e593dSSteven Whitehouse extern const struct gfs2_log_operations gfs2_glock_lops; 24b09e593dSSteven Whitehouse extern const struct gfs2_log_operations gfs2_buf_lops; 25b09e593dSSteven Whitehouse extern const struct gfs2_log_operations gfs2_revoke_lops; 26b09e593dSSteven Whitehouse extern const struct gfs2_log_operations gfs2_rg_lops; 27b09e593dSSteven Whitehouse extern const struct gfs2_log_operations gfs2_databuf_lops; 28b3b94faaSDavid Teigland 29b09e593dSSteven Whitehouse extern const struct gfs2_log_operations *gfs2_log_ops[]; 30b3b94faaSDavid Teigland 31*2332c443SRobert Peterson static inline unsigned int buf_limit(struct gfs2_sbd *sdp) 32*2332c443SRobert Peterson { 33*2332c443SRobert Peterson unsigned int limit; 34*2332c443SRobert Peterson 35*2332c443SRobert Peterson limit = (sdp->sd_sb.sb_bsize - BUF_OFFSET) / sizeof(__be64); 36*2332c443SRobert Peterson return limit; 37*2332c443SRobert Peterson } 38*2332c443SRobert Peterson 39*2332c443SRobert Peterson static inline unsigned int databuf_limit(struct gfs2_sbd *sdp) 40*2332c443SRobert Peterson { 41*2332c443SRobert Peterson unsigned int limit; 42*2332c443SRobert Peterson 43*2332c443SRobert Peterson limit = (sdp->sd_sb.sb_bsize - DATABUF_OFFSET) / (2 * sizeof(__be64)); 44*2332c443SRobert Peterson return limit; 45*2332c443SRobert Peterson } 46*2332c443SRobert Peterson 47b3b94faaSDavid Teigland static inline void lops_init_le(struct gfs2_log_element *le, 48b09e593dSSteven Whitehouse const struct gfs2_log_operations *lops) 49b3b94faaSDavid Teigland { 50b3b94faaSDavid Teigland INIT_LIST_HEAD(&le->le_list); 51b3b94faaSDavid Teigland le->le_ops = lops; 52b3b94faaSDavid Teigland } 53b3b94faaSDavid Teigland 54b3b94faaSDavid Teigland static inline void lops_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) 55b3b94faaSDavid Teigland { 56b3b94faaSDavid Teigland if (le->le_ops->lo_add) 57b3b94faaSDavid Teigland le->le_ops->lo_add(sdp, le); 58b3b94faaSDavid Teigland } 59b3b94faaSDavid Teigland 60b3b94faaSDavid Teigland static inline void lops_incore_commit(struct gfs2_sbd *sdp, 61b3b94faaSDavid Teigland struct gfs2_trans *tr) 62b3b94faaSDavid Teigland { 63b3b94faaSDavid Teigland int x; 64b3b94faaSDavid Teigland for (x = 0; gfs2_log_ops[x]; x++) 65b3b94faaSDavid Teigland if (gfs2_log_ops[x]->lo_incore_commit) 66b3b94faaSDavid Teigland gfs2_log_ops[x]->lo_incore_commit(sdp, tr); 67b3b94faaSDavid Teigland } 68b3b94faaSDavid Teigland 69b3b94faaSDavid Teigland static inline void lops_before_commit(struct gfs2_sbd *sdp) 70b3b94faaSDavid Teigland { 71b3b94faaSDavid Teigland int x; 72b3b94faaSDavid Teigland for (x = 0; gfs2_log_ops[x]; x++) 73b3b94faaSDavid Teigland if (gfs2_log_ops[x]->lo_before_commit) 74b3b94faaSDavid Teigland gfs2_log_ops[x]->lo_before_commit(sdp); 75b3b94faaSDavid Teigland } 76b3b94faaSDavid Teigland 77b3b94faaSDavid Teigland static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) 78b3b94faaSDavid Teigland { 79b3b94faaSDavid Teigland int x; 80b3b94faaSDavid Teigland for (x = 0; gfs2_log_ops[x]; x++) 81b3b94faaSDavid Teigland if (gfs2_log_ops[x]->lo_after_commit) 82b3b94faaSDavid Teigland gfs2_log_ops[x]->lo_after_commit(sdp, ai); 83b3b94faaSDavid Teigland } 84b3b94faaSDavid Teigland 85b3b94faaSDavid Teigland static inline void lops_before_scan(struct gfs2_jdesc *jd, 8655167622SAl Viro struct gfs2_log_header_host *head, 87b3b94faaSDavid Teigland unsigned int pass) 88b3b94faaSDavid Teigland { 89b3b94faaSDavid Teigland int x; 90b3b94faaSDavid Teigland for (x = 0; gfs2_log_ops[x]; x++) 91b3b94faaSDavid Teigland if (gfs2_log_ops[x]->lo_before_scan) 92b3b94faaSDavid Teigland gfs2_log_ops[x]->lo_before_scan(jd, head, pass); 93b3b94faaSDavid Teigland } 94b3b94faaSDavid Teigland 95b3b94faaSDavid Teigland static inline int lops_scan_elements(struct gfs2_jdesc *jd, unsigned int start, 96b3b94faaSDavid Teigland struct gfs2_log_descriptor *ld, 97b3b94faaSDavid Teigland __be64 *ptr, 98b3b94faaSDavid Teigland unsigned int pass) 99b3b94faaSDavid Teigland { 100b3b94faaSDavid Teigland int x, error; 101b3b94faaSDavid Teigland for (x = 0; gfs2_log_ops[x]; x++) 102b3b94faaSDavid Teigland if (gfs2_log_ops[x]->lo_scan_elements) { 103b3b94faaSDavid Teigland error = gfs2_log_ops[x]->lo_scan_elements(jd, start, 104b3b94faaSDavid Teigland ld, ptr, pass); 105b3b94faaSDavid Teigland if (error) 106b3b94faaSDavid Teigland return error; 107b3b94faaSDavid Teigland } 108b3b94faaSDavid Teigland 109b3b94faaSDavid Teigland return 0; 110b3b94faaSDavid Teigland } 111b3b94faaSDavid Teigland 112b3b94faaSDavid Teigland static inline void lops_after_scan(struct gfs2_jdesc *jd, int error, 113b3b94faaSDavid Teigland unsigned int pass) 114b3b94faaSDavid Teigland { 115b3b94faaSDavid Teigland int x; 116b3b94faaSDavid Teigland for (x = 0; gfs2_log_ops[x]; x++) 117b3b94faaSDavid Teigland if (gfs2_log_ops[x]->lo_before_scan) 118b3b94faaSDavid Teigland gfs2_log_ops[x]->lo_after_scan(jd, error, pass); 119b3b94faaSDavid Teigland } 120b3b94faaSDavid Teigland 121b3b94faaSDavid Teigland #endif /* __LOPS_DOT_H__ */ 122b3b94faaSDavid Teigland 123