xref: /openbmc/linux/fs/gfs2/log.h (revision e7501bf8)
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 
567542486bSBob Peterson 	if (list_empty(&ip->i_ordered)) {
5745138990SSteven Whitehouse 		spin_lock(&sdp->sd_ordered_lock);
587542486bSBob Peterson 		if (list_empty(&ip->i_ordered))
59a5b1d3fcSAndreas Gruenbacher 			list_add(&ip->i_ordered, &sdp->sd_log_ordered);
6045138990SSteven Whitehouse 		spin_unlock(&sdp->sd_ordered_lock);
6145138990SSteven Whitehouse 	}
6245138990SSteven Whitehouse }
632e9eeaa1SBob Peterson 
6445138990SSteven Whitehouse extern void gfs2_ordered_del_inode(struct gfs2_inode *ip);
652e9eeaa1SBob Peterson extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct);
6668942870SBob Peterson extern void gfs2_remove_from_ail(struct gfs2_bufdata *bd);
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);
769ff78289SBob Peterson extern void log_flush_wait(struct gfs2_sbd *sdp);
772bcd610dSSteven Whitehouse 
78ed4878e8SBob Peterson extern int gfs2_logd(void *data);
795d054964SBenjamin Marzinski extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
80fe5e7ba1SBob Peterson extern void gfs2_glock_remove_revoke(struct gfs2_glock *gl);
81*e7501bf8SAndreas Gruenbacher extern void gfs2_flush_revokes(struct gfs2_sbd *sdp);
82b3b94faaSDavid Teigland 
83b3b94faaSDavid Teigland #endif /* __LOG_DOT_H__ */
84