xfs_shared.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  3. * Copyright (c) 2013 Red Hat, Inc.
  4. * All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it would be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write the Free Software Foundation,
  17. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #ifndef __XFS_SHARED_H__
  20. #define __XFS_SHARED_H__
  21. /*
  22. * Definitions shared between kernel and userspace that don't fit into any other
  23. * header file that is shared with userspace.
  24. */
  25. struct xfs_ifork;
  26. struct xfs_buf;
  27. struct xfs_buf_ops;
  28. struct xfs_mount;
  29. struct xfs_trans;
  30. struct xfs_inode;
  31. /*
  32. * Buffer verifier operations are widely used, including userspace tools
  33. */
  34. extern const struct xfs_buf_ops xfs_agf_buf_ops;
  35. extern const struct xfs_buf_ops xfs_agi_buf_ops;
  36. extern const struct xfs_buf_ops xfs_agf_buf_ops;
  37. extern const struct xfs_buf_ops xfs_agfl_buf_ops;
  38. extern const struct xfs_buf_ops xfs_allocbt_buf_ops;
  39. extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops;
  40. extern const struct xfs_buf_ops xfs_attr3_rmt_buf_ops;
  41. extern const struct xfs_buf_ops xfs_bmbt_buf_ops;
  42. extern const struct xfs_buf_ops xfs_da3_node_buf_ops;
  43. extern const struct xfs_buf_ops xfs_dquot_buf_ops;
  44. extern const struct xfs_buf_ops xfs_symlink_buf_ops;
  45. extern const struct xfs_buf_ops xfs_agi_buf_ops;
  46. extern const struct xfs_buf_ops xfs_inobt_buf_ops;
  47. extern const struct xfs_buf_ops xfs_inode_buf_ops;
  48. extern const struct xfs_buf_ops xfs_inode_buf_ra_ops;
  49. extern const struct xfs_buf_ops xfs_dquot_buf_ops;
  50. extern const struct xfs_buf_ops xfs_sb_buf_ops;
  51. extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;
  52. extern const struct xfs_buf_ops xfs_symlink_buf_ops;
  53. /*
  54. * Transaction types. Used to distinguish types of buffers. These never reach
  55. * the log.
  56. */
  57. #define XFS_TRANS_SETATTR_NOT_SIZE 1
  58. #define XFS_TRANS_SETATTR_SIZE 2
  59. #define XFS_TRANS_INACTIVE 3
  60. #define XFS_TRANS_CREATE 4
  61. #define XFS_TRANS_CREATE_TRUNC 5
  62. #define XFS_TRANS_TRUNCATE_FILE 6
  63. #define XFS_TRANS_REMOVE 7
  64. #define XFS_TRANS_LINK 8
  65. #define XFS_TRANS_RENAME 9
  66. #define XFS_TRANS_MKDIR 10
  67. #define XFS_TRANS_RMDIR 11
  68. #define XFS_TRANS_SYMLINK 12
  69. #define XFS_TRANS_SET_DMATTRS 13
  70. #define XFS_TRANS_GROWFS 14
  71. #define XFS_TRANS_STRAT_WRITE 15
  72. #define XFS_TRANS_DIOSTRAT 16
  73. /* 17 was XFS_TRANS_WRITE_SYNC */
  74. #define XFS_TRANS_WRITEID 18
  75. #define XFS_TRANS_ADDAFORK 19
  76. #define XFS_TRANS_ATTRINVAL 20
  77. #define XFS_TRANS_ATRUNCATE 21
  78. #define XFS_TRANS_ATTR_SET 22
  79. #define XFS_TRANS_ATTR_RM 23
  80. #define XFS_TRANS_ATTR_FLAG 24
  81. #define XFS_TRANS_CLEAR_AGI_BUCKET 25
  82. #define XFS_TRANS_QM_SBCHANGE 26
  83. /*
  84. * Dummy entries since we use the transaction type to index into the
  85. * trans_type[] in xlog_recover_print_trans_head()
  86. */
  87. #define XFS_TRANS_DUMMY1 27
  88. #define XFS_TRANS_DUMMY2 28
  89. #define XFS_TRANS_QM_QUOTAOFF 29
  90. #define XFS_TRANS_QM_DQALLOC 30
  91. #define XFS_TRANS_QM_SETQLIM 31
  92. #define XFS_TRANS_QM_DQCLUSTER 32
  93. #define XFS_TRANS_QM_QINOCREATE 33
  94. #define XFS_TRANS_QM_QUOTAOFF_END 34
  95. #define XFS_TRANS_SB_UNIT 35
  96. #define XFS_TRANS_FSYNC_TS 36
  97. #define XFS_TRANS_GROWFSRT_ALLOC 37
  98. #define XFS_TRANS_GROWFSRT_ZERO 38
  99. #define XFS_TRANS_GROWFSRT_FREE 39
  100. #define XFS_TRANS_SWAPEXT 40
  101. #define XFS_TRANS_SB_COUNT 41
  102. #define XFS_TRANS_CHECKPOINT 42
  103. #define XFS_TRANS_ICREATE 43
  104. #define XFS_TRANS_TYPE_MAX 43
  105. /* new transaction types need to be reflected in xfs_logprint(8) */
  106. #define XFS_TRANS_TYPES \
  107. { XFS_TRANS_SETATTR_NOT_SIZE, "SETATTR_NOT_SIZE" }, \
  108. { XFS_TRANS_SETATTR_SIZE, "SETATTR_SIZE" }, \
  109. { XFS_TRANS_INACTIVE, "INACTIVE" }, \
  110. { XFS_TRANS_CREATE, "CREATE" }, \
  111. { XFS_TRANS_CREATE_TRUNC, "CREATE_TRUNC" }, \
  112. { XFS_TRANS_TRUNCATE_FILE, "TRUNCATE_FILE" }, \
  113. { XFS_TRANS_REMOVE, "REMOVE" }, \
  114. { XFS_TRANS_LINK, "LINK" }, \
  115. { XFS_TRANS_RENAME, "RENAME" }, \
  116. { XFS_TRANS_MKDIR, "MKDIR" }, \
  117. { XFS_TRANS_RMDIR, "RMDIR" }, \
  118. { XFS_TRANS_SYMLINK, "SYMLINK" }, \
  119. { XFS_TRANS_SET_DMATTRS, "SET_DMATTRS" }, \
  120. { XFS_TRANS_GROWFS, "GROWFS" }, \
  121. { XFS_TRANS_STRAT_WRITE, "STRAT_WRITE" }, \
  122. { XFS_TRANS_DIOSTRAT, "DIOSTRAT" }, \
  123. { XFS_TRANS_WRITEID, "WRITEID" }, \
  124. { XFS_TRANS_ADDAFORK, "ADDAFORK" }, \
  125. { XFS_TRANS_ATTRINVAL, "ATTRINVAL" }, \
  126. { XFS_TRANS_ATRUNCATE, "ATRUNCATE" }, \
  127. { XFS_TRANS_ATTR_SET, "ATTR_SET" }, \
  128. { XFS_TRANS_ATTR_RM, "ATTR_RM" }, \
  129. { XFS_TRANS_ATTR_FLAG, "ATTR_FLAG" }, \
  130. { XFS_TRANS_CLEAR_AGI_BUCKET, "CLEAR_AGI_BUCKET" }, \
  131. { XFS_TRANS_QM_SBCHANGE, "QM_SBCHANGE" }, \
  132. { XFS_TRANS_QM_QUOTAOFF, "QM_QUOTAOFF" }, \
  133. { XFS_TRANS_QM_DQALLOC, "QM_DQALLOC" }, \
  134. { XFS_TRANS_QM_SETQLIM, "QM_SETQLIM" }, \
  135. { XFS_TRANS_QM_DQCLUSTER, "QM_DQCLUSTER" }, \
  136. { XFS_TRANS_QM_QINOCREATE, "QM_QINOCREATE" }, \
  137. { XFS_TRANS_QM_QUOTAOFF_END, "QM_QOFF_END" }, \
  138. { XFS_TRANS_SB_UNIT, "SB_UNIT" }, \
  139. { XFS_TRANS_FSYNC_TS, "FSYNC_TS" }, \
  140. { XFS_TRANS_GROWFSRT_ALLOC, "GROWFSRT_ALLOC" }, \
  141. { XFS_TRANS_GROWFSRT_ZERO, "GROWFSRT_ZERO" }, \
  142. { XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \
  143. { XFS_TRANS_SWAPEXT, "SWAPEXT" }, \
  144. { XFS_TRANS_SB_COUNT, "SB_COUNT" }, \
  145. { XFS_TRANS_CHECKPOINT, "CHECKPOINT" }, \
  146. { XFS_TRANS_DUMMY1, "DUMMY1" }, \
  147. { XFS_TRANS_DUMMY2, "DUMMY2" }, \
  148. { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" }
  149. /*
  150. * This structure is used to track log items associated with
  151. * a transaction. It points to the log item and keeps some
  152. * flags to track the state of the log item. It also tracks
  153. * the amount of space needed to log the item it describes
  154. * once we get to commit processing (see xfs_trans_commit()).
  155. */
  156. struct xfs_log_item_desc {
  157. struct xfs_log_item *lid_item;
  158. struct list_head lid_trans;
  159. unsigned char lid_flags;
  160. };
  161. #define XFS_LID_DIRTY 0x1
  162. /* log size calculation functions */
  163. int xfs_log_calc_unit_res(struct xfs_mount *mp, int unit_bytes);
  164. int xfs_log_calc_minimum_size(struct xfs_mount *);
  165. /*
  166. * Values for t_flags.
  167. */
  168. #define XFS_TRANS_DIRTY 0x01 /* something needs to be logged */
  169. #define XFS_TRANS_SB_DIRTY 0x02 /* superblock is modified */
  170. #define XFS_TRANS_PERM_LOG_RES 0x04 /* xact took a permanent log res */
  171. #define XFS_TRANS_SYNC 0x08 /* make commit synchronous */
  172. #define XFS_TRANS_DQ_DIRTY 0x10 /* at least one dquot in trx dirty */
  173. #define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */
  174. #define XFS_TRANS_FREEZE_PROT 0x40 /* Transaction has elevated writer
  175. count in superblock */
  176. /*
  177. * Values for call flags parameter.
  178. */
  179. #define XFS_TRANS_RELEASE_LOG_RES 0x4
  180. #define XFS_TRANS_ABORT 0x8
  181. /*
  182. * Field values for xfs_trans_mod_sb.
  183. */
  184. #define XFS_TRANS_SB_ICOUNT 0x00000001
  185. #define XFS_TRANS_SB_IFREE 0x00000002
  186. #define XFS_TRANS_SB_FDBLOCKS 0x00000004
  187. #define XFS_TRANS_SB_RES_FDBLOCKS 0x00000008
  188. #define XFS_TRANS_SB_FREXTENTS 0x00000010
  189. #define XFS_TRANS_SB_RES_FREXTENTS 0x00000020
  190. #define XFS_TRANS_SB_DBLOCKS 0x00000040
  191. #define XFS_TRANS_SB_AGCOUNT 0x00000080
  192. #define XFS_TRANS_SB_IMAXPCT 0x00000100
  193. #define XFS_TRANS_SB_REXTSIZE 0x00000200
  194. #define XFS_TRANS_SB_RBMBLOCKS 0x00000400
  195. #define XFS_TRANS_SB_RBLOCKS 0x00000800
  196. #define XFS_TRANS_SB_REXTENTS 0x00001000
  197. #define XFS_TRANS_SB_REXTSLOG 0x00002000
  198. /*
  199. * Here we centralize the specification of XFS meta-data buffer reference count
  200. * values. This determines how hard the buffer cache tries to hold onto the
  201. * buffer.
  202. */
  203. #define XFS_AGF_REF 4
  204. #define XFS_AGI_REF 4
  205. #define XFS_AGFL_REF 3
  206. #define XFS_INO_BTREE_REF 3
  207. #define XFS_ALLOC_BTREE_REF 2
  208. #define XFS_BMAP_BTREE_REF 2
  209. #define XFS_DIR_BTREE_REF 2
  210. #define XFS_INO_REF 2
  211. #define XFS_ATTR_BTREE_REF 1
  212. #define XFS_DQUOT_REF 1
  213. /*
  214. * Flags for xfs_trans_ichgtime().
  215. */
  216. #define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */
  217. #define XFS_ICHGTIME_CHG 0x2 /* inode field change timestamp */
  218. #define XFS_ICHGTIME_CREATE 0x4 /* inode create timestamp */
  219. /*
  220. * Symlink decoding/encoding functions
  221. */
  222. int xfs_symlink_blocks(struct xfs_mount *mp, int pathlen);
  223. int xfs_symlink_hdr_set(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
  224. uint32_t size, struct xfs_buf *bp);
  225. bool xfs_symlink_hdr_ok(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
  226. uint32_t size, struct xfs_buf *bp);
  227. void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
  228. struct xfs_inode *ip, struct xfs_ifork *ifp);
  229. #endif /* __XFS_SHARED_H__ */