xfs_trans.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. /*
  2. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_TRANS_H__
  19. #define __XFS_TRANS_H__
  20. /*
  21. * This is the structure written in the log at the head of
  22. * every transaction. It identifies the type and id of the
  23. * transaction, and contains the number of items logged by
  24. * the transaction so we know how many to expect during recovery.
  25. *
  26. * Do not change the below structure without redoing the code in
  27. * xlog_recover_add_to_trans() and xlog_recover_add_to_cont_trans().
  28. */
  29. typedef struct xfs_trans_header {
  30. uint th_magic; /* magic number */
  31. uint th_type; /* transaction type */
  32. __int32_t th_tid; /* transaction id (unused) */
  33. uint th_num_items; /* num items logged by trans */
  34. } xfs_trans_header_t;
  35. #define XFS_TRANS_HEADER_MAGIC 0x5452414e /* TRAN */
  36. /*
  37. * Log item types.
  38. */
  39. #define XFS_LI_EFI 0x1236
  40. #define XFS_LI_EFD 0x1237
  41. #define XFS_LI_IUNLINK 0x1238
  42. #define XFS_LI_INODE 0x123b /* aligned ino chunks, var-size ibufs */
  43. #define XFS_LI_BUF 0x123c /* v2 bufs, variable sized inode bufs */
  44. #define XFS_LI_DQUOT 0x123d
  45. #define XFS_LI_QUOTAOFF 0x123e
  46. /*
  47. * Transaction types. Used to distinguish types of buffers.
  48. */
  49. #define XFS_TRANS_SETATTR_NOT_SIZE 1
  50. #define XFS_TRANS_SETATTR_SIZE 2
  51. #define XFS_TRANS_INACTIVE 3
  52. #define XFS_TRANS_CREATE 4
  53. #define XFS_TRANS_CREATE_TRUNC 5
  54. #define XFS_TRANS_TRUNCATE_FILE 6
  55. #define XFS_TRANS_REMOVE 7
  56. #define XFS_TRANS_LINK 8
  57. #define XFS_TRANS_RENAME 9
  58. #define XFS_TRANS_MKDIR 10
  59. #define XFS_TRANS_RMDIR 11
  60. #define XFS_TRANS_SYMLINK 12
  61. #define XFS_TRANS_SET_DMATTRS 13
  62. #define XFS_TRANS_GROWFS 14
  63. #define XFS_TRANS_STRAT_WRITE 15
  64. #define XFS_TRANS_DIOSTRAT 16
  65. #define XFS_TRANS_WRITE_SYNC 17
  66. #define XFS_TRANS_WRITEID 18
  67. #define XFS_TRANS_ADDAFORK 19
  68. #define XFS_TRANS_ATTRINVAL 20
  69. #define XFS_TRANS_ATRUNCATE 21
  70. #define XFS_TRANS_ATTR_SET 22
  71. #define XFS_TRANS_ATTR_RM 23
  72. #define XFS_TRANS_ATTR_FLAG 24
  73. #define XFS_TRANS_CLEAR_AGI_BUCKET 25
  74. #define XFS_TRANS_QM_SBCHANGE 26
  75. /*
  76. * Dummy entries since we use the transaction type to index into the
  77. * trans_type[] in xlog_recover_print_trans_head()
  78. */
  79. #define XFS_TRANS_DUMMY1 27
  80. #define XFS_TRANS_DUMMY2 28
  81. #define XFS_TRANS_QM_QUOTAOFF 29
  82. #define XFS_TRANS_QM_DQALLOC 30
  83. #define XFS_TRANS_QM_SETQLIM 31
  84. #define XFS_TRANS_QM_DQCLUSTER 32
  85. #define XFS_TRANS_QM_QINOCREATE 33
  86. #define XFS_TRANS_QM_QUOTAOFF_END 34
  87. #define XFS_TRANS_SB_UNIT 35
  88. #define XFS_TRANS_FSYNC_TS 36
  89. #define XFS_TRANS_GROWFSRT_ALLOC 37
  90. #define XFS_TRANS_GROWFSRT_ZERO 38
  91. #define XFS_TRANS_GROWFSRT_FREE 39
  92. #define XFS_TRANS_SWAPEXT 40
  93. #define XFS_TRANS_SB_COUNT 41
  94. #define XFS_TRANS_TYPE_MAX 41
  95. /* new transaction types need to be reflected in xfs_logprint(8) */
  96. #ifdef __KERNEL__
  97. struct xfs_buf;
  98. struct xfs_buftarg;
  99. struct xfs_efd_log_item;
  100. struct xfs_efi_log_item;
  101. struct xfs_inode;
  102. struct xfs_item_ops;
  103. struct xfs_log_iovec;
  104. struct xfs_log_item;
  105. struct xfs_log_item_desc;
  106. struct xfs_mount;
  107. struct xfs_trans;
  108. struct xfs_dquot_acct;
  109. typedef struct xfs_log_item {
  110. struct list_head li_ail; /* AIL pointers */
  111. xfs_lsn_t li_lsn; /* last on-disk lsn */
  112. struct xfs_log_item_desc *li_desc; /* ptr to current desc*/
  113. struct xfs_mount *li_mountp; /* ptr to fs mount */
  114. uint li_type; /* item type */
  115. uint li_flags; /* misc flags */
  116. struct xfs_log_item *li_bio_list; /* buffer item list */
  117. void (*li_cb)(struct xfs_buf *,
  118. struct xfs_log_item *);
  119. /* buffer item iodone */
  120. /* callback func */
  121. struct xfs_item_ops *li_ops; /* function list */
  122. } xfs_log_item_t;
  123. #define XFS_LI_IN_AIL 0x1
  124. #define XFS_LI_ABORTED 0x2
  125. typedef struct xfs_item_ops {
  126. uint (*iop_size)(xfs_log_item_t *);
  127. void (*iop_format)(xfs_log_item_t *, struct xfs_log_iovec *);
  128. void (*iop_pin)(xfs_log_item_t *);
  129. void (*iop_unpin)(xfs_log_item_t *, int);
  130. void (*iop_unpin_remove)(xfs_log_item_t *, struct xfs_trans *);
  131. uint (*iop_trylock)(xfs_log_item_t *);
  132. void (*iop_unlock)(xfs_log_item_t *);
  133. xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t);
  134. void (*iop_push)(xfs_log_item_t *);
  135. void (*iop_pushbuf)(xfs_log_item_t *);
  136. void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t);
  137. } xfs_item_ops_t;
  138. #define IOP_SIZE(ip) (*(ip)->li_ops->iop_size)(ip)
  139. #define IOP_FORMAT(ip,vp) (*(ip)->li_ops->iop_format)(ip, vp)
  140. #define IOP_PIN(ip) (*(ip)->li_ops->iop_pin)(ip)
  141. #define IOP_UNPIN(ip, flags) (*(ip)->li_ops->iop_unpin)(ip, flags)
  142. #define IOP_UNPIN_REMOVE(ip,tp) (*(ip)->li_ops->iop_unpin_remove)(ip, tp)
  143. #define IOP_TRYLOCK(ip) (*(ip)->li_ops->iop_trylock)(ip)
  144. #define IOP_UNLOCK(ip) (*(ip)->li_ops->iop_unlock)(ip)
  145. #define IOP_COMMITTED(ip, lsn) (*(ip)->li_ops->iop_committed)(ip, lsn)
  146. #define IOP_PUSH(ip) (*(ip)->li_ops->iop_push)(ip)
  147. #define IOP_PUSHBUF(ip) (*(ip)->li_ops->iop_pushbuf)(ip)
  148. #define IOP_COMMITTING(ip, lsn) (*(ip)->li_ops->iop_committing)(ip, lsn)
  149. /*
  150. * Return values for the IOP_TRYLOCK() routines.
  151. */
  152. #define XFS_ITEM_SUCCESS 0
  153. #define XFS_ITEM_PINNED 1
  154. #define XFS_ITEM_LOCKED 2
  155. #define XFS_ITEM_FLUSHING 3
  156. #define XFS_ITEM_PUSHBUF 4
  157. #endif /* __KERNEL__ */
  158. /*
  159. * This structure is used to track log items associated with
  160. * a transaction. It points to the log item and keeps some
  161. * flags to track the state of the log item. It also tracks
  162. * the amount of space needed to log the item it describes
  163. * once we get to commit processing (see xfs_trans_commit()).
  164. */
  165. typedef struct xfs_log_item_desc {
  166. xfs_log_item_t *lid_item;
  167. ushort lid_size;
  168. unsigned char lid_flags;
  169. unsigned char lid_index;
  170. } xfs_log_item_desc_t;
  171. #define XFS_LID_DIRTY 0x1
  172. #define XFS_LID_PINNED 0x2
  173. #define XFS_LID_BUF_STALE 0x8
  174. /*
  175. * This structure is used to maintain a chunk list of log_item_desc
  176. * structures. The free field is a bitmask indicating which descriptors
  177. * in this chunk's array are free. The unused field is the first value
  178. * not used since this chunk was allocated.
  179. */
  180. #define XFS_LIC_NUM_SLOTS 15
  181. typedef struct xfs_log_item_chunk {
  182. struct xfs_log_item_chunk *lic_next;
  183. ushort lic_free;
  184. ushort lic_unused;
  185. xfs_log_item_desc_t lic_descs[XFS_LIC_NUM_SLOTS];
  186. } xfs_log_item_chunk_t;
  187. #define XFS_LIC_MAX_SLOT (XFS_LIC_NUM_SLOTS - 1)
  188. #define XFS_LIC_FREEMASK ((1 << XFS_LIC_NUM_SLOTS) - 1)
  189. /*
  190. * Initialize the given chunk. Set the chunk's free descriptor mask
  191. * to indicate that all descriptors are free. The caller gets to set
  192. * lic_unused to the right value (0 matches all free). The
  193. * lic_descs.lid_index values are set up as each desc is allocated.
  194. */
  195. static inline void xfs_lic_init(xfs_log_item_chunk_t *cp)
  196. {
  197. cp->lic_free = XFS_LIC_FREEMASK;
  198. }
  199. static inline void xfs_lic_init_slot(xfs_log_item_chunk_t *cp, int slot)
  200. {
  201. cp->lic_descs[slot].lid_index = (unsigned char)(slot);
  202. }
  203. static inline int xfs_lic_vacancy(xfs_log_item_chunk_t *cp)
  204. {
  205. return cp->lic_free & XFS_LIC_FREEMASK;
  206. }
  207. static inline void xfs_lic_all_free(xfs_log_item_chunk_t *cp)
  208. {
  209. cp->lic_free = XFS_LIC_FREEMASK;
  210. }
  211. static inline int xfs_lic_are_all_free(xfs_log_item_chunk_t *cp)
  212. {
  213. return ((cp->lic_free & XFS_LIC_FREEMASK) == XFS_LIC_FREEMASK);
  214. }
  215. static inline int xfs_lic_isfree(xfs_log_item_chunk_t *cp, int slot)
  216. {
  217. return (cp->lic_free & (1 << slot));
  218. }
  219. static inline void xfs_lic_claim(xfs_log_item_chunk_t *cp, int slot)
  220. {
  221. cp->lic_free &= ~(1 << slot);
  222. }
  223. static inline void xfs_lic_relse(xfs_log_item_chunk_t *cp, int slot)
  224. {
  225. cp->lic_free |= 1 << slot;
  226. }
  227. static inline xfs_log_item_desc_t *
  228. xfs_lic_slot(xfs_log_item_chunk_t *cp, int slot)
  229. {
  230. return &(cp->lic_descs[slot]);
  231. }
  232. static inline int xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp)
  233. {
  234. return (uint)dp->lid_index;
  235. }
  236. /*
  237. * Calculate the address of a chunk given a descriptor pointer:
  238. * dp - dp->lid_index give the address of the start of the lic_descs array.
  239. * From this we subtract the offset of the lic_descs field in a chunk.
  240. * All of this yields the address of the chunk, which is
  241. * cast to a chunk pointer.
  242. */
  243. static inline xfs_log_item_chunk_t *
  244. xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp)
  245. {
  246. return (xfs_log_item_chunk_t*) \
  247. (((xfs_caddr_t)((dp) - (dp)->lid_index)) - \
  248. (xfs_caddr_t)(((xfs_log_item_chunk_t*)0)->lic_descs));
  249. }
  250. #ifdef __KERNEL__
  251. /*
  252. * This structure is used to maintain a list of block ranges that have been
  253. * freed in the transaction. The ranges are listed in the perag[] busy list
  254. * between when they're freed and the transaction is committed to disk.
  255. */
  256. typedef struct xfs_log_busy_slot {
  257. xfs_agnumber_t lbc_ag;
  258. ushort lbc_idx; /* index in perag.busy[] */
  259. } xfs_log_busy_slot_t;
  260. #define XFS_LBC_NUM_SLOTS 31
  261. typedef struct xfs_log_busy_chunk {
  262. struct xfs_log_busy_chunk *lbc_next;
  263. uint lbc_free; /* free slots bitmask */
  264. ushort lbc_unused; /* first unused */
  265. xfs_log_busy_slot_t lbc_busy[XFS_LBC_NUM_SLOTS];
  266. } xfs_log_busy_chunk_t;
  267. #define XFS_LBC_MAX_SLOT (XFS_LBC_NUM_SLOTS - 1)
  268. #define XFS_LBC_FREEMASK ((1U << XFS_LBC_NUM_SLOTS) - 1)
  269. #define XFS_LBC_INIT(cp) ((cp)->lbc_free = XFS_LBC_FREEMASK)
  270. #define XFS_LBC_CLAIM(cp, slot) ((cp)->lbc_free &= ~(1 << (slot)))
  271. #define XFS_LBC_SLOT(cp, slot) (&((cp)->lbc_busy[(slot)]))
  272. #define XFS_LBC_VACANCY(cp) (((cp)->lbc_free) & XFS_LBC_FREEMASK)
  273. #define XFS_LBC_ISFREE(cp, slot) ((cp)->lbc_free & (1 << (slot)))
  274. /*
  275. * This is the type of function which can be given to xfs_trans_callback()
  276. * to be called upon the transaction's commit to disk.
  277. */
  278. typedef void (*xfs_trans_callback_t)(struct xfs_trans *, void *);
  279. /*
  280. * This is the structure maintained for every active transaction.
  281. */
  282. typedef struct xfs_trans {
  283. unsigned int t_magic; /* magic number */
  284. xfs_log_callback_t t_logcb; /* log callback struct */
  285. unsigned int t_type; /* transaction type */
  286. unsigned int t_log_res; /* amt of log space resvd */
  287. unsigned int t_log_count; /* count for perm log res */
  288. unsigned int t_blk_res; /* # of blocks resvd */
  289. unsigned int t_blk_res_used; /* # of resvd blocks used */
  290. unsigned int t_rtx_res; /* # of rt extents resvd */
  291. unsigned int t_rtx_res_used; /* # of resvd rt extents used */
  292. xfs_log_ticket_t t_ticket; /* log mgr ticket */
  293. xfs_lsn_t t_lsn; /* log seq num of start of
  294. * transaction. */
  295. xfs_lsn_t t_commit_lsn; /* log seq num of end of
  296. * transaction. */
  297. struct xfs_mount *t_mountp; /* ptr to fs mount struct */
  298. struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */
  299. xfs_trans_callback_t t_callback; /* transaction callback */
  300. void *t_callarg; /* callback arg */
  301. unsigned int t_flags; /* misc flags */
  302. int64_t t_icount_delta; /* superblock icount change */
  303. int64_t t_ifree_delta; /* superblock ifree change */
  304. int64_t t_fdblocks_delta; /* superblock fdblocks chg */
  305. int64_t t_res_fdblocks_delta; /* on-disk only chg */
  306. int64_t t_frextents_delta;/* superblock freextents chg*/
  307. int64_t t_res_frextents_delta; /* on-disk only chg */
  308. #ifdef DEBUG
  309. int64_t t_ag_freeblks_delta; /* debugging counter */
  310. int64_t t_ag_flist_delta; /* debugging counter */
  311. int64_t t_ag_btree_delta; /* debugging counter */
  312. #endif
  313. int64_t t_dblocks_delta;/* superblock dblocks change */
  314. int64_t t_agcount_delta;/* superblock agcount change */
  315. int64_t t_imaxpct_delta;/* superblock imaxpct change */
  316. int64_t t_rextsize_delta;/* superblock rextsize chg */
  317. int64_t t_rbmblocks_delta;/* superblock rbmblocks chg */
  318. int64_t t_rblocks_delta;/* superblock rblocks change */
  319. int64_t t_rextents_delta;/* superblocks rextents chg */
  320. int64_t t_rextslog_delta;/* superblocks rextslog chg */
  321. unsigned int t_items_free; /* log item descs free */
  322. xfs_log_item_chunk_t t_items; /* first log item desc chunk */
  323. xfs_trans_header_t t_header; /* header for in-log trans */
  324. unsigned int t_busy_free; /* busy descs free */
  325. xfs_log_busy_chunk_t t_busy; /* busy/async free blocks */
  326. unsigned long t_pflags; /* saved process flags state */
  327. } xfs_trans_t;
  328. #endif /* __KERNEL__ */
  329. #define XFS_TRANS_MAGIC 0x5452414E /* 'TRAN' */
  330. /*
  331. * Values for t_flags.
  332. */
  333. #define XFS_TRANS_DIRTY 0x01 /* something needs to be logged */
  334. #define XFS_TRANS_SB_DIRTY 0x02 /* superblock is modified */
  335. #define XFS_TRANS_PERM_LOG_RES 0x04 /* xact took a permanent log res */
  336. #define XFS_TRANS_SYNC 0x08 /* make commit synchronous */
  337. #define XFS_TRANS_DQ_DIRTY 0x10 /* at least one dquot in trx dirty */
  338. #define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */
  339. /*
  340. * Values for call flags parameter.
  341. */
  342. #define XFS_TRANS_NOSLEEP 0x1
  343. #define XFS_TRANS_WAIT 0x2
  344. #define XFS_TRANS_RELEASE_LOG_RES 0x4
  345. #define XFS_TRANS_ABORT 0x8
  346. /*
  347. * Field values for xfs_trans_mod_sb.
  348. */
  349. #define XFS_TRANS_SB_ICOUNT 0x00000001
  350. #define XFS_TRANS_SB_IFREE 0x00000002
  351. #define XFS_TRANS_SB_FDBLOCKS 0x00000004
  352. #define XFS_TRANS_SB_RES_FDBLOCKS 0x00000008
  353. #define XFS_TRANS_SB_FREXTENTS 0x00000010
  354. #define XFS_TRANS_SB_RES_FREXTENTS 0x00000020
  355. #define XFS_TRANS_SB_DBLOCKS 0x00000040
  356. #define XFS_TRANS_SB_AGCOUNT 0x00000080
  357. #define XFS_TRANS_SB_IMAXPCT 0x00000100
  358. #define XFS_TRANS_SB_REXTSIZE 0x00000200
  359. #define XFS_TRANS_SB_RBMBLOCKS 0x00000400
  360. #define XFS_TRANS_SB_RBLOCKS 0x00000800
  361. #define XFS_TRANS_SB_REXTENTS 0x00001000
  362. #define XFS_TRANS_SB_REXTSLOG 0x00002000
  363. /*
  364. * Various log reservation values.
  365. * These are based on the size of the file system block
  366. * because that is what most transactions manipulate.
  367. * Each adds in an additional 128 bytes per item logged to
  368. * try to account for the overhead of the transaction mechanism.
  369. *
  370. * Note:
  371. * Most of the reservations underestimate the number of allocation
  372. * groups into which they could free extents in the xfs_bmap_finish()
  373. * call. This is because the number in the worst case is quite high
  374. * and quite unusual. In order to fix this we need to change
  375. * xfs_bmap_finish() to free extents in only a single AG at a time.
  376. * This will require changes to the EFI code as well, however, so that
  377. * the EFI for the extents not freed is logged again in each transaction.
  378. * See bug 261917.
  379. */
  380. /*
  381. * Per-extent log reservation for the allocation btree changes
  382. * involved in freeing or allocating an extent.
  383. * 2 trees * (2 blocks/level * max depth - 1) * block size
  384. */
  385. #define XFS_ALLOCFREE_LOG_RES(mp,nx) \
  386. ((nx) * (2 * XFS_FSB_TO_B((mp), 2 * XFS_AG_MAXLEVELS(mp) - 1)))
  387. #define XFS_ALLOCFREE_LOG_COUNT(mp,nx) \
  388. ((nx) * (2 * (2 * XFS_AG_MAXLEVELS(mp) - 1)))
  389. /*
  390. * Per-directory log reservation for any directory change.
  391. * dir blocks: (1 btree block per level + data block + free block) * dblock size
  392. * bmap btree: (levels + 2) * max depth * block size
  393. * v2 directory blocks can be fragmented below the dirblksize down to the fsb
  394. * size, so account for that in the DAENTER macros.
  395. */
  396. #define XFS_DIROP_LOG_RES(mp) \
  397. (XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \
  398. (XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)))
  399. #define XFS_DIROP_LOG_COUNT(mp) \
  400. (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \
  401. XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)
  402. /*
  403. * In a write transaction we can allocate a maximum of 2
  404. * extents. This gives:
  405. * the inode getting the new extents: inode size
  406. * the inode\'s bmap btree: max depth * block size
  407. * the agfs of the ags from which the extents are allocated: 2 * sector
  408. * the superblock free block counter: sector size
  409. * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
  410. * And the bmap_finish transaction can free bmap blocks in a join:
  411. * the agfs of the ags containing the blocks: 2 * sector size
  412. * the agfls of the ags containing the blocks: 2 * sector size
  413. * the super block free block counter: sector size
  414. * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
  415. */
  416. #define XFS_CALC_WRITE_LOG_RES(mp) \
  417. (MAX( \
  418. ((mp)->m_sb.sb_inodesize + \
  419. XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)) + \
  420. (2 * (mp)->m_sb.sb_sectsize) + \
  421. (mp)->m_sb.sb_sectsize + \
  422. XFS_ALLOCFREE_LOG_RES(mp, 2) + \
  423. (128 * (4 + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + XFS_ALLOCFREE_LOG_COUNT(mp, 2)))),\
  424. ((2 * (mp)->m_sb.sb_sectsize) + \
  425. (2 * (mp)->m_sb.sb_sectsize) + \
  426. (mp)->m_sb.sb_sectsize + \
  427. XFS_ALLOCFREE_LOG_RES(mp, 2) + \
  428. (128 * (5 + XFS_ALLOCFREE_LOG_COUNT(mp, 2))))))
  429. #define XFS_WRITE_LOG_RES(mp) ((mp)->m_reservations.tr_write)
  430. /*
  431. * In truncating a file we free up to two extents at once. We can modify:
  432. * the inode being truncated: inode size
  433. * the inode\'s bmap btree: (max depth + 1) * block size
  434. * And the bmap_finish transaction can free the blocks and bmap blocks:
  435. * the agf for each of the ags: 4 * sector size
  436. * the agfl for each of the ags: 4 * sector size
  437. * the super block to reflect the freed blocks: sector size
  438. * worst case split in allocation btrees per extent assuming 4 extents:
  439. * 4 exts * 2 trees * (2 * max depth - 1) * block size
  440. * the inode btree: max depth * blocksize
  441. * the allocation btrees: 2 trees * (max depth - 1) * block size
  442. */
  443. #define XFS_CALC_ITRUNCATE_LOG_RES(mp) \
  444. (MAX( \
  445. ((mp)->m_sb.sb_inodesize + \
  446. XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + 1) + \
  447. (128 * (2 + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)))), \
  448. ((4 * (mp)->m_sb.sb_sectsize) + \
  449. (4 * (mp)->m_sb.sb_sectsize) + \
  450. (mp)->m_sb.sb_sectsize + \
  451. XFS_ALLOCFREE_LOG_RES(mp, 4) + \
  452. (128 * (9 + XFS_ALLOCFREE_LOG_COUNT(mp, 4))) + \
  453. (128 * 5) + \
  454. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  455. (128 * (2 + XFS_IALLOC_BLOCKS(mp) + XFS_IN_MAXLEVELS(mp) + \
  456. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))))
  457. #define XFS_ITRUNCATE_LOG_RES(mp) ((mp)->m_reservations.tr_itruncate)
  458. /*
  459. * In renaming a files we can modify:
  460. * the four inodes involved: 4 * inode size
  461. * the two directory btrees: 2 * (max depth + v2) * dir block size
  462. * the two directory bmap btrees: 2 * max depth * block size
  463. * And the bmap_finish transaction can free dir and bmap blocks (two sets
  464. * of bmap blocks) giving:
  465. * the agf for the ags in which the blocks live: 3 * sector size
  466. * the agfl for the ags in which the blocks live: 3 * sector size
  467. * the superblock for the free block count: sector size
  468. * the allocation btrees: 3 exts * 2 trees * (2 * max depth - 1) * block size
  469. */
  470. #define XFS_CALC_RENAME_LOG_RES(mp) \
  471. (MAX( \
  472. ((4 * (mp)->m_sb.sb_inodesize) + \
  473. (2 * XFS_DIROP_LOG_RES(mp)) + \
  474. (128 * (4 + 2 * XFS_DIROP_LOG_COUNT(mp)))), \
  475. ((3 * (mp)->m_sb.sb_sectsize) + \
  476. (3 * (mp)->m_sb.sb_sectsize) + \
  477. (mp)->m_sb.sb_sectsize + \
  478. XFS_ALLOCFREE_LOG_RES(mp, 3) + \
  479. (128 * (7 + XFS_ALLOCFREE_LOG_COUNT(mp, 3))))))
  480. #define XFS_RENAME_LOG_RES(mp) ((mp)->m_reservations.tr_rename)
  481. /*
  482. * For creating a link to an inode:
  483. * the parent directory inode: inode size
  484. * the linked inode: inode size
  485. * the directory btree could split: (max depth + v2) * dir block size
  486. * the directory bmap btree could join or split: (max depth + v2) * blocksize
  487. * And the bmap_finish transaction can free some bmap blocks giving:
  488. * the agf for the ag in which the blocks live: sector size
  489. * the agfl for the ag in which the blocks live: sector size
  490. * the superblock for the free block count: sector size
  491. * the allocation btrees: 2 trees * (2 * max depth - 1) * block size
  492. */
  493. #define XFS_CALC_LINK_LOG_RES(mp) \
  494. (MAX( \
  495. ((mp)->m_sb.sb_inodesize + \
  496. (mp)->m_sb.sb_inodesize + \
  497. XFS_DIROP_LOG_RES(mp) + \
  498. (128 * (2 + XFS_DIROP_LOG_COUNT(mp)))), \
  499. ((mp)->m_sb.sb_sectsize + \
  500. (mp)->m_sb.sb_sectsize + \
  501. (mp)->m_sb.sb_sectsize + \
  502. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  503. (128 * (3 + XFS_ALLOCFREE_LOG_COUNT(mp, 1))))))
  504. #define XFS_LINK_LOG_RES(mp) ((mp)->m_reservations.tr_link)
  505. /*
  506. * For removing a directory entry we can modify:
  507. * the parent directory inode: inode size
  508. * the removed inode: inode size
  509. * the directory btree could join: (max depth + v2) * dir block size
  510. * the directory bmap btree could join or split: (max depth + v2) * blocksize
  511. * And the bmap_finish transaction can free the dir and bmap blocks giving:
  512. * the agf for the ag in which the blocks live: 2 * sector size
  513. * the agfl for the ag in which the blocks live: 2 * sector size
  514. * the superblock for the free block count: sector size
  515. * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
  516. */
  517. #define XFS_CALC_REMOVE_LOG_RES(mp) \
  518. (MAX( \
  519. ((mp)->m_sb.sb_inodesize + \
  520. (mp)->m_sb.sb_inodesize + \
  521. XFS_DIROP_LOG_RES(mp) + \
  522. (128 * (2 + XFS_DIROP_LOG_COUNT(mp)))), \
  523. ((2 * (mp)->m_sb.sb_sectsize) + \
  524. (2 * (mp)->m_sb.sb_sectsize) + \
  525. (mp)->m_sb.sb_sectsize + \
  526. XFS_ALLOCFREE_LOG_RES(mp, 2) + \
  527. (128 * (5 + XFS_ALLOCFREE_LOG_COUNT(mp, 2))))))
  528. #define XFS_REMOVE_LOG_RES(mp) ((mp)->m_reservations.tr_remove)
  529. /*
  530. * For symlink we can modify:
  531. * the parent directory inode: inode size
  532. * the new inode: inode size
  533. * the inode btree entry: 1 block
  534. * the directory btree: (max depth + v2) * dir block size
  535. * the directory inode\'s bmap btree: (max depth + v2) * block size
  536. * the blocks for the symlink: 1 KB
  537. * Or in the first xact we allocate some inodes giving:
  538. * the agi and agf of the ag getting the new inodes: 2 * sectorsize
  539. * the inode blocks allocated: XFS_IALLOC_BLOCKS * blocksize
  540. * the inode btree: max depth * blocksize
  541. * the allocation btrees: 2 trees * (2 * max depth - 1) * block size
  542. */
  543. #define XFS_CALC_SYMLINK_LOG_RES(mp) \
  544. (MAX( \
  545. ((mp)->m_sb.sb_inodesize + \
  546. (mp)->m_sb.sb_inodesize + \
  547. XFS_FSB_TO_B(mp, 1) + \
  548. XFS_DIROP_LOG_RES(mp) + \
  549. 1024 + \
  550. (128 * (4 + XFS_DIROP_LOG_COUNT(mp)))), \
  551. (2 * (mp)->m_sb.sb_sectsize + \
  552. XFS_FSB_TO_B((mp), XFS_IALLOC_BLOCKS((mp))) + \
  553. XFS_FSB_TO_B((mp), XFS_IN_MAXLEVELS(mp)) + \
  554. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  555. (128 * (2 + XFS_IALLOC_BLOCKS(mp) + XFS_IN_MAXLEVELS(mp) + \
  556. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))))
  557. #define XFS_SYMLINK_LOG_RES(mp) ((mp)->m_reservations.tr_symlink)
  558. /*
  559. * For create we can modify:
  560. * the parent directory inode: inode size
  561. * the new inode: inode size
  562. * the inode btree entry: block size
  563. * the superblock for the nlink flag: sector size
  564. * the directory btree: (max depth + v2) * dir block size
  565. * the directory inode\'s bmap btree: (max depth + v2) * block size
  566. * Or in the first xact we allocate some inodes giving:
  567. * the agi and agf of the ag getting the new inodes: 2 * sectorsize
  568. * the superblock for the nlink flag: sector size
  569. * the inode blocks allocated: XFS_IALLOC_BLOCKS * blocksize
  570. * the inode btree: max depth * blocksize
  571. * the allocation btrees: 2 trees * (max depth - 1) * block size
  572. */
  573. #define XFS_CALC_CREATE_LOG_RES(mp) \
  574. (MAX( \
  575. ((mp)->m_sb.sb_inodesize + \
  576. (mp)->m_sb.sb_inodesize + \
  577. (mp)->m_sb.sb_sectsize + \
  578. XFS_FSB_TO_B(mp, 1) + \
  579. XFS_DIROP_LOG_RES(mp) + \
  580. (128 * (3 + XFS_DIROP_LOG_COUNT(mp)))), \
  581. (3 * (mp)->m_sb.sb_sectsize + \
  582. XFS_FSB_TO_B((mp), XFS_IALLOC_BLOCKS((mp))) + \
  583. XFS_FSB_TO_B((mp), XFS_IN_MAXLEVELS(mp)) + \
  584. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  585. (128 * (2 + XFS_IALLOC_BLOCKS(mp) + XFS_IN_MAXLEVELS(mp) + \
  586. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))))
  587. #define XFS_CREATE_LOG_RES(mp) ((mp)->m_reservations.tr_create)
  588. /*
  589. * Making a new directory is the same as creating a new file.
  590. */
  591. #define XFS_CALC_MKDIR_LOG_RES(mp) XFS_CALC_CREATE_LOG_RES(mp)
  592. #define XFS_MKDIR_LOG_RES(mp) ((mp)->m_reservations.tr_mkdir)
  593. /*
  594. * In freeing an inode we can modify:
  595. * the inode being freed: inode size
  596. * the super block free inode counter: sector size
  597. * the agi hash list and counters: sector size
  598. * the inode btree entry: block size
  599. * the on disk inode before ours in the agi hash list: inode cluster size
  600. * the inode btree: max depth * blocksize
  601. * the allocation btrees: 2 trees * (max depth - 1) * block size
  602. */
  603. #define XFS_CALC_IFREE_LOG_RES(mp) \
  604. ((mp)->m_sb.sb_inodesize + \
  605. (mp)->m_sb.sb_sectsize + \
  606. (mp)->m_sb.sb_sectsize + \
  607. XFS_FSB_TO_B((mp), 1) + \
  608. MAX((__uint16_t)XFS_FSB_TO_B((mp), 1), XFS_INODE_CLUSTER_SIZE(mp)) + \
  609. (128 * 5) + \
  610. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  611. (128 * (2 + XFS_IALLOC_BLOCKS(mp) + XFS_IN_MAXLEVELS(mp) + \
  612. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))
  613. #define XFS_IFREE_LOG_RES(mp) ((mp)->m_reservations.tr_ifree)
  614. /*
  615. * When only changing the inode we log the inode and possibly the superblock
  616. * We also add a bit of slop for the transaction stuff.
  617. */
  618. #define XFS_CALC_ICHANGE_LOG_RES(mp) ((mp)->m_sb.sb_inodesize + \
  619. (mp)->m_sb.sb_sectsize + 512)
  620. #define XFS_ICHANGE_LOG_RES(mp) ((mp)->m_reservations.tr_ichange)
  621. /*
  622. * Growing the data section of the filesystem.
  623. * superblock
  624. * agi and agf
  625. * allocation btrees
  626. */
  627. #define XFS_CALC_GROWDATA_LOG_RES(mp) \
  628. ((mp)->m_sb.sb_sectsize * 3 + \
  629. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  630. (128 * (3 + XFS_ALLOCFREE_LOG_COUNT(mp, 1))))
  631. #define XFS_GROWDATA_LOG_RES(mp) ((mp)->m_reservations.tr_growdata)
  632. /*
  633. * Growing the rt section of the filesystem.
  634. * In the first set of transactions (ALLOC) we allocate space to the
  635. * bitmap or summary files.
  636. * superblock: sector size
  637. * agf of the ag from which the extent is allocated: sector size
  638. * bmap btree for bitmap/summary inode: max depth * blocksize
  639. * bitmap/summary inode: inode size
  640. * allocation btrees for 1 block alloc: 2 * (2 * maxdepth - 1) * blocksize
  641. */
  642. #define XFS_CALC_GROWRTALLOC_LOG_RES(mp) \
  643. (2 * (mp)->m_sb.sb_sectsize + \
  644. XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)) + \
  645. (mp)->m_sb.sb_inodesize + \
  646. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  647. (128 * \
  648. (3 + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + \
  649. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))
  650. #define XFS_GROWRTALLOC_LOG_RES(mp) ((mp)->m_reservations.tr_growrtalloc)
  651. /*
  652. * Growing the rt section of the filesystem.
  653. * In the second set of transactions (ZERO) we zero the new metadata blocks.
  654. * one bitmap/summary block: blocksize
  655. */
  656. #define XFS_CALC_GROWRTZERO_LOG_RES(mp) \
  657. ((mp)->m_sb.sb_blocksize + 128)
  658. #define XFS_GROWRTZERO_LOG_RES(mp) ((mp)->m_reservations.tr_growrtzero)
  659. /*
  660. * Growing the rt section of the filesystem.
  661. * In the third set of transactions (FREE) we update metadata without
  662. * allocating any new blocks.
  663. * superblock: sector size
  664. * bitmap inode: inode size
  665. * summary inode: inode size
  666. * one bitmap block: blocksize
  667. * summary blocks: new summary size
  668. */
  669. #define XFS_CALC_GROWRTFREE_LOG_RES(mp) \
  670. ((mp)->m_sb.sb_sectsize + \
  671. 2 * (mp)->m_sb.sb_inodesize + \
  672. (mp)->m_sb.sb_blocksize + \
  673. (mp)->m_rsumsize + \
  674. (128 * 5))
  675. #define XFS_GROWRTFREE_LOG_RES(mp) ((mp)->m_reservations.tr_growrtfree)
  676. /*
  677. * Logging the inode modification timestamp on a synchronous write.
  678. * inode
  679. */
  680. #define XFS_CALC_SWRITE_LOG_RES(mp) \
  681. ((mp)->m_sb.sb_inodesize + 128)
  682. #define XFS_SWRITE_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)
  683. /*
  684. * Logging the inode timestamps on an fsync -- same as SWRITE
  685. * as long as SWRITE logs the entire inode core
  686. */
  687. #define XFS_FSYNC_TS_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)
  688. /*
  689. * Logging the inode mode bits when writing a setuid/setgid file
  690. * inode
  691. */
  692. #define XFS_CALC_WRITEID_LOG_RES(mp) \
  693. ((mp)->m_sb.sb_inodesize + 128)
  694. #define XFS_WRITEID_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)
  695. /*
  696. * Converting the inode from non-attributed to attributed.
  697. * the inode being converted: inode size
  698. * agf block and superblock (for block allocation)
  699. * the new block (directory sized)
  700. * bmap blocks for the new directory block
  701. * allocation btrees
  702. */
  703. #define XFS_CALC_ADDAFORK_LOG_RES(mp) \
  704. ((mp)->m_sb.sb_inodesize + \
  705. (mp)->m_sb.sb_sectsize * 2 + \
  706. (mp)->m_dirblksize + \
  707. XFS_FSB_TO_B(mp, (XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1)) + \
  708. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  709. (128 * (4 + (XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1) + \
  710. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))
  711. #define XFS_ADDAFORK_LOG_RES(mp) ((mp)->m_reservations.tr_addafork)
  712. /*
  713. * Removing the attribute fork of a file
  714. * the inode being truncated: inode size
  715. * the inode\'s bmap btree: max depth * block size
  716. * And the bmap_finish transaction can free the blocks and bmap blocks:
  717. * the agf for each of the ags: 4 * sector size
  718. * the agfl for each of the ags: 4 * sector size
  719. * the super block to reflect the freed blocks: sector size
  720. * worst case split in allocation btrees per extent assuming 4 extents:
  721. * 4 exts * 2 trees * (2 * max depth - 1) * block size
  722. */
  723. #define XFS_CALC_ATTRINVAL_LOG_RES(mp) \
  724. (MAX( \
  725. ((mp)->m_sb.sb_inodesize + \
  726. XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)) + \
  727. (128 * (1 + XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)))), \
  728. ((4 * (mp)->m_sb.sb_sectsize) + \
  729. (4 * (mp)->m_sb.sb_sectsize) + \
  730. (mp)->m_sb.sb_sectsize + \
  731. XFS_ALLOCFREE_LOG_RES(mp, 4) + \
  732. (128 * (9 + XFS_ALLOCFREE_LOG_COUNT(mp, 4))))))
  733. #define XFS_ATTRINVAL_LOG_RES(mp) ((mp)->m_reservations.tr_attrinval)
  734. /*
  735. * Setting an attribute.
  736. * the inode getting the attribute
  737. * the superblock for allocations
  738. * the agfs extents are allocated from
  739. * the attribute btree * max depth
  740. * the inode allocation btree
  741. * Since attribute transaction space is dependent on the size of the attribute,
  742. * the calculation is done partially at mount time and partially at runtime.
  743. */
  744. #define XFS_CALC_ATTRSET_LOG_RES(mp) \
  745. ((mp)->m_sb.sb_inodesize + \
  746. (mp)->m_sb.sb_sectsize + \
  747. XFS_FSB_TO_B((mp), XFS_DA_NODE_MAXDEPTH) + \
  748. (128 * (2 + XFS_DA_NODE_MAXDEPTH)))
  749. #define XFS_ATTRSET_LOG_RES(mp, ext) \
  750. ((mp)->m_reservations.tr_attrset + \
  751. (ext * (mp)->m_sb.sb_sectsize) + \
  752. (ext * XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK))) + \
  753. (128 * (ext + (ext * XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)))))
  754. /*
  755. * Removing an attribute.
  756. * the inode: inode size
  757. * the attribute btree could join: max depth * block size
  758. * the inode bmap btree could join or split: max depth * block size
  759. * And the bmap_finish transaction can free the attr blocks freed giving:
  760. * the agf for the ag in which the blocks live: 2 * sector size
  761. * the agfl for the ag in which the blocks live: 2 * sector size
  762. * the superblock for the free block count: sector size
  763. * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
  764. */
  765. #define XFS_CALC_ATTRRM_LOG_RES(mp) \
  766. (MAX( \
  767. ((mp)->m_sb.sb_inodesize + \
  768. XFS_FSB_TO_B((mp), XFS_DA_NODE_MAXDEPTH) + \
  769. XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)) + \
  770. (128 * (1 + XFS_DA_NODE_MAXDEPTH + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)))), \
  771. ((2 * (mp)->m_sb.sb_sectsize) + \
  772. (2 * (mp)->m_sb.sb_sectsize) + \
  773. (mp)->m_sb.sb_sectsize + \
  774. XFS_ALLOCFREE_LOG_RES(mp, 2) + \
  775. (128 * (5 + XFS_ALLOCFREE_LOG_COUNT(mp, 2))))))
  776. #define XFS_ATTRRM_LOG_RES(mp) ((mp)->m_reservations.tr_attrrm)
  777. /*
  778. * Clearing a bad agino number in an agi hash bucket.
  779. */
  780. #define XFS_CALC_CLEAR_AGI_BUCKET_LOG_RES(mp) \
  781. ((mp)->m_sb.sb_sectsize + 128)
  782. #define XFS_CLEAR_AGI_BUCKET_LOG_RES(mp) ((mp)->m_reservations.tr_clearagi)
  783. /*
  784. * Various log count values.
  785. */
  786. #define XFS_DEFAULT_LOG_COUNT 1
  787. #define XFS_DEFAULT_PERM_LOG_COUNT 2
  788. #define XFS_ITRUNCATE_LOG_COUNT 2
  789. #define XFS_INACTIVE_LOG_COUNT 2
  790. #define XFS_CREATE_LOG_COUNT 2
  791. #define XFS_MKDIR_LOG_COUNT 3
  792. #define XFS_SYMLINK_LOG_COUNT 3
  793. #define XFS_REMOVE_LOG_COUNT 2
  794. #define XFS_LINK_LOG_COUNT 2
  795. #define XFS_RENAME_LOG_COUNT 2
  796. #define XFS_WRITE_LOG_COUNT 2
  797. #define XFS_ADDAFORK_LOG_COUNT 2
  798. #define XFS_ATTRINVAL_LOG_COUNT 1
  799. #define XFS_ATTRSET_LOG_COUNT 3
  800. #define XFS_ATTRRM_LOG_COUNT 3
  801. /*
  802. * Here we centralize the specification of XFS meta-data buffer
  803. * reference count values. This determine how hard the buffer
  804. * cache tries to hold onto the buffer.
  805. */
  806. #define XFS_AGF_REF 4
  807. #define XFS_AGI_REF 4
  808. #define XFS_AGFL_REF 3
  809. #define XFS_INO_BTREE_REF 3
  810. #define XFS_ALLOC_BTREE_REF 2
  811. #define XFS_BMAP_BTREE_REF 2
  812. #define XFS_DIR_BTREE_REF 2
  813. #define XFS_ATTR_BTREE_REF 1
  814. #define XFS_INO_REF 1
  815. #define XFS_DQUOT_REF 1
  816. #ifdef __KERNEL__
  817. /*
  818. * XFS transaction mechanism exported interfaces that are
  819. * actually macros.
  820. */
  821. #define xfs_trans_get_log_res(tp) ((tp)->t_log_res)
  822. #define xfs_trans_get_log_count(tp) ((tp)->t_log_count)
  823. #define xfs_trans_get_block_res(tp) ((tp)->t_blk_res)
  824. #define xfs_trans_set_sync(tp) ((tp)->t_flags |= XFS_TRANS_SYNC)
  825. #ifdef DEBUG
  826. #define xfs_trans_agblocks_delta(tp, d) ((tp)->t_ag_freeblks_delta += (int64_t)d)
  827. #define xfs_trans_agflist_delta(tp, d) ((tp)->t_ag_flist_delta += (int64_t)d)
  828. #define xfs_trans_agbtree_delta(tp, d) ((tp)->t_ag_btree_delta += (int64_t)d)
  829. #else
  830. #define xfs_trans_agblocks_delta(tp, d)
  831. #define xfs_trans_agflist_delta(tp, d)
  832. #define xfs_trans_agbtree_delta(tp, d)
  833. #endif
  834. /*
  835. * XFS transaction mechanism exported interfaces.
  836. */
  837. void xfs_trans_init(struct xfs_mount *);
  838. xfs_trans_t *xfs_trans_alloc(struct xfs_mount *, uint);
  839. xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint);
  840. xfs_trans_t *xfs_trans_dup(xfs_trans_t *);
  841. int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint,
  842. uint, uint);
  843. void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
  844. struct xfs_buf *xfs_trans_get_buf(xfs_trans_t *, struct xfs_buftarg *, xfs_daddr_t,
  845. int, uint);
  846. int xfs_trans_read_buf(struct xfs_mount *, xfs_trans_t *,
  847. struct xfs_buftarg *, xfs_daddr_t, int, uint,
  848. struct xfs_buf **);
  849. struct xfs_buf *xfs_trans_getsb(xfs_trans_t *, struct xfs_mount *, int);
  850. void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *);
  851. void xfs_trans_bjoin(xfs_trans_t *, struct xfs_buf *);
  852. void xfs_trans_bhold(xfs_trans_t *, struct xfs_buf *);
  853. void xfs_trans_bhold_release(xfs_trans_t *, struct xfs_buf *);
  854. void xfs_trans_binval(xfs_trans_t *, struct xfs_buf *);
  855. void xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *);
  856. void xfs_trans_stale_inode_buf(xfs_trans_t *, struct xfs_buf *);
  857. void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint);
  858. void xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *);
  859. int xfs_trans_iget(struct xfs_mount *, xfs_trans_t *,
  860. xfs_ino_t , uint, uint, struct xfs_inode **);
  861. void xfs_trans_ijoin(xfs_trans_t *, struct xfs_inode *, uint);
  862. void xfs_trans_ihold(xfs_trans_t *, struct xfs_inode *);
  863. void xfs_trans_log_buf(xfs_trans_t *, struct xfs_buf *, uint, uint);
  864. void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint);
  865. struct xfs_efi_log_item *xfs_trans_get_efi(xfs_trans_t *, uint);
  866. void xfs_efi_release(struct xfs_efi_log_item *, uint);
  867. void xfs_trans_log_efi_extent(xfs_trans_t *,
  868. struct xfs_efi_log_item *,
  869. xfs_fsblock_t,
  870. xfs_extlen_t);
  871. struct xfs_efd_log_item *xfs_trans_get_efd(xfs_trans_t *,
  872. struct xfs_efi_log_item *,
  873. uint);
  874. void xfs_trans_log_efd_extent(xfs_trans_t *,
  875. struct xfs_efd_log_item *,
  876. xfs_fsblock_t,
  877. xfs_extlen_t);
  878. int _xfs_trans_commit(xfs_trans_t *,
  879. uint flags,
  880. int *);
  881. #define xfs_trans_commit(tp, flags) _xfs_trans_commit(tp, flags, NULL)
  882. void xfs_trans_cancel(xfs_trans_t *, int);
  883. int xfs_trans_roll(struct xfs_trans **, struct xfs_inode *);
  884. int xfs_trans_ail_init(struct xfs_mount *);
  885. void xfs_trans_ail_destroy(struct xfs_mount *);
  886. void xfs_trans_push_ail(struct xfs_mount *, xfs_lsn_t);
  887. xfs_lsn_t xfs_trans_tail_ail(struct xfs_mount *);
  888. void xfs_trans_unlocked_item(struct xfs_mount *,
  889. xfs_log_item_t *);
  890. xfs_log_busy_slot_t *xfs_trans_add_busy(xfs_trans_t *tp,
  891. xfs_agnumber_t ag,
  892. xfs_extlen_t idx);
  893. extern kmem_zone_t *xfs_trans_zone;
  894. #endif /* __KERNEL__ */
  895. #endif /* __XFS_TRANS_H__ */