meta_io.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. struct gfs2_glock_aspace *gla =
  38. container_of(mapping, struct gfs2_glock_aspace, mapping);
  39. return gla->glock.gl_name.ln_sbd;
  40. } else if (mapping->a_ops == &gfs2_rgrp_aops)
  41. return container_of(mapping, struct gfs2_sbd, sd_aspace);
  42. else
  43. return inode->i_sb->s_fs_info;
  44. }
  45. extern struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno);
  46. extern int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
  47. int rahead, struct buffer_head **bhp);
  48. extern int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh);
  49. extern struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno,
  50. int create);
  51. enum {
  52. REMOVE_JDATA = 0,
  53. REMOVE_META = 1,
  54. };
  55. extern void gfs2_remove_from_journal(struct buffer_head *bh, int meta);
  56. extern void gfs2_journal_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen);
  57. extern int gfs2_meta_buffer(struct gfs2_inode *ip, u32 mtype, u64 num,
  58. struct buffer_head **bhp);
  59. static inline int gfs2_meta_inode_buffer(struct gfs2_inode *ip,
  60. struct buffer_head **bhp)
  61. {
  62. return gfs2_meta_buffer(ip, GFS2_METATYPE_DI, ip->i_no_addr, bhp);
  63. }
  64. struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen);
  65. #define buffer_busy(bh) \
  66. ((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned)))
  67. #endif /* __DIO_DOT_H__ */