xref: /linux/fs/gfs2/lops.h (revision b3b94faa5fe5968827ba0640ee9fba4b3e7f736e)
1*b3b94faaSDavid Teigland /*
2*b3b94faaSDavid Teigland  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
3*b3b94faaSDavid Teigland  * Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
4*b3b94faaSDavid Teigland  *
5*b3b94faaSDavid Teigland  * This copyrighted material is made available to anyone wishing to use,
6*b3b94faaSDavid Teigland  * modify, copy, or redistribute it subject to the terms and conditions
7*b3b94faaSDavid Teigland  * of the GNU General Public License v.2.
8*b3b94faaSDavid Teigland  */
9*b3b94faaSDavid Teigland 
10*b3b94faaSDavid Teigland #ifndef __LOPS_DOT_H__
11*b3b94faaSDavid Teigland #define __LOPS_DOT_H__
12*b3b94faaSDavid Teigland 
13*b3b94faaSDavid Teigland extern struct gfs2_log_operations gfs2_glock_lops;
14*b3b94faaSDavid Teigland extern struct gfs2_log_operations gfs2_buf_lops;
15*b3b94faaSDavid Teigland extern struct gfs2_log_operations gfs2_revoke_lops;
16*b3b94faaSDavid Teigland extern struct gfs2_log_operations gfs2_rg_lops;
17*b3b94faaSDavid Teigland extern struct gfs2_log_operations gfs2_databuf_lops;
18*b3b94faaSDavid Teigland 
19*b3b94faaSDavid Teigland extern struct gfs2_log_operations *gfs2_log_ops[];
20*b3b94faaSDavid Teigland 
21*b3b94faaSDavid Teigland static inline void lops_init_le(struct gfs2_log_element *le,
22*b3b94faaSDavid Teigland 				struct gfs2_log_operations *lops)
23*b3b94faaSDavid Teigland {
24*b3b94faaSDavid Teigland 	INIT_LIST_HEAD(&le->le_list);
25*b3b94faaSDavid Teigland 	le->le_ops = lops;
26*b3b94faaSDavid Teigland }
27*b3b94faaSDavid Teigland 
28*b3b94faaSDavid Teigland static inline void lops_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
29*b3b94faaSDavid Teigland {
30*b3b94faaSDavid Teigland 	if (le->le_ops->lo_add)
31*b3b94faaSDavid Teigland 		le->le_ops->lo_add(sdp, le);
32*b3b94faaSDavid Teigland }
33*b3b94faaSDavid Teigland 
34*b3b94faaSDavid Teigland static inline void lops_incore_commit(struct gfs2_sbd *sdp,
35*b3b94faaSDavid Teigland 				      struct gfs2_trans *tr)
36*b3b94faaSDavid Teigland {
37*b3b94faaSDavid Teigland 	int x;
38*b3b94faaSDavid Teigland 	for (x = 0; gfs2_log_ops[x]; x++)
39*b3b94faaSDavid Teigland 		if (gfs2_log_ops[x]->lo_incore_commit)
40*b3b94faaSDavid Teigland 			gfs2_log_ops[x]->lo_incore_commit(sdp, tr);
41*b3b94faaSDavid Teigland }
42*b3b94faaSDavid Teigland 
43*b3b94faaSDavid Teigland static inline void lops_before_commit(struct gfs2_sbd *sdp)
44*b3b94faaSDavid Teigland {
45*b3b94faaSDavid Teigland 	int x;
46*b3b94faaSDavid Teigland 	for (x = 0; gfs2_log_ops[x]; x++)
47*b3b94faaSDavid Teigland 		if (gfs2_log_ops[x]->lo_before_commit)
48*b3b94faaSDavid Teigland 			gfs2_log_ops[x]->lo_before_commit(sdp);
49*b3b94faaSDavid Teigland }
50*b3b94faaSDavid Teigland 
51*b3b94faaSDavid Teigland static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
52*b3b94faaSDavid Teigland {
53*b3b94faaSDavid Teigland 	int x;
54*b3b94faaSDavid Teigland 	for (x = 0; gfs2_log_ops[x]; x++)
55*b3b94faaSDavid Teigland 		if (gfs2_log_ops[x]->lo_after_commit)
56*b3b94faaSDavid Teigland 			gfs2_log_ops[x]->lo_after_commit(sdp, ai);
57*b3b94faaSDavid Teigland }
58*b3b94faaSDavid Teigland 
59*b3b94faaSDavid Teigland static inline void lops_before_scan(struct gfs2_jdesc *jd,
60*b3b94faaSDavid Teigland 				    struct gfs2_log_header *head,
61*b3b94faaSDavid Teigland 				    unsigned int pass)
62*b3b94faaSDavid Teigland {
63*b3b94faaSDavid Teigland 	int x;
64*b3b94faaSDavid Teigland 	for (x = 0; gfs2_log_ops[x]; x++)
65*b3b94faaSDavid Teigland 		if (gfs2_log_ops[x]->lo_before_scan)
66*b3b94faaSDavid Teigland 			gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
67*b3b94faaSDavid Teigland }
68*b3b94faaSDavid Teigland 
69*b3b94faaSDavid Teigland static inline int lops_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
70*b3b94faaSDavid Teigland 				     struct gfs2_log_descriptor *ld,
71*b3b94faaSDavid Teigland 				     __be64 *ptr,
72*b3b94faaSDavid Teigland 				     unsigned int pass)
73*b3b94faaSDavid Teigland {
74*b3b94faaSDavid Teigland 	int x, error;
75*b3b94faaSDavid Teigland 	for (x = 0; gfs2_log_ops[x]; x++)
76*b3b94faaSDavid Teigland 		if (gfs2_log_ops[x]->lo_scan_elements) {
77*b3b94faaSDavid Teigland 			error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
78*b3b94faaSDavid Teigland 								  ld, ptr, pass);
79*b3b94faaSDavid Teigland 			if (error)
80*b3b94faaSDavid Teigland 				return error;
81*b3b94faaSDavid Teigland 		}
82*b3b94faaSDavid Teigland 
83*b3b94faaSDavid Teigland 	return 0;
84*b3b94faaSDavid Teigland }
85*b3b94faaSDavid Teigland 
86*b3b94faaSDavid Teigland static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
87*b3b94faaSDavid Teigland 				   unsigned int pass)
88*b3b94faaSDavid Teigland {
89*b3b94faaSDavid Teigland 	int x;
90*b3b94faaSDavid Teigland 	for (x = 0; gfs2_log_ops[x]; x++)
91*b3b94faaSDavid Teigland 		if (gfs2_log_ops[x]->lo_before_scan)
92*b3b94faaSDavid Teigland 			gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
93*b3b94faaSDavid Teigland }
94*b3b94faaSDavid Teigland 
95*b3b94faaSDavid Teigland #endif /* __LOPS_DOT_H__ */
96*b3b94faaSDavid Teigland 
97