xref: /openbmc/linux/fs/gfs2/log.h (revision c1696fb8)
1b3b94faaSDavid Teigland /*
2b3b94faaSDavid Teigland  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
33a8a9a10SSteven Whitehouse  * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
4b3b94faaSDavid Teigland  *
5b3b94faaSDavid Teigland  * This copyrighted material is made available to anyone wishing to use,
6b3b94faaSDavid Teigland  * modify, copy, or redistribute it subject to the terms and conditions
7e9fc2aa0SSteven Whitehouse  * of the GNU General Public License version 2.
8b3b94faaSDavid Teigland  */
9b3b94faaSDavid Teigland 
10b3b94faaSDavid Teigland #ifndef __LOG_DOT_H__
11b3b94faaSDavid Teigland #define __LOG_DOT_H__
12b3b94faaSDavid Teigland 
13f2f7ba52SSteven Whitehouse #include <linux/list.h>
14f2f7ba52SSteven Whitehouse #include <linux/spinlock.h>
154667a0ecSSteven Whitehouse #include <linux/writeback.h>
16f2f7ba52SSteven Whitehouse #include "incore.h"
17f2f7ba52SSteven Whitehouse 
18b3b94faaSDavid Teigland /**
19b3b94faaSDavid Teigland  * gfs2_log_lock - acquire the right to mess with the log manager
20b3b94faaSDavid Teigland  * @sdp: the filesystem
21b3b94faaSDavid Teigland  *
22b3b94faaSDavid Teigland  */
23b3b94faaSDavid Teigland 
24b3b94faaSDavid Teigland static inline void gfs2_log_lock(struct gfs2_sbd *sdp)
252d81afb8SHarvey Harrison __acquires(&sdp->sd_log_lock)
26b3b94faaSDavid Teigland {
27b3b94faaSDavid Teigland 	spin_lock(&sdp->sd_log_lock);
28b3b94faaSDavid Teigland }
29b3b94faaSDavid Teigland 
30b3b94faaSDavid Teigland /**
31b3b94faaSDavid Teigland  * gfs2_log_unlock - release the right to mess with the log manager
32b3b94faaSDavid Teigland  * @sdp: the filesystem
33b3b94faaSDavid Teigland  *
34b3b94faaSDavid Teigland  */
35b3b94faaSDavid Teigland 
36b3b94faaSDavid Teigland static inline void gfs2_log_unlock(struct gfs2_sbd *sdp)
372d81afb8SHarvey Harrison __releases(&sdp->sd_log_lock)
38b3b94faaSDavid Teigland {
39b3b94faaSDavid Teigland 	spin_unlock(&sdp->sd_log_lock);
40b3b94faaSDavid Teigland }
41b3b94faaSDavid Teigland 
42b3b94faaSDavid Teigland static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp,
43b3b94faaSDavid Teigland 					  unsigned int value)
44b3b94faaSDavid Teigland {
45b3b94faaSDavid Teigland 	if (++value == sdp->sd_jdesc->jd_blocks) {
46b3b94faaSDavid Teigland 		value = 0;
47b3b94faaSDavid Teigland 	}
48b3b94faaSDavid Teigland 	sdp->sd_log_head = sdp->sd_log_tail = value;
49b3b94faaSDavid Teigland }
50b3b94faaSDavid Teigland 
5145138990SSteven Whitehouse static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
5245138990SSteven Whitehouse {
5345138990SSteven Whitehouse 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
5445138990SSteven Whitehouse 
5545138990SSteven Whitehouse 	if (!test_bit(GIF_ORDERED, &ip->i_flags)) {
5645138990SSteven Whitehouse 		spin_lock(&sdp->sd_ordered_lock);
5745138990SSteven Whitehouse 		if (!test_and_set_bit(GIF_ORDERED, &ip->i_flags))
5845138990SSteven Whitehouse 			list_add(&ip->i_ordered, &sdp->sd_log_le_ordered);
5945138990SSteven Whitehouse 		spin_unlock(&sdp->sd_ordered_lock);
6045138990SSteven Whitehouse 	}
6145138990SSteven Whitehouse }
6245138990SSteven Whitehouse extern void gfs2_ordered_del_inode(struct gfs2_inode *ip);
63ed4878e8SBob Peterson extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct,
64b3b94faaSDavid Teigland 			    unsigned int ssize);
65b3b94faaSDavid Teigland 
6624972557SBenjamin Marzinski extern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks);
67ed4878e8SBob Peterson extern int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks);
68c1696fb8SBob Peterson extern void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
69c1696fb8SBob Peterson 				  u64 seq, u32 tail, u32 flags, int op_flags);
7024972557SBenjamin Marzinski extern void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl,
71c1696fb8SBob Peterson 			   u32 type);
72ed4878e8SBob Peterson extern void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans);
73ed4878e8SBob Peterson extern void gfs2_remove_from_ail(struct gfs2_bufdata *bd);
744667a0ecSSteven Whitehouse extern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc);
752bcd610dSSteven Whitehouse 
76ed4878e8SBob Peterson extern void gfs2_log_shutdown(struct gfs2_sbd *sdp);
77ed4878e8SBob Peterson extern int gfs2_logd(void *data);
785d054964SBenjamin Marzinski extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
795d054964SBenjamin Marzinski extern void gfs2_write_revokes(struct gfs2_sbd *sdp);
80b3b94faaSDavid Teigland 
81b3b94faaSDavid Teigland #endif /* __LOG_DOT_H__ */
82