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