xref: /openbmc/linux/fs/gfs2/lops.h (revision afba8b0a)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
4  * Copyright (C) 2004-2008 Red Hat, Inc.  All rights reserved.
5  */
6 
7 #ifndef __LOPS_DOT_H__
8 #define __LOPS_DOT_H__
9 
10 #include <linux/list.h>
11 #include "incore.h"
12 
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 
20 extern const struct gfs2_log_operations *gfs2_log_ops[];
21 extern void gfs2_log_incr_head(struct gfs2_sbd *sdp);
22 extern u64 gfs2_log_bmap(struct gfs2_jdesc *jd, unsigned int lbn);
23 extern void gfs2_log_write(struct gfs2_sbd *sdp, struct page *page,
24 			   unsigned size, unsigned offset, u64 blkno);
25 extern void gfs2_log_write_page(struct gfs2_sbd *sdp, struct page *page);
26 extern void gfs2_log_submit_bio(struct bio **biop, int opf);
27 extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
28 extern int gfs2_find_jhead(struct gfs2_jdesc *jd,
29 			   struct gfs2_log_header_host *head, bool keep_cache);
30 extern void gfs2_meta_sync(struct gfs2_glock *gl);
31 
32 static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
33 {
34 	unsigned int limit;
35 
36 	limit = (sdp->sd_sb.sb_bsize - BUF_OFFSET) / sizeof(__be64);
37 	return limit;
38 }
39 
40 static inline unsigned int databuf_limit(struct gfs2_sbd *sdp)
41 {
42 	unsigned int limit;
43 
44 	limit = (sdp->sd_sb.sb_bsize - DATABUF_OFFSET) / (2 * sizeof(__be64));
45 	return limit;
46 }
47 
48 static inline void lops_before_commit(struct gfs2_sbd *sdp,
49 				      struct gfs2_trans *tr)
50 {
51 	int x;
52 	for (x = 0; gfs2_log_ops[x]; x++)
53 		if (gfs2_log_ops[x]->lo_before_commit)
54 			gfs2_log_ops[x]->lo_before_commit(sdp, tr);
55 }
56 
57 static inline void lops_after_commit(struct gfs2_sbd *sdp,
58 				     struct gfs2_trans *tr)
59 {
60 	int x;
61 	for (x = 0; gfs2_log_ops[x]; x++)
62 		if (gfs2_log_ops[x]->lo_after_commit)
63 			gfs2_log_ops[x]->lo_after_commit(sdp, tr);
64 }
65 
66 static inline void lops_before_scan(struct gfs2_jdesc *jd,
67 				    struct gfs2_log_header_host *head,
68 				    unsigned int pass)
69 {
70 	int x;
71 	for (x = 0; gfs2_log_ops[x]; x++)
72 		if (gfs2_log_ops[x]->lo_before_scan)
73 			gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
74 }
75 
76 static inline int lops_scan_elements(struct gfs2_jdesc *jd, u32 start,
77 				     struct gfs2_log_descriptor *ld,
78 				     __be64 *ptr,
79 				     unsigned int pass)
80 {
81 	int x, error;
82 	for (x = 0; gfs2_log_ops[x]; x++)
83 		if (gfs2_log_ops[x]->lo_scan_elements) {
84 			error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
85 								  ld, ptr, pass);
86 			if (error)
87 				return error;
88 		}
89 
90 	return 0;
91 }
92 
93 static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
94 				   unsigned int pass)
95 {
96 	int x;
97 	for (x = 0; gfs2_log_ops[x]; x++)
98 		if (gfs2_log_ops[x]->lo_before_scan)
99 			gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
100 }
101 
102 #endif /* __LOPS_DOT_H__ */
103 
104