xfs_shared.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  4. * Copyright (c) 2013 Red Hat, Inc.
  5. * All Rights Reserved.
  6. */
  7. #ifndef __XFS_SHARED_H__
  8. #define __XFS_SHARED_H__
  9. /*
  10. * Definitions shared between kernel and userspace that don't fit into any other
  11. * header file that is shared with userspace.
  12. */
  13. struct xfs_ifork;
  14. struct xfs_buf;
  15. struct xfs_buf_ops;
  16. struct xfs_mount;
  17. struct xfs_trans;
  18. struct xfs_inode;
  19. /*
  20. * Buffer verifier operations are widely used, including userspace tools
  21. */
  22. extern const struct xfs_buf_ops xfs_agf_buf_ops;
  23. extern const struct xfs_buf_ops xfs_agi_buf_ops;
  24. extern const struct xfs_buf_ops xfs_agf_buf_ops;
  25. extern const struct xfs_buf_ops xfs_agfl_buf_ops;
  26. extern const struct xfs_buf_ops xfs_allocbt_buf_ops;
  27. extern const struct xfs_buf_ops xfs_rmapbt_buf_ops;
  28. extern const struct xfs_buf_ops xfs_refcountbt_buf_ops;
  29. extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops;
  30. extern const struct xfs_buf_ops xfs_attr3_rmt_buf_ops;
  31. extern const struct xfs_buf_ops xfs_bmbt_buf_ops;
  32. extern const struct xfs_buf_ops xfs_da3_node_buf_ops;
  33. extern const struct xfs_buf_ops xfs_dquot_buf_ops;
  34. extern const struct xfs_buf_ops xfs_symlink_buf_ops;
  35. extern const struct xfs_buf_ops xfs_agi_buf_ops;
  36. extern const struct xfs_buf_ops xfs_inobt_buf_ops;
  37. extern const struct xfs_buf_ops xfs_inode_buf_ops;
  38. extern const struct xfs_buf_ops xfs_inode_buf_ra_ops;
  39. extern const struct xfs_buf_ops xfs_dquot_buf_ops;
  40. extern const struct xfs_buf_ops xfs_dquot_buf_ra_ops;
  41. extern const struct xfs_buf_ops xfs_sb_buf_ops;
  42. extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;
  43. extern const struct xfs_buf_ops xfs_symlink_buf_ops;
  44. extern const struct xfs_buf_ops xfs_rtbuf_ops;
  45. /* log size calculation functions */
  46. int xfs_log_calc_unit_res(struct xfs_mount *mp, int unit_bytes);
  47. int xfs_log_calc_minimum_size(struct xfs_mount *);
  48. struct xfs_trans_res;
  49. void xfs_log_get_max_trans_res(struct xfs_mount *mp,
  50. struct xfs_trans_res *max_resp);
  51. /*
  52. * Values for t_flags.
  53. */
  54. #define XFS_TRANS_DIRTY 0x01 /* something needs to be logged */
  55. #define XFS_TRANS_SB_DIRTY 0x02 /* superblock is modified */
  56. #define XFS_TRANS_PERM_LOG_RES 0x04 /* xact took a permanent log res */
  57. #define XFS_TRANS_SYNC 0x08 /* make commit synchronous */
  58. #define XFS_TRANS_DQ_DIRTY 0x10 /* at least one dquot in trx dirty */
  59. #define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */
  60. #define XFS_TRANS_NO_WRITECOUNT 0x40 /* do not elevate SB writecount */
  61. #define XFS_TRANS_NOFS 0x80 /* pass KM_NOFS to kmem_alloc */
  62. /*
  63. * LOWMODE is used by the allocator to activate the lowspace algorithm - when
  64. * free space is running low the extent allocator may choose to allocate an
  65. * extent from an AG without leaving sufficient space for a btree split when
  66. * inserting the new extent. In this case the allocator will enable the
  67. * lowspace algorithm which is supposed to allow further allocations (such as
  68. * btree splits and newroots) to allocate from sequential AGs. In order to
  69. * avoid locking AGs out of order the lowspace algorithm will start searching
  70. * for free space from AG 0. If the correct transaction reservations have been
  71. * made then this algorithm will eventually find all the space it needs.
  72. */
  73. #define XFS_TRANS_LOWMODE 0x100 /* allocate in low space mode */
  74. /*
  75. * Field values for xfs_trans_mod_sb.
  76. */
  77. #define XFS_TRANS_SB_ICOUNT 0x00000001
  78. #define XFS_TRANS_SB_IFREE 0x00000002
  79. #define XFS_TRANS_SB_FDBLOCKS 0x00000004
  80. #define XFS_TRANS_SB_RES_FDBLOCKS 0x00000008
  81. #define XFS_TRANS_SB_FREXTENTS 0x00000010
  82. #define XFS_TRANS_SB_RES_FREXTENTS 0x00000020
  83. #define XFS_TRANS_SB_DBLOCKS 0x00000040
  84. #define XFS_TRANS_SB_AGCOUNT 0x00000080
  85. #define XFS_TRANS_SB_IMAXPCT 0x00000100
  86. #define XFS_TRANS_SB_REXTSIZE 0x00000200
  87. #define XFS_TRANS_SB_RBMBLOCKS 0x00000400
  88. #define XFS_TRANS_SB_RBLOCKS 0x00000800
  89. #define XFS_TRANS_SB_REXTENTS 0x00001000
  90. #define XFS_TRANS_SB_REXTSLOG 0x00002000
  91. /*
  92. * Here we centralize the specification of XFS meta-data buffer reference count
  93. * values. This determines how hard the buffer cache tries to hold onto the
  94. * buffer.
  95. */
  96. #define XFS_AGF_REF 4
  97. #define XFS_AGI_REF 4
  98. #define XFS_AGFL_REF 3
  99. #define XFS_INO_BTREE_REF 3
  100. #define XFS_ALLOC_BTREE_REF 2
  101. #define XFS_BMAP_BTREE_REF 2
  102. #define XFS_RMAP_BTREE_REF 2
  103. #define XFS_DIR_BTREE_REF 2
  104. #define XFS_INO_REF 2
  105. #define XFS_ATTR_BTREE_REF 1
  106. #define XFS_DQUOT_REF 1
  107. #define XFS_REFC_BTREE_REF 1
  108. #define XFS_SSB_REF 0
  109. /*
  110. * Flags for xfs_trans_ichgtime().
  111. */
  112. #define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */
  113. #define XFS_ICHGTIME_CHG 0x2 /* inode field change timestamp */
  114. #define XFS_ICHGTIME_CREATE 0x4 /* inode create timestamp */
  115. /*
  116. * Symlink decoding/encoding functions
  117. */
  118. int xfs_symlink_blocks(struct xfs_mount *mp, int pathlen);
  119. int xfs_symlink_hdr_set(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
  120. uint32_t size, struct xfs_buf *bp);
  121. bool xfs_symlink_hdr_ok(xfs_ino_t ino, uint32_t offset,
  122. uint32_t size, struct xfs_buf *bp);
  123. void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
  124. struct xfs_inode *ip, struct xfs_ifork *ifp);
  125. xfs_failaddr_t xfs_symlink_shortform_verify(struct xfs_inode *ip);
  126. #endif /* __XFS_SHARED_H__ */