xref: /openbmc/linux/fs/gfs2/log.h (revision 7336d0e6)
17336d0e6SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2b3b94faaSDavid Teigland /*
3b3b94faaSDavid Teigland  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
43a8a9a10SSteven Whitehouse  * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
5b3b94faaSDavid Teigland  */
6b3b94faaSDavid Teigland 
7b3b94faaSDavid Teigland #ifndef __LOG_DOT_H__
8b3b94faaSDavid Teigland #define __LOG_DOT_H__
9b3b94faaSDavid Teigland 
10f2f7ba52SSteven Whitehouse #include <linux/list.h>
11f2f7ba52SSteven Whitehouse #include <linux/spinlock.h>
124667a0ecSSteven Whitehouse #include <linux/writeback.h>
13f2f7ba52SSteven Whitehouse #include "incore.h"
14845802b1SAndreas Gruenbacher #include "inode.h"
15f2f7ba52SSteven Whitehouse 
16b3b94faaSDavid Teigland /**
17b3b94faaSDavid Teigland  * gfs2_log_lock - acquire the right to mess with the log manager
18b3b94faaSDavid Teigland  * @sdp: the filesystem
19b3b94faaSDavid Teigland  *
20b3b94faaSDavid Teigland  */
21b3b94faaSDavid Teigland 
22b3b94faaSDavid Teigland static inline void gfs2_log_lock(struct gfs2_sbd *sdp)
232d81afb8SHarvey Harrison __acquires(&sdp->sd_log_lock)
24b3b94faaSDavid Teigland {
25b3b94faaSDavid Teigland 	spin_lock(&sdp->sd_log_lock);
26b3b94faaSDavid Teigland }
27b3b94faaSDavid Teigland 
28b3b94faaSDavid Teigland /**
29b3b94faaSDavid Teigland  * gfs2_log_unlock - release the right to mess with the log manager
30b3b94faaSDavid Teigland  * @sdp: the filesystem
31b3b94faaSDavid Teigland  *
32b3b94faaSDavid Teigland  */
33b3b94faaSDavid Teigland 
34b3b94faaSDavid Teigland static inline void gfs2_log_unlock(struct gfs2_sbd *sdp)
352d81afb8SHarvey Harrison __releases(&sdp->sd_log_lock)
36b3b94faaSDavid Teigland {
37b3b94faaSDavid Teigland 	spin_unlock(&sdp->sd_log_lock);
38b3b94faaSDavid Teigland }
39b3b94faaSDavid Teigland 
40b3b94faaSDavid Teigland static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp,
41b3b94faaSDavid Teigland 					  unsigned int value)
42b3b94faaSDavid Teigland {
43b3b94faaSDavid Teigland 	if (++value == sdp->sd_jdesc->jd_blocks) {
44b3b94faaSDavid Teigland 		value = 0;
45b3b94faaSDavid Teigland 	}
46b3b94faaSDavid Teigland 	sdp->sd_log_head = sdp->sd_log_tail = value;
47b3b94faaSDavid Teigland }
48b3b94faaSDavid Teigland 
4945138990SSteven Whitehouse static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
5045138990SSteven Whitehouse {
51977767a7SAndreas Gruenbacher 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
5245138990SSteven Whitehouse 
53977767a7SAndreas Gruenbacher 	if (gfs2_is_jdata(ip) || !gfs2_is_ordered(sdp))
54845802b1SAndreas Gruenbacher 		return;
55845802b1SAndreas Gruenbacher 
5645138990SSteven Whitehouse 	if (!test_bit(GIF_ORDERED, &ip->i_flags)) {
5745138990SSteven Whitehouse 		spin_lock(&sdp->sd_ordered_lock);
5845138990SSteven Whitehouse 		if (!test_and_set_bit(GIF_ORDERED, &ip->i_flags))
59a5b1d3fcSAndreas Gruenbacher 			list_add(&ip->i_ordered, &sdp->sd_log_ordered);
6045138990SSteven Whitehouse 		spin_unlock(&sdp->sd_ordered_lock);
6145138990SSteven Whitehouse 	}
6245138990SSteven Whitehouse }
6345138990SSteven Whitehouse extern void gfs2_ordered_del_inode(struct gfs2_inode *ip);
64ed4878e8SBob Peterson extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct,
65b3b94faaSDavid Teigland 			    unsigned int ssize);
66b3b94faaSDavid Teigland 
6724972557SBenjamin Marzinski extern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks);
68ed4878e8SBob Peterson extern int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks);
69c1696fb8SBob Peterson extern void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
707c70b896SBob Peterson 				  u64 seq, u32 tail, u32 lblock, u32 flags,
717c70b896SBob Peterson 				  int op_flags);
7224972557SBenjamin Marzinski extern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl,
73c1696fb8SBob Peterson 			   u32 type);
74ed4878e8SBob Peterson extern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans);
754667a0ecSSteven Whitehouse extern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc);
762bcd610dSSteven Whitehouse 
77ed4878e8SBob Peterson extern void gfs2_log_shutdown(struct gfs2_sbd *sdp);
78ed4878e8SBob Peterson extern int gfs2_logd(void *data);
795d054964SBenjamin Marzinski extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
805d054964SBenjamin Marzinski extern void gfs2_write_revokes(struct gfs2_sbd *sdp);
81b3b94faaSDavid Teigland 
82b3b94faaSDavid Teigland #endif /* __LOG_DOT_H__ */
83