meta_io.h 2.4 KB

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