^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef __DIO_DOT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define __DIO_DOT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "incore.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static inline void gfs2_buffer_clear(struct buffer_head *bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) memset(bh->b_data, 0, bh->b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static inline void gfs2_buffer_clear_tail(struct buffer_head *bh, int head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) BUG_ON(head > bh->b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) memset(bh->b_data + head, 0, bh->b_size - head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static inline void gfs2_buffer_copy_tail(struct buffer_head *to_bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) int to_head,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct buffer_head *from_bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) int from_head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) BUG_ON(from_head < to_head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) memcpy(to_bh->b_data + to_head, from_bh->b_data + from_head,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) from_bh->b_size - from_head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) memset(to_bh->b_data + to_bh->b_size + to_head - from_head,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 0, from_head - to_head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) extern const struct address_space_operations gfs2_meta_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) extern const struct address_space_operations gfs2_rgrp_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static inline struct gfs2_sbd *gfs2_mapping2sbd(struct address_space *mapping)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct inode *inode = mapping->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) if (mapping->a_ops == &gfs2_meta_aops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return (((struct gfs2_glock *)mapping) - 1)->gl_name.ln_sbd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) else if (mapping->a_ops == &gfs2_rgrp_aops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) return container_of(mapping, struct gfs2_sbd, sd_aspace);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) return inode->i_sb->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) extern struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) extern int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int rahead, struct buffer_head **bhp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) extern int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) extern struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) REMOVE_JDATA = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) REMOVE_META = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) extern void gfs2_remove_from_journal(struct buffer_head *bh, int meta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) extern void gfs2_journal_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) extern int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, u64 num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct buffer_head **bhp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static inline int gfs2_meta_inode_buffer(struct gfs2_inode *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct buffer_head **bhp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) return gfs2_meta_indirect_buffer(ip, 0, ip->i_no_addr, bhp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define buffer_busy(bh) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #endif /* __DIO_DOT_H__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)