David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
Steven Whitehouse | 3a8a9a1 | 2006-05-18 15:09:15 -0400 | [diff] [blame] | 3 | * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 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 |
Steven Whitehouse | e9fc2aa | 2006-09-01 11:05:15 -0400 | [diff] [blame] | 7 | * of the GNU General Public License version 2. |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __LOPS_DOT_H__ |
| 11 | #define __LOPS_DOT_H__ |
| 12 | |
Steven Whitehouse | f2f7ba5 | 2006-09-05 10:39:21 -0400 | [diff] [blame] | 13 | #include <linux/list.h> |
| 14 | #include "incore.h" |
| 15 | |
Steven Whitehouse | b09e593 | 2006-04-07 11:17:32 -0400 | [diff] [blame] | 16 | extern const struct gfs2_log_operations gfs2_glock_lops; |
| 17 | extern const struct gfs2_log_operations gfs2_buf_lops; |
| 18 | extern const struct gfs2_log_operations gfs2_revoke_lops; |
| 19 | extern const struct gfs2_log_operations gfs2_rg_lops; |
| 20 | extern const struct gfs2_log_operations gfs2_databuf_lops; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 21 | |
Steven Whitehouse | b09e593 | 2006-04-07 11:17:32 -0400 | [diff] [blame] | 22 | extern const struct gfs2_log_operations *gfs2_log_ops[]; |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 23 | |
| 24 | static inline void lops_init_le(struct gfs2_log_element *le, |
Steven Whitehouse | b09e593 | 2006-04-07 11:17:32 -0400 | [diff] [blame] | 25 | const struct gfs2_log_operations *lops) |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 26 | { |
| 27 | INIT_LIST_HEAD(&le->le_list); |
| 28 | le->le_ops = lops; |
| 29 | } |
| 30 | |
| 31 | static inline void lops_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le) |
| 32 | { |
| 33 | if (le->le_ops->lo_add) |
| 34 | le->le_ops->lo_add(sdp, le); |
| 35 | } |
| 36 | |
| 37 | static inline void lops_incore_commit(struct gfs2_sbd *sdp, |
| 38 | struct gfs2_trans *tr) |
| 39 | { |
| 40 | int x; |
| 41 | for (x = 0; gfs2_log_ops[x]; x++) |
| 42 | if (gfs2_log_ops[x]->lo_incore_commit) |
| 43 | gfs2_log_ops[x]->lo_incore_commit(sdp, tr); |
| 44 | } |
| 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 | |
| 54 | static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) |
| 55 | { |
| 56 | int x; |
| 57 | for (x = 0; gfs2_log_ops[x]; x++) |
| 58 | if (gfs2_log_ops[x]->lo_after_commit) |
| 59 | gfs2_log_ops[x]->lo_after_commit(sdp, ai); |
| 60 | } |
| 61 | |
| 62 | static inline void lops_before_scan(struct gfs2_jdesc *jd, |
Al Viro | 5516762 | 2006-10-13 21:47:13 -0400 | [diff] [blame] | 63 | struct gfs2_log_header_host *head, |
David Teigland | b3b94fa | 2006-01-16 16:50:04 +0000 | [diff] [blame] | 64 | unsigned int pass) |
| 65 | { |
| 66 | int x; |
| 67 | for (x = 0; gfs2_log_ops[x]; x++) |
| 68 | if (gfs2_log_ops[x]->lo_before_scan) |
| 69 | gfs2_log_ops[x]->lo_before_scan(jd, head, pass); |
| 70 | } |
| 71 | |
| 72 | static inline int lops_scan_elements(struct gfs2_jdesc *jd, unsigned int start, |
| 73 | struct gfs2_log_descriptor *ld, |
| 74 | __be64 *ptr, |
| 75 | unsigned int pass) |
| 76 | { |
| 77 | int x, error; |
| 78 | for (x = 0; gfs2_log_ops[x]; x++) |
| 79 | if (gfs2_log_ops[x]->lo_scan_elements) { |
| 80 | error = gfs2_log_ops[x]->lo_scan_elements(jd, start, |
| 81 | ld, ptr, pass); |
| 82 | if (error) |
| 83 | return error; |
| 84 | } |
| 85 | |
| 86 | return 0; |
| 87 | } |
| 88 | |
| 89 | static inline void lops_after_scan(struct gfs2_jdesc *jd, int error, |
| 90 | unsigned int pass) |
| 91 | { |
| 92 | int x; |
| 93 | for (x = 0; gfs2_log_ops[x]; x++) |
| 94 | if (gfs2_log_ops[x]->lo_before_scan) |
| 95 | gfs2_log_ops[x]->lo_after_scan(jd, error, pass); |
| 96 | } |
| 97 | |
| 98 | #endif /* __LOPS_DOT_H__ */ |
| 99 | |