0001
0002
0003
0004
0005
0006
0007 #ifndef __DIO_DOT_H__
0008 #define __DIO_DOT_H__
0009
0010 #include <linux/buffer_head.h>
0011 #include <linux/string.h>
0012 #include "incore.h"
0013
0014 static inline void gfs2_buffer_clear(struct buffer_head *bh)
0015 {
0016 memset(bh->b_data, 0, bh->b_size);
0017 }
0018
0019 static inline void gfs2_buffer_clear_tail(struct buffer_head *bh, int head)
0020 {
0021 BUG_ON(head > bh->b_size);
0022 memset(bh->b_data + head, 0, bh->b_size - head);
0023 }
0024
0025 static inline void gfs2_buffer_copy_tail(struct buffer_head *to_bh,
0026 int to_head,
0027 struct buffer_head *from_bh,
0028 int from_head)
0029 {
0030 BUG_ON(from_head < to_head);
0031 memcpy(to_bh->b_data + to_head, from_bh->b_data + from_head,
0032 from_bh->b_size - from_head);
0033 memset(to_bh->b_data + to_bh->b_size + to_head - from_head,
0034 0, from_head - to_head);
0035 }
0036
0037 extern const struct address_space_operations gfs2_meta_aops;
0038 extern const struct address_space_operations gfs2_rgrp_aops;
0039
0040 static inline struct gfs2_sbd *gfs2_mapping2sbd(struct address_space *mapping)
0041 {
0042 struct inode *inode = mapping->host;
0043 if (mapping->a_ops == &gfs2_meta_aops) {
0044 struct gfs2_glock_aspace *gla =
0045 container_of(mapping, struct gfs2_glock_aspace, mapping);
0046 return gla->glock.gl_name.ln_sbd;
0047 } else if (mapping->a_ops == &gfs2_rgrp_aops)
0048 return container_of(mapping, struct gfs2_sbd, sd_aspace);
0049 else
0050 return inode->i_sb->s_fs_info;
0051 }
0052
0053 extern struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno);
0054 extern int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
0055 int rahead, struct buffer_head **bhp);
0056 extern int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh);
0057 extern struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno,
0058 int create);
0059 enum {
0060 REMOVE_JDATA = 0,
0061 REMOVE_META = 1,
0062 };
0063
0064 extern void gfs2_remove_from_journal(struct buffer_head *bh, int meta);
0065 extern void gfs2_journal_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen);
0066 extern int gfs2_meta_buffer(struct gfs2_inode *ip, u32 mtype, u64 num,
0067 struct buffer_head **bhp);
0068
0069 static inline int gfs2_meta_inode_buffer(struct gfs2_inode *ip,
0070 struct buffer_head **bhp)
0071 {
0072 return gfs2_meta_buffer(ip, GFS2_METATYPE_DI, ip->i_no_addr, bhp);
0073 }
0074
0075 struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen);
0076
0077 #define buffer_busy(bh) \
0078 ((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned)))
0079
0080 #endif
0081