blob: 3fca5bf239d336d8b308e74c91f6a1429a836773 [file] [log] [blame]
Thomas Gleixner7336d0e2019-05-31 01:09:56 -07001/* SPDX-License-Identifier: GPL-2.0-only */
David Teiglandb3b94fa2006-01-16 16:50:04 +00002/*
3 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Bob Petersond0109bf2008-01-28 11:20:10 -06004 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00005 */
6
7#ifndef __LOPS_DOT_H__
8#define __LOPS_DOT_H__
9
Steven Whitehousef2f7ba52006-09-05 10:39:21 -040010#include <linux/list.h>
11#include "incore.h"
12
Steven Whitehouseb09e5932006-04-07 11:17:32 -040013extern const struct gfs2_log_operations *gfs2_log_ops[];
Andreas Gruenbacher19ebc052019-08-28 22:21:34 +020014extern void gfs2_log_incr_head(struct gfs2_sbd *sdp);
15extern u64 gfs2_log_bmap(struct gfs2_jdesc *jd, unsigned int lbn);
Bob Petersonc1696fb2018-01-17 00:01:33 +010016extern void gfs2_log_write(struct gfs2_sbd *sdp, struct page *page,
17 unsigned size, unsigned offset, u64 blkno);
Steven Whitehousee8c92ed2012-04-16 09:28:31 +010018extern void gfs2_log_write_page(struct gfs2_sbd *sdp, struct page *page);
Abhi Dasf4686c22019-05-02 14:17:40 -050019extern void gfs2_log_submit_bio(struct bio **biop, int opf);
Steven Whitehouse767f4332012-12-14 12:52:14 +000020extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
Abhi Dasf4686c22019-05-02 14:17:40 -050021extern int gfs2_find_jhead(struct gfs2_jdesc *jd,
22 struct gfs2_log_header_host *head, bool keep_cache);
Robert Peterson2332c442007-06-18 14:50:20 -050023static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
24{
Andreas Gruenbacher458094c2020-12-05 13:21:50 +010025 return sdp->sd_ldptrs;
Robert Peterson2332c442007-06-18 14:50:20 -050026}
27
28static inline unsigned int databuf_limit(struct gfs2_sbd *sdp)
29{
Andreas Gruenbacher458094c2020-12-05 13:21:50 +010030 return sdp->sd_ldptrs / 2;
Robert Peterson2332c442007-06-18 14:50:20 -050031}
32
Steven Whitehoused69a3c62014-02-21 15:22:35 +000033static inline void lops_before_commit(struct gfs2_sbd *sdp,
34 struct gfs2_trans *tr)
David Teiglandb3b94fa2006-01-16 16:50:04 +000035{
36 int x;
37 for (x = 0; gfs2_log_ops[x]; x++)
38 if (gfs2_log_ops[x]->lo_before_commit)
Steven Whitehoused69a3c62014-02-21 15:22:35 +000039 gfs2_log_ops[x]->lo_before_commit(sdp, tr);
David Teiglandb3b94fa2006-01-16 16:50:04 +000040}
41
Benjamin Marzinski16ca9412013-04-05 20:31:46 -050042static inline void lops_after_commit(struct gfs2_sbd *sdp,
43 struct gfs2_trans *tr)
David Teiglandb3b94fa2006-01-16 16:50:04 +000044{
45 int x;
46 for (x = 0; gfs2_log_ops[x]; x++)
47 if (gfs2_log_ops[x]->lo_after_commit)
Benjamin Marzinski16ca9412013-04-05 20:31:46 -050048 gfs2_log_ops[x]->lo_after_commit(sdp, tr);
David Teiglandb3b94fa2006-01-16 16:50:04 +000049}
50
51static inline void lops_before_scan(struct gfs2_jdesc *jd,
Al Viro55167622006-10-13 21:47:13 -040052 struct gfs2_log_header_host *head,
David Teiglandb3b94fa2006-01-16 16:50:04 +000053 unsigned int pass)
54{
55 int x;
56 for (x = 0; gfs2_log_ops[x]; x++)
57 if (gfs2_log_ops[x]->lo_before_scan)
58 gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
59}
60
Bob Peterson7c70b892019-03-25 09:34:19 -060061static inline int lops_scan_elements(struct gfs2_jdesc *jd, u32 start,
David Teiglandb3b94fa2006-01-16 16:50:04 +000062 struct gfs2_log_descriptor *ld,
63 __be64 *ptr,
64 unsigned int pass)
65{
66 int x, error;
67 for (x = 0; gfs2_log_ops[x]; x++)
68 if (gfs2_log_ops[x]->lo_scan_elements) {
69 error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
70 ld, ptr, pass);
71 if (error)
72 return error;
73 }
74
75 return 0;
76}
77
78static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
79 unsigned int pass)
80{
81 int x;
82 for (x = 0; gfs2_log_ops[x]; x++)
83 if (gfs2_log_ops[x]->lo_before_scan)
84 gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
85}
86
87#endif /* __LOPS_DOT_H__ */
88