^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-2006 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 __LOG_DOT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define __LOG_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 <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/writeback.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "incore.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "inode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * gfs2_log_lock - acquire the right to mess with the log manager
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * @sdp: the filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static inline void gfs2_log_lock(struct gfs2_sbd *sdp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) __acquires(&sdp->sd_log_lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) spin_lock(&sdp->sd_log_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * gfs2_log_unlock - release the right to mess with the log manager
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * @sdp: the filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static inline void gfs2_log_unlock(struct gfs2_sbd *sdp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) __releases(&sdp->sd_log_lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) spin_unlock(&sdp->sd_log_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) unsigned int value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) if (++value == sdp->sd_jdesc->jd_blocks) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) value = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) sdp->sd_log_head = sdp->sd_log_tail = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (gfs2_is_jdata(ip) || !gfs2_is_ordered(sdp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) if (list_empty(&ip->i_ordered)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) spin_lock(&sdp->sd_ordered_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) if (list_empty(&ip->i_ordered))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) list_add(&ip->i_ordered, &sdp->sd_log_ordered);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) spin_unlock(&sdp->sd_ordered_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^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) extern void gfs2_ordered_del_inode(struct gfs2_inode *ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) extern void gfs2_remove_from_ail(struct gfs2_bufdata *bd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) extern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) extern int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) extern void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) u64 seq, u32 tail, u32 lblock, u32 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) int op_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) extern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u32 type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) extern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) extern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) extern void log_flush_wait(struct gfs2_sbd *sdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) extern int gfs2_logd(void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) extern void gfs2_glock_remove_revoke(struct gfs2_glock *gl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) extern void gfs2_write_revokes(struct gfs2_sbd *sdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #endif /* __LOG_DOT_H__ */