xref: /linux/fs/gfs2/meta_io.h (revision 009d851837ab26cab18adda6169a813f70b0b21b)
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 
40*009d8518SSteven Whitehouse extern const struct address_space_operations gfs2_meta_aops;
41*009d8518SSteven Whitehouse 
42*009d8518SSteven Whitehouse static inline struct gfs2_sbd *gfs2_mapping2sbd(struct address_space *mapping)
43*009d8518SSteven Whitehouse {
44*009d8518SSteven Whitehouse 	struct inode *inode = mapping->host;
45*009d8518SSteven Whitehouse 	if (mapping->a_ops == &gfs2_meta_aops)
46*009d8518SSteven Whitehouse 		return (((struct gfs2_glock *)mapping) - 1)->gl_sbd;
47*009d8518SSteven Whitehouse 	else
48*009d8518SSteven Whitehouse 		return inode->i_sb->s_fs_info;
49*009d8518SSteven Whitehouse }
50b3b94faaSDavid Teigland 
517276b3b0SSteven Whitehouse void gfs2_meta_sync(struct gfs2_glock *gl);
52b3b94faaSDavid Teigland 
53cd915493SSteven Whitehouse struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno);
54cd915493SSteven Whitehouse int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno,
55b3b94faaSDavid Teigland 		   int flags, struct buffer_head **bhp);
567276b3b0SSteven Whitehouse int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh);
576802e340SSteven Whitehouse struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno, int create);
58b3b94faaSDavid Teigland 
59568f4c96SSteven Whitehouse void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh,
60568f4c96SSteven Whitehouse 			 int meta);
61b3b94faaSDavid Teigland 
6216615be1SSteven Whitehouse void gfs2_remove_from_journal(struct buffer_head *bh, struct gfs2_trans *tr,
6316615be1SSteven Whitehouse 			      int meta);
6416615be1SSteven Whitehouse 
65cd915493SSteven Whitehouse void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen);
66b3b94faaSDavid Teigland 
67cd915493SSteven Whitehouse int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, u64 num,
68b3b94faaSDavid Teigland 			      int new, struct buffer_head **bhp);
69b3b94faaSDavid Teigland 
70b3b94faaSDavid Teigland static inline int gfs2_meta_inode_buffer(struct gfs2_inode *ip,
71b3b94faaSDavid Teigland 					 struct buffer_head **bhp)
72b3b94faaSDavid Teigland {
73dbb7cae2SSteven Whitehouse 	return gfs2_meta_indirect_buffer(ip, 0, ip->i_no_addr, 0, bhp);
74b3b94faaSDavid Teigland }
75b3b94faaSDavid Teigland 
767276b3b0SSteven Whitehouse struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen);
77b3b94faaSDavid Teigland 
78ddacfaf7SSteven Whitehouse #define buffer_busy(bh) \
79ddacfaf7SSteven Whitehouse ((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned)))
80ddacfaf7SSteven Whitehouse #define buffer_in_io(bh) \
81ddacfaf7SSteven Whitehouse ((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock)))
82ddacfaf7SSteven Whitehouse 
83b3b94faaSDavid Teigland #endif /* __DIO_DOT_H__ */
84b3b94faaSDavid Teigland 
85