xref: /linux/fs/gfs2/meta_io.h (revision ddacfaf76dd620af9b73343a975749778321b51c)
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 __DIO_DOT_H__
11b3b94faaSDavid Teigland #define __DIO_DOT_H__
12b3b94faaSDavid Teigland 
13f2f7ba52SSteven Whitehouse #include <linux/buffer_head.h>
14f2f7ba52SSteven Whitehouse #include <linux/string.h>
15f2f7ba52SSteven Whitehouse #include "incore.h"
16f2f7ba52SSteven Whitehouse 
17b3b94faaSDavid Teigland static inline void gfs2_buffer_clear(struct buffer_head *bh)
18b3b94faaSDavid Teigland {
19b3b94faaSDavid Teigland 	memset(bh->b_data, 0, bh->b_size);
20b3b94faaSDavid Teigland }
21b3b94faaSDavid Teigland 
22b3b94faaSDavid Teigland static inline void gfs2_buffer_clear_tail(struct buffer_head *bh, int head)
23b3b94faaSDavid Teigland {
24420b9e5eSSteven Whitehouse 	BUG_ON(head > bh->b_size);
25b3b94faaSDavid Teigland 	memset(bh->b_data + head, 0, bh->b_size - head);
26b3b94faaSDavid Teigland }
27b3b94faaSDavid Teigland 
28b3b94faaSDavid Teigland static inline void gfs2_buffer_copy_tail(struct buffer_head *to_bh,
29b3b94faaSDavid Teigland 					 int to_head,
30b3b94faaSDavid Teigland 					 struct buffer_head *from_bh,
31b3b94faaSDavid Teigland 					 int from_head)
32b3b94faaSDavid Teigland {
33420b9e5eSSteven Whitehouse 	BUG_ON(from_head < to_head);
34420b9e5eSSteven Whitehouse 	memcpy(to_bh->b_data + to_head, from_bh->b_data + from_head,
35b3b94faaSDavid Teigland 	       from_bh->b_size - from_head);
36b3b94faaSDavid Teigland 	memset(to_bh->b_data + to_bh->b_size + to_head - from_head,
37420b9e5eSSteven Whitehouse 	       0, from_head - to_head);
38b3b94faaSDavid Teigland }
39b3b94faaSDavid Teigland 
40b3b94faaSDavid Teigland struct inode *gfs2_aspace_get(struct gfs2_sbd *sdp);
41b3b94faaSDavid Teigland void gfs2_aspace_put(struct inode *aspace);
42b3b94faaSDavid Teigland 
43b3b94faaSDavid Teigland void gfs2_meta_inval(struct gfs2_glock *gl);
447276b3b0SSteven Whitehouse void gfs2_meta_sync(struct gfs2_glock *gl);
45b3b94faaSDavid Teigland 
46cd915493SSteven Whitehouse struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno);
47cd915493SSteven Whitehouse int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno,
48b3b94faaSDavid Teigland 		   int flags, struct buffer_head **bhp);
497276b3b0SSteven Whitehouse int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh);
50b3b94faaSDavid Teigland 
51568f4c96SSteven Whitehouse void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh,
52568f4c96SSteven Whitehouse 			 int meta);
53a98ab220SSteven Whitehouse void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
54a98ab220SSteven Whitehouse void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
55b3b94faaSDavid Teigland 		struct gfs2_ail *ai);
56b3b94faaSDavid Teigland 
57cd915493SSteven Whitehouse void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen);
58b3b94faaSDavid Teigland 
59b3b94faaSDavid Teigland void gfs2_meta_cache_flush(struct gfs2_inode *ip);
60cd915493SSteven Whitehouse int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, u64 num,
61b3b94faaSDavid Teigland 			      int new, struct buffer_head **bhp);
62b3b94faaSDavid Teigland 
63b3b94faaSDavid Teigland static inline int gfs2_meta_inode_buffer(struct gfs2_inode *ip,
64b3b94faaSDavid Teigland 					 struct buffer_head **bhp)
65b3b94faaSDavid Teigland {
66b3b94faaSDavid Teigland 	return gfs2_meta_indirect_buffer(ip, 0, ip->i_num.no_addr, 0, bhp);
67b3b94faaSDavid Teigland }
68b3b94faaSDavid Teigland 
697276b3b0SSteven Whitehouse struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen);
70b3b94faaSDavid Teigland void gfs2_meta_syncfs(struct gfs2_sbd *sdp);
71b3b94faaSDavid Teigland 
72*ddacfaf7SSteven Whitehouse #define buffer_busy(bh) \
73*ddacfaf7SSteven Whitehouse ((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned)))
74*ddacfaf7SSteven Whitehouse #define buffer_in_io(bh) \
75*ddacfaf7SSteven Whitehouse ((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock)))
76*ddacfaf7SSteven Whitehouse 
77b3b94faaSDavid Teigland #endif /* __DIO_DOT_H__ */
78b3b94faaSDavid Teigland 
79