xfs_trans.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  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. #define XFS_LIC_INIT(cp) xfs_lic_init(cp)
  196. static inline void xfs_lic_init(xfs_log_item_chunk_t *cp)
  197. {
  198. cp->lic_free = XFS_LIC_FREEMASK;
  199. }
  200. #define XFS_LIC_INIT_SLOT(cp,slot) xfs_lic_init_slot(cp, slot)
  201. static inline void xfs_lic_init_slot(xfs_log_item_chunk_t *cp, int slot)
  202. {
  203. cp->lic_descs[slot].lid_index = (unsigned char)(slot);
  204. }
  205. #define XFS_LIC_VACANCY(cp) xfs_lic_vacancy(cp)
  206. static inline int xfs_lic_vacancy(xfs_log_item_chunk_t *cp)
  207. {
  208. return cp->lic_free & XFS_LIC_FREEMASK;
  209. }
  210. #define XFS_LIC_ALL_FREE(cp) xfs_lic_all_free(cp)
  211. static inline void xfs_lic_all_free(xfs_log_item_chunk_t *cp)
  212. {
  213. cp->lic_free = XFS_LIC_FREEMASK;
  214. }
  215. #define XFS_LIC_ARE_ALL_FREE(cp) xfs_lic_are_all_free(cp)
  216. static inline int xfs_lic_are_all_free(xfs_log_item_chunk_t *cp)
  217. {
  218. return ((cp->lic_free & XFS_LIC_FREEMASK) == XFS_LIC_FREEMASK);
  219. }
  220. #define XFS_LIC_ISFREE(cp,slot) xfs_lic_isfree(cp,slot)
  221. static inline int xfs_lic_isfree(xfs_log_item_chunk_t *cp, int slot)
  222. {
  223. return (cp->lic_free & (1 << slot));
  224. }
  225. #define XFS_LIC_CLAIM(cp,slot) xfs_lic_claim(cp,slot)
  226. static inline void xfs_lic_claim(xfs_log_item_chunk_t *cp, int slot)
  227. {
  228. cp->lic_free &= ~(1 << slot);
  229. }
  230. #define XFS_LIC_RELSE(cp,slot) xfs_lic_relse(cp,slot)
  231. static inline void xfs_lic_relse(xfs_log_item_chunk_t *cp, int slot)
  232. {
  233. cp->lic_free |= 1 << slot;
  234. }
  235. #define XFS_LIC_SLOT(cp,slot) xfs_lic_slot(cp,slot)
  236. static inline xfs_log_item_desc_t *
  237. xfs_lic_slot(xfs_log_item_chunk_t *cp, int slot)
  238. {
  239. return &(cp->lic_descs[slot]);
  240. }
  241. #define XFS_LIC_DESC_TO_SLOT(dp) xfs_lic_desc_to_slot(dp)
  242. static inline int xfs_lic_desc_to_slot(xfs_log_item_desc_t *dp)
  243. {
  244. return (uint)dp->lid_index;
  245. }
  246. /*
  247. * Calculate the address of a chunk given a descriptor pointer:
  248. * dp - dp->lid_index give the address of the start of the lic_descs array.
  249. * From this we subtract the offset of the lic_descs field in a chunk.
  250. * All of this yields the address of the chunk, which is
  251. * cast to a chunk pointer.
  252. */
  253. #define XFS_LIC_DESC_TO_CHUNK(dp) xfs_lic_desc_to_chunk(dp)
  254. static inline xfs_log_item_chunk_t *
  255. xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp)
  256. {
  257. return (xfs_log_item_chunk_t*) \
  258. (((xfs_caddr_t)((dp) - (dp)->lid_index)) - \
  259. (xfs_caddr_t)(((xfs_log_item_chunk_t*)0)->lic_descs));
  260. }
  261. #ifdef __KERNEL__
  262. /*
  263. * This structure is used to maintain a list of block ranges that have been
  264. * freed in the transaction. The ranges are listed in the perag[] busy list
  265. * between when they're freed and the transaction is committed to disk.
  266. */
  267. typedef struct xfs_log_busy_slot {
  268. xfs_agnumber_t lbc_ag;
  269. ushort lbc_idx; /* index in perag.busy[] */
  270. } xfs_log_busy_slot_t;
  271. #define XFS_LBC_NUM_SLOTS 31
  272. typedef struct xfs_log_busy_chunk {
  273. struct xfs_log_busy_chunk *lbc_next;
  274. uint lbc_free; /* free slots bitmask */
  275. ushort lbc_unused; /* first unused */
  276. xfs_log_busy_slot_t lbc_busy[XFS_LBC_NUM_SLOTS];
  277. } xfs_log_busy_chunk_t;
  278. #define XFS_LBC_MAX_SLOT (XFS_LBC_NUM_SLOTS - 1)
  279. #define XFS_LBC_FREEMASK ((1U << XFS_LBC_NUM_SLOTS) - 1)
  280. #define XFS_LBC_INIT(cp) ((cp)->lbc_free = XFS_LBC_FREEMASK)
  281. #define XFS_LBC_CLAIM(cp, slot) ((cp)->lbc_free &= ~(1 << (slot)))
  282. #define XFS_LBC_SLOT(cp, slot) (&((cp)->lbc_busy[(slot)]))
  283. #define XFS_LBC_VACANCY(cp) (((cp)->lbc_free) & XFS_LBC_FREEMASK)
  284. #define XFS_LBC_ISFREE(cp, slot) ((cp)->lbc_free & (1 << (slot)))
  285. /*
  286. * This is the type of function which can be given to xfs_trans_callback()
  287. * to be called upon the transaction's commit to disk.
  288. */
  289. typedef void (*xfs_trans_callback_t)(struct xfs_trans *, void *);
  290. /*
  291. * This is the structure maintained for every active transaction.
  292. */
  293. typedef struct xfs_trans {
  294. unsigned int t_magic; /* magic number */
  295. xfs_log_callback_t t_logcb; /* log callback struct */
  296. unsigned int t_type; /* transaction type */
  297. unsigned int t_log_res; /* amt of log space resvd */
  298. unsigned int t_log_count; /* count for perm log res */
  299. unsigned int t_blk_res; /* # of blocks resvd */
  300. unsigned int t_blk_res_used; /* # of resvd blocks used */
  301. unsigned int t_rtx_res; /* # of rt extents resvd */
  302. unsigned int t_rtx_res_used; /* # of resvd rt extents used */
  303. xfs_log_ticket_t t_ticket; /* log mgr ticket */
  304. xfs_lsn_t t_lsn; /* log seq num of start of
  305. * transaction. */
  306. xfs_lsn_t t_commit_lsn; /* log seq num of end of
  307. * transaction. */
  308. struct xfs_mount *t_mountp; /* ptr to fs mount struct */
  309. struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */
  310. xfs_trans_callback_t t_callback; /* transaction callback */
  311. void *t_callarg; /* callback arg */
  312. unsigned int t_flags; /* misc flags */
  313. int64_t t_icount_delta; /* superblock icount change */
  314. int64_t t_ifree_delta; /* superblock ifree change */
  315. int64_t t_fdblocks_delta; /* superblock fdblocks chg */
  316. int64_t t_res_fdblocks_delta; /* on-disk only chg */
  317. int64_t t_frextents_delta;/* superblock freextents chg*/
  318. int64_t t_res_frextents_delta; /* on-disk only chg */
  319. #ifdef DEBUG
  320. int64_t t_ag_freeblks_delta; /* debugging counter */
  321. int64_t t_ag_flist_delta; /* debugging counter */
  322. int64_t t_ag_btree_delta; /* debugging counter */
  323. #endif
  324. int64_t t_dblocks_delta;/* superblock dblocks change */
  325. int64_t t_agcount_delta;/* superblock agcount change */
  326. int64_t t_imaxpct_delta;/* superblock imaxpct change */
  327. int64_t t_rextsize_delta;/* superblock rextsize chg */
  328. int64_t t_rbmblocks_delta;/* superblock rbmblocks chg */
  329. int64_t t_rblocks_delta;/* superblock rblocks change */
  330. int64_t t_rextents_delta;/* superblocks rextents chg */
  331. int64_t t_rextslog_delta;/* superblocks rextslog chg */
  332. unsigned int t_items_free; /* log item descs free */
  333. xfs_log_item_chunk_t t_items; /* first log item desc chunk */
  334. xfs_trans_header_t t_header; /* header for in-log trans */
  335. unsigned int t_busy_free; /* busy descs free */
  336. xfs_log_busy_chunk_t t_busy; /* busy/async free blocks */
  337. unsigned long t_pflags; /* saved process flags state */
  338. } xfs_trans_t;
  339. #endif /* __KERNEL__ */
  340. #define XFS_TRANS_MAGIC 0x5452414E /* 'TRAN' */
  341. /*
  342. * Values for t_flags.
  343. */
  344. #define XFS_TRANS_DIRTY 0x01 /* something needs to be logged */
  345. #define XFS_TRANS_SB_DIRTY 0x02 /* superblock is modified */
  346. #define XFS_TRANS_PERM_LOG_RES 0x04 /* xact took a permanent log res */
  347. #define XFS_TRANS_SYNC 0x08 /* make commit synchronous */
  348. #define XFS_TRANS_DQ_DIRTY 0x10 /* at least one dquot in trx dirty */
  349. #define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */
  350. /*
  351. * Values for call flags parameter.
  352. */
  353. #define XFS_TRANS_NOSLEEP 0x1
  354. #define XFS_TRANS_WAIT 0x2
  355. #define XFS_TRANS_RELEASE_LOG_RES 0x4
  356. #define XFS_TRANS_ABORT 0x8
  357. /*
  358. * Field values for xfs_trans_mod_sb.
  359. */
  360. #define XFS_TRANS_SB_ICOUNT 0x00000001
  361. #define XFS_TRANS_SB_IFREE 0x00000002
  362. #define XFS_TRANS_SB_FDBLOCKS 0x00000004
  363. #define XFS_TRANS_SB_RES_FDBLOCKS 0x00000008
  364. #define XFS_TRANS_SB_FREXTENTS 0x00000010
  365. #define XFS_TRANS_SB_RES_FREXTENTS 0x00000020
  366. #define XFS_TRANS_SB_DBLOCKS 0x00000040
  367. #define XFS_TRANS_SB_AGCOUNT 0x00000080
  368. #define XFS_TRANS_SB_IMAXPCT 0x00000100
  369. #define XFS_TRANS_SB_REXTSIZE 0x00000200
  370. #define XFS_TRANS_SB_RBMBLOCKS 0x00000400
  371. #define XFS_TRANS_SB_RBLOCKS 0x00000800
  372. #define XFS_TRANS_SB_REXTENTS 0x00001000
  373. #define XFS_TRANS_SB_REXTSLOG 0x00002000
  374. /*
  375. * Various log reservation values.
  376. * These are based on the size of the file system block
  377. * because that is what most transactions manipulate.
  378. * Each adds in an additional 128 bytes per item logged to
  379. * try to account for the overhead of the transaction mechanism.
  380. *
  381. * Note:
  382. * Most of the reservations underestimate the number of allocation
  383. * groups into which they could free extents in the xfs_bmap_finish()
  384. * call. This is because the number in the worst case is quite high
  385. * and quite unusual. In order to fix this we need to change
  386. * xfs_bmap_finish() to free extents in only a single AG at a time.
  387. * This will require changes to the EFI code as well, however, so that
  388. * the EFI for the extents not freed is logged again in each transaction.
  389. * See bug 261917.
  390. */
  391. /*
  392. * Per-extent log reservation for the allocation btree changes
  393. * involved in freeing or allocating an extent.
  394. * 2 trees * (2 blocks/level * max depth - 1) * block size
  395. */
  396. #define XFS_ALLOCFREE_LOG_RES(mp,nx) \
  397. ((nx) * (2 * XFS_FSB_TO_B((mp), 2 * XFS_AG_MAXLEVELS(mp) - 1)))
  398. #define XFS_ALLOCFREE_LOG_COUNT(mp,nx) \
  399. ((nx) * (2 * (2 * XFS_AG_MAXLEVELS(mp) - 1)))
  400. /*
  401. * Per-directory log reservation for any directory change.
  402. * dir blocks: (1 btree block per level + data block + free block) * dblock size
  403. * bmap btree: (levels + 2) * max depth * block size
  404. * v2 directory blocks can be fragmented below the dirblksize down to the fsb
  405. * size, so account for that in the DAENTER macros.
  406. */
  407. #define XFS_DIROP_LOG_RES(mp) \
  408. (XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \
  409. (XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)))
  410. #define XFS_DIROP_LOG_COUNT(mp) \
  411. (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \
  412. XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)
  413. /*
  414. * In a write transaction we can allocate a maximum of 2
  415. * extents. This gives:
  416. * the inode getting the new extents: inode size
  417. * the inode\'s bmap btree: max depth * block size
  418. * the agfs of the ags from which the extents are allocated: 2 * sector
  419. * the superblock free block counter: sector size
  420. * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
  421. * And the bmap_finish transaction can free bmap blocks in a join:
  422. * the agfs of the ags containing the blocks: 2 * sector size
  423. * the agfls of the ags containing the blocks: 2 * sector size
  424. * the super block free block counter: sector size
  425. * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
  426. */
  427. #define XFS_CALC_WRITE_LOG_RES(mp) \
  428. (MAX( \
  429. ((mp)->m_sb.sb_inodesize + \
  430. XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)) + \
  431. (2 * (mp)->m_sb.sb_sectsize) + \
  432. (mp)->m_sb.sb_sectsize + \
  433. XFS_ALLOCFREE_LOG_RES(mp, 2) + \
  434. (128 * (4 + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + XFS_ALLOCFREE_LOG_COUNT(mp, 2)))),\
  435. ((2 * (mp)->m_sb.sb_sectsize) + \
  436. (2 * (mp)->m_sb.sb_sectsize) + \
  437. (mp)->m_sb.sb_sectsize + \
  438. XFS_ALLOCFREE_LOG_RES(mp, 2) + \
  439. (128 * (5 + XFS_ALLOCFREE_LOG_COUNT(mp, 2))))))
  440. #define XFS_WRITE_LOG_RES(mp) ((mp)->m_reservations.tr_write)
  441. /*
  442. * In truncating a file we free up to two extents at once. We can modify:
  443. * the inode being truncated: inode size
  444. * the inode\'s bmap btree: (max depth + 1) * block size
  445. * And the bmap_finish transaction can free the blocks and bmap blocks:
  446. * the agf for each of the ags: 4 * sector size
  447. * the agfl for each of the ags: 4 * sector size
  448. * the super block to reflect the freed blocks: sector size
  449. * worst case split in allocation btrees per extent assuming 4 extents:
  450. * 4 exts * 2 trees * (2 * max depth - 1) * block size
  451. * the inode btree: max depth * blocksize
  452. * the allocation btrees: 2 trees * (max depth - 1) * block size
  453. */
  454. #define XFS_CALC_ITRUNCATE_LOG_RES(mp) \
  455. (MAX( \
  456. ((mp)->m_sb.sb_inodesize + \
  457. XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + 1) + \
  458. (128 * (2 + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)))), \
  459. ((4 * (mp)->m_sb.sb_sectsize) + \
  460. (4 * (mp)->m_sb.sb_sectsize) + \
  461. (mp)->m_sb.sb_sectsize + \
  462. XFS_ALLOCFREE_LOG_RES(mp, 4) + \
  463. (128 * (9 + XFS_ALLOCFREE_LOG_COUNT(mp, 4))) + \
  464. (128 * 5) + \
  465. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  466. (128 * (2 + XFS_IALLOC_BLOCKS(mp) + XFS_IN_MAXLEVELS(mp) + \
  467. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))))
  468. #define XFS_ITRUNCATE_LOG_RES(mp) ((mp)->m_reservations.tr_itruncate)
  469. /*
  470. * In renaming a files we can modify:
  471. * the four inodes involved: 4 * inode size
  472. * the two directory btrees: 2 * (max depth + v2) * dir block size
  473. * the two directory bmap btrees: 2 * max depth * block size
  474. * And the bmap_finish transaction can free dir and bmap blocks (two sets
  475. * of bmap blocks) giving:
  476. * the agf for the ags in which the blocks live: 3 * sector size
  477. * the agfl for the ags in which the blocks live: 3 * sector size
  478. * the superblock for the free block count: sector size
  479. * the allocation btrees: 3 exts * 2 trees * (2 * max depth - 1) * block size
  480. */
  481. #define XFS_CALC_RENAME_LOG_RES(mp) \
  482. (MAX( \
  483. ((4 * (mp)->m_sb.sb_inodesize) + \
  484. (2 * XFS_DIROP_LOG_RES(mp)) + \
  485. (128 * (4 + 2 * XFS_DIROP_LOG_COUNT(mp)))), \
  486. ((3 * (mp)->m_sb.sb_sectsize) + \
  487. (3 * (mp)->m_sb.sb_sectsize) + \
  488. (mp)->m_sb.sb_sectsize + \
  489. XFS_ALLOCFREE_LOG_RES(mp, 3) + \
  490. (128 * (7 + XFS_ALLOCFREE_LOG_COUNT(mp, 3))))))
  491. #define XFS_RENAME_LOG_RES(mp) ((mp)->m_reservations.tr_rename)
  492. /*
  493. * For creating a link to an inode:
  494. * the parent directory inode: inode size
  495. * the linked inode: inode size
  496. * the directory btree could split: (max depth + v2) * dir block size
  497. * the directory bmap btree could join or split: (max depth + v2) * blocksize
  498. * And the bmap_finish transaction can free some bmap blocks giving:
  499. * the agf for the ag in which the blocks live: sector size
  500. * the agfl for the ag in which the blocks live: sector size
  501. * the superblock for the free block count: sector size
  502. * the allocation btrees: 2 trees * (2 * max depth - 1) * block size
  503. */
  504. #define XFS_CALC_LINK_LOG_RES(mp) \
  505. (MAX( \
  506. ((mp)->m_sb.sb_inodesize + \
  507. (mp)->m_sb.sb_inodesize + \
  508. XFS_DIROP_LOG_RES(mp) + \
  509. (128 * (2 + XFS_DIROP_LOG_COUNT(mp)))), \
  510. ((mp)->m_sb.sb_sectsize + \
  511. (mp)->m_sb.sb_sectsize + \
  512. (mp)->m_sb.sb_sectsize + \
  513. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  514. (128 * (3 + XFS_ALLOCFREE_LOG_COUNT(mp, 1))))))
  515. #define XFS_LINK_LOG_RES(mp) ((mp)->m_reservations.tr_link)
  516. /*
  517. * For removing a directory entry we can modify:
  518. * the parent directory inode: inode size
  519. * the removed inode: inode size
  520. * the directory btree could join: (max depth + v2) * dir block size
  521. * the directory bmap btree could join or split: (max depth + v2) * blocksize
  522. * And the bmap_finish transaction can free the dir and bmap blocks giving:
  523. * the agf for the ag in which the blocks live: 2 * sector size
  524. * the agfl for the ag in which the blocks live: 2 * sector size
  525. * the superblock for the free block count: sector size
  526. * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
  527. */
  528. #define XFS_CALC_REMOVE_LOG_RES(mp) \
  529. (MAX( \
  530. ((mp)->m_sb.sb_inodesize + \
  531. (mp)->m_sb.sb_inodesize + \
  532. XFS_DIROP_LOG_RES(mp) + \
  533. (128 * (2 + XFS_DIROP_LOG_COUNT(mp)))), \
  534. ((2 * (mp)->m_sb.sb_sectsize) + \
  535. (2 * (mp)->m_sb.sb_sectsize) + \
  536. (mp)->m_sb.sb_sectsize + \
  537. XFS_ALLOCFREE_LOG_RES(mp, 2) + \
  538. (128 * (5 + XFS_ALLOCFREE_LOG_COUNT(mp, 2))))))
  539. #define XFS_REMOVE_LOG_RES(mp) ((mp)->m_reservations.tr_remove)
  540. /*
  541. * For symlink we can modify:
  542. * the parent directory inode: inode size
  543. * the new inode: inode size
  544. * the inode btree entry: 1 block
  545. * the directory btree: (max depth + v2) * dir block size
  546. * the directory inode\'s bmap btree: (max depth + v2) * block size
  547. * the blocks for the symlink: 1 KB
  548. * Or in the first xact we allocate some inodes giving:
  549. * the agi and agf of the ag getting the new inodes: 2 * sectorsize
  550. * the inode blocks allocated: XFS_IALLOC_BLOCKS * blocksize
  551. * the inode btree: max depth * blocksize
  552. * the allocation btrees: 2 trees * (2 * max depth - 1) * block size
  553. */
  554. #define XFS_CALC_SYMLINK_LOG_RES(mp) \
  555. (MAX( \
  556. ((mp)->m_sb.sb_inodesize + \
  557. (mp)->m_sb.sb_inodesize + \
  558. XFS_FSB_TO_B(mp, 1) + \
  559. XFS_DIROP_LOG_RES(mp) + \
  560. 1024 + \
  561. (128 * (4 + XFS_DIROP_LOG_COUNT(mp)))), \
  562. (2 * (mp)->m_sb.sb_sectsize + \
  563. XFS_FSB_TO_B((mp), XFS_IALLOC_BLOCKS((mp))) + \
  564. XFS_FSB_TO_B((mp), XFS_IN_MAXLEVELS(mp)) + \
  565. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  566. (128 * (2 + XFS_IALLOC_BLOCKS(mp) + XFS_IN_MAXLEVELS(mp) + \
  567. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))))
  568. #define XFS_SYMLINK_LOG_RES(mp) ((mp)->m_reservations.tr_symlink)
  569. /*
  570. * For create we can modify:
  571. * the parent directory inode: inode size
  572. * the new inode: inode size
  573. * the inode btree entry: block size
  574. * the superblock for the nlink flag: sector size
  575. * the directory btree: (max depth + v2) * dir block size
  576. * the directory inode\'s bmap btree: (max depth + v2) * block size
  577. * Or in the first xact we allocate some inodes giving:
  578. * the agi and agf of the ag getting the new inodes: 2 * sectorsize
  579. * the superblock for the nlink flag: sector size
  580. * the inode blocks allocated: XFS_IALLOC_BLOCKS * blocksize
  581. * the inode btree: max depth * blocksize
  582. * the allocation btrees: 2 trees * (max depth - 1) * block size
  583. */
  584. #define XFS_CALC_CREATE_LOG_RES(mp) \
  585. (MAX( \
  586. ((mp)->m_sb.sb_inodesize + \
  587. (mp)->m_sb.sb_inodesize + \
  588. (mp)->m_sb.sb_sectsize + \
  589. XFS_FSB_TO_B(mp, 1) + \
  590. XFS_DIROP_LOG_RES(mp) + \
  591. (128 * (3 + XFS_DIROP_LOG_COUNT(mp)))), \
  592. (3 * (mp)->m_sb.sb_sectsize + \
  593. XFS_FSB_TO_B((mp), XFS_IALLOC_BLOCKS((mp))) + \
  594. XFS_FSB_TO_B((mp), XFS_IN_MAXLEVELS(mp)) + \
  595. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  596. (128 * (2 + XFS_IALLOC_BLOCKS(mp) + XFS_IN_MAXLEVELS(mp) + \
  597. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))))
  598. #define XFS_CREATE_LOG_RES(mp) ((mp)->m_reservations.tr_create)
  599. /*
  600. * Making a new directory is the same as creating a new file.
  601. */
  602. #define XFS_CALC_MKDIR_LOG_RES(mp) XFS_CALC_CREATE_LOG_RES(mp)
  603. #define XFS_MKDIR_LOG_RES(mp) ((mp)->m_reservations.tr_mkdir)
  604. /*
  605. * In freeing an inode we can modify:
  606. * the inode being freed: inode size
  607. * the super block free inode counter: sector size
  608. * the agi hash list and counters: sector size
  609. * the inode btree entry: block size
  610. * the on disk inode before ours in the agi hash list: inode cluster size
  611. * the inode btree: max depth * blocksize
  612. * the allocation btrees: 2 trees * (max depth - 1) * block size
  613. */
  614. #define XFS_CALC_IFREE_LOG_RES(mp) \
  615. ((mp)->m_sb.sb_inodesize + \
  616. (mp)->m_sb.sb_sectsize + \
  617. (mp)->m_sb.sb_sectsize + \
  618. XFS_FSB_TO_B((mp), 1) + \
  619. MAX((__uint16_t)XFS_FSB_TO_B((mp), 1), XFS_INODE_CLUSTER_SIZE(mp)) + \
  620. (128 * 5) + \
  621. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  622. (128 * (2 + XFS_IALLOC_BLOCKS(mp) + XFS_IN_MAXLEVELS(mp) + \
  623. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))
  624. #define XFS_IFREE_LOG_RES(mp) ((mp)->m_reservations.tr_ifree)
  625. /*
  626. * When only changing the inode we log the inode and possibly the superblock
  627. * We also add a bit of slop for the transaction stuff.
  628. */
  629. #define XFS_CALC_ICHANGE_LOG_RES(mp) ((mp)->m_sb.sb_inodesize + \
  630. (mp)->m_sb.sb_sectsize + 512)
  631. #define XFS_ICHANGE_LOG_RES(mp) ((mp)->m_reservations.tr_ichange)
  632. /*
  633. * Growing the data section of the filesystem.
  634. * superblock
  635. * agi and agf
  636. * allocation btrees
  637. */
  638. #define XFS_CALC_GROWDATA_LOG_RES(mp) \
  639. ((mp)->m_sb.sb_sectsize * 3 + \
  640. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  641. (128 * (3 + XFS_ALLOCFREE_LOG_COUNT(mp, 1))))
  642. #define XFS_GROWDATA_LOG_RES(mp) ((mp)->m_reservations.tr_growdata)
  643. /*
  644. * Growing the rt section of the filesystem.
  645. * In the first set of transactions (ALLOC) we allocate space to the
  646. * bitmap or summary files.
  647. * superblock: sector size
  648. * agf of the ag from which the extent is allocated: sector size
  649. * bmap btree for bitmap/summary inode: max depth * blocksize
  650. * bitmap/summary inode: inode size
  651. * allocation btrees for 1 block alloc: 2 * (2 * maxdepth - 1) * blocksize
  652. */
  653. #define XFS_CALC_GROWRTALLOC_LOG_RES(mp) \
  654. (2 * (mp)->m_sb.sb_sectsize + \
  655. XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)) + \
  656. (mp)->m_sb.sb_inodesize + \
  657. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  658. (128 * \
  659. (3 + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + \
  660. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))
  661. #define XFS_GROWRTALLOC_LOG_RES(mp) ((mp)->m_reservations.tr_growrtalloc)
  662. /*
  663. * Growing the rt section of the filesystem.
  664. * In the second set of transactions (ZERO) we zero the new metadata blocks.
  665. * one bitmap/summary block: blocksize
  666. */
  667. #define XFS_CALC_GROWRTZERO_LOG_RES(mp) \
  668. ((mp)->m_sb.sb_blocksize + 128)
  669. #define XFS_GROWRTZERO_LOG_RES(mp) ((mp)->m_reservations.tr_growrtzero)
  670. /*
  671. * Growing the rt section of the filesystem.
  672. * In the third set of transactions (FREE) we update metadata without
  673. * allocating any new blocks.
  674. * superblock: sector size
  675. * bitmap inode: inode size
  676. * summary inode: inode size
  677. * one bitmap block: blocksize
  678. * summary blocks: new summary size
  679. */
  680. #define XFS_CALC_GROWRTFREE_LOG_RES(mp) \
  681. ((mp)->m_sb.sb_sectsize + \
  682. 2 * (mp)->m_sb.sb_inodesize + \
  683. (mp)->m_sb.sb_blocksize + \
  684. (mp)->m_rsumsize + \
  685. (128 * 5))
  686. #define XFS_GROWRTFREE_LOG_RES(mp) ((mp)->m_reservations.tr_growrtfree)
  687. /*
  688. * Logging the inode modification timestamp on a synchronous write.
  689. * inode
  690. */
  691. #define XFS_CALC_SWRITE_LOG_RES(mp) \
  692. ((mp)->m_sb.sb_inodesize + 128)
  693. #define XFS_SWRITE_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)
  694. /*
  695. * Logging the inode timestamps on an fsync -- same as SWRITE
  696. * as long as SWRITE logs the entire inode core
  697. */
  698. #define XFS_FSYNC_TS_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)
  699. /*
  700. * Logging the inode mode bits when writing a setuid/setgid file
  701. * inode
  702. */
  703. #define XFS_CALC_WRITEID_LOG_RES(mp) \
  704. ((mp)->m_sb.sb_inodesize + 128)
  705. #define XFS_WRITEID_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)
  706. /*
  707. * Converting the inode from non-attributed to attributed.
  708. * the inode being converted: inode size
  709. * agf block and superblock (for block allocation)
  710. * the new block (directory sized)
  711. * bmap blocks for the new directory block
  712. * allocation btrees
  713. */
  714. #define XFS_CALC_ADDAFORK_LOG_RES(mp) \
  715. ((mp)->m_sb.sb_inodesize + \
  716. (mp)->m_sb.sb_sectsize * 2 + \
  717. (mp)->m_dirblksize + \
  718. XFS_FSB_TO_B(mp, (XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1)) + \
  719. XFS_ALLOCFREE_LOG_RES(mp, 1) + \
  720. (128 * (4 + (XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1) + \
  721. XFS_ALLOCFREE_LOG_COUNT(mp, 1))))
  722. #define XFS_ADDAFORK_LOG_RES(mp) ((mp)->m_reservations.tr_addafork)
  723. /*
  724. * Removing the attribute fork of a file
  725. * the inode being truncated: inode size
  726. * the inode\'s bmap btree: max depth * block size
  727. * And the bmap_finish transaction can free the blocks and bmap blocks:
  728. * the agf for each of the ags: 4 * sector size
  729. * the agfl for each of the ags: 4 * sector size
  730. * the super block to reflect the freed blocks: sector size
  731. * worst case split in allocation btrees per extent assuming 4 extents:
  732. * 4 exts * 2 trees * (2 * max depth - 1) * block size
  733. */
  734. #define XFS_CALC_ATTRINVAL_LOG_RES(mp) \
  735. (MAX( \
  736. ((mp)->m_sb.sb_inodesize + \
  737. XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)) + \
  738. (128 * (1 + XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)))), \
  739. ((4 * (mp)->m_sb.sb_sectsize) + \
  740. (4 * (mp)->m_sb.sb_sectsize) + \
  741. (mp)->m_sb.sb_sectsize + \
  742. XFS_ALLOCFREE_LOG_RES(mp, 4) + \
  743. (128 * (9 + XFS_ALLOCFREE_LOG_COUNT(mp, 4))))))
  744. #define XFS_ATTRINVAL_LOG_RES(mp) ((mp)->m_reservations.tr_attrinval)
  745. /*
  746. * Setting an attribute.
  747. * the inode getting the attribute
  748. * the superblock for allocations
  749. * the agfs extents are allocated from
  750. * the attribute btree * max depth
  751. * the inode allocation btree
  752. * Since attribute transaction space is dependent on the size of the attribute,
  753. * the calculation is done partially at mount time and partially at runtime.
  754. */
  755. #define XFS_CALC_ATTRSET_LOG_RES(mp) \
  756. ((mp)->m_sb.sb_inodesize + \
  757. (mp)->m_sb.sb_sectsize + \
  758. XFS_FSB_TO_B((mp), XFS_DA_NODE_MAXDEPTH) + \
  759. (128 * (2 + XFS_DA_NODE_MAXDEPTH)))
  760. #define XFS_ATTRSET_LOG_RES(mp, ext) \
  761. ((mp)->m_reservations.tr_attrset + \
  762. (ext * (mp)->m_sb.sb_sectsize) + \
  763. (ext * XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK))) + \
  764. (128 * (ext + (ext * XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)))))
  765. /*
  766. * Removing an attribute.
  767. * the inode: inode size
  768. * the attribute btree could join: max depth * block size
  769. * the inode bmap btree could join or split: max depth * block size
  770. * And the bmap_finish transaction can free the attr blocks freed giving:
  771. * the agf for the ag in which the blocks live: 2 * sector size
  772. * the agfl for the ag in which the blocks live: 2 * sector size
  773. * the superblock for the free block count: sector size
  774. * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
  775. */
  776. #define XFS_CALC_ATTRRM_LOG_RES(mp) \
  777. (MAX( \
  778. ((mp)->m_sb.sb_inodesize + \
  779. XFS_FSB_TO_B((mp), XFS_DA_NODE_MAXDEPTH) + \
  780. XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)) + \
  781. (128 * (1 + XFS_DA_NODE_MAXDEPTH + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)))), \
  782. ((2 * (mp)->m_sb.sb_sectsize) + \
  783. (2 * (mp)->m_sb.sb_sectsize) + \
  784. (mp)->m_sb.sb_sectsize + \
  785. XFS_ALLOCFREE_LOG_RES(mp, 2) + \
  786. (128 * (5 + XFS_ALLOCFREE_LOG_COUNT(mp, 2))))))
  787. #define XFS_ATTRRM_LOG_RES(mp) ((mp)->m_reservations.tr_attrrm)
  788. /*
  789. * Clearing a bad agino number in an agi hash bucket.
  790. */
  791. #define XFS_CALC_CLEAR_AGI_BUCKET_LOG_RES(mp) \
  792. ((mp)->m_sb.sb_sectsize + 128)
  793. #define XFS_CLEAR_AGI_BUCKET_LOG_RES(mp) ((mp)->m_reservations.tr_clearagi)
  794. /*
  795. * Various log count values.
  796. */
  797. #define XFS_DEFAULT_LOG_COUNT 1
  798. #define XFS_DEFAULT_PERM_LOG_COUNT 2
  799. #define XFS_ITRUNCATE_LOG_COUNT 2
  800. #define XFS_INACTIVE_LOG_COUNT 2
  801. #define XFS_CREATE_LOG_COUNT 2
  802. #define XFS_MKDIR_LOG_COUNT 3
  803. #define XFS_SYMLINK_LOG_COUNT 3
  804. #define XFS_REMOVE_LOG_COUNT 2
  805. #define XFS_LINK_LOG_COUNT 2
  806. #define XFS_RENAME_LOG_COUNT 2
  807. #define XFS_WRITE_LOG_COUNT 2
  808. #define XFS_ADDAFORK_LOG_COUNT 2
  809. #define XFS_ATTRINVAL_LOG_COUNT 1
  810. #define XFS_ATTRSET_LOG_COUNT 3
  811. #define XFS_ATTRRM_LOG_COUNT 3
  812. /*
  813. * Here we centralize the specification of XFS meta-data buffer
  814. * reference count values. This determine how hard the buffer
  815. * cache tries to hold onto the buffer.
  816. */
  817. #define XFS_AGF_REF 4
  818. #define XFS_AGI_REF 4
  819. #define XFS_AGFL_REF 3
  820. #define XFS_INO_BTREE_REF 3
  821. #define XFS_ALLOC_BTREE_REF 2
  822. #define XFS_BMAP_BTREE_REF 2
  823. #define XFS_DIR_BTREE_REF 2
  824. #define XFS_ATTR_BTREE_REF 1
  825. #define XFS_INO_REF 1
  826. #define XFS_DQUOT_REF 1
  827. #ifdef __KERNEL__
  828. /*
  829. * XFS transaction mechanism exported interfaces that are
  830. * actually macros.
  831. */
  832. #define xfs_trans_get_log_res(tp) ((tp)->t_log_res)
  833. #define xfs_trans_get_log_count(tp) ((tp)->t_log_count)
  834. #define xfs_trans_get_block_res(tp) ((tp)->t_blk_res)
  835. #define xfs_trans_set_sync(tp) ((tp)->t_flags |= XFS_TRANS_SYNC)
  836. #ifdef DEBUG
  837. #define xfs_trans_agblocks_delta(tp, d) ((tp)->t_ag_freeblks_delta += (int64_t)d)
  838. #define xfs_trans_agflist_delta(tp, d) ((tp)->t_ag_flist_delta += (int64_t)d)
  839. #define xfs_trans_agbtree_delta(tp, d) ((tp)->t_ag_btree_delta += (int64_t)d)
  840. #else
  841. #define xfs_trans_agblocks_delta(tp, d)
  842. #define xfs_trans_agflist_delta(tp, d)
  843. #define xfs_trans_agbtree_delta(tp, d)
  844. #endif
  845. /*
  846. * XFS transaction mechanism exported interfaces.
  847. */
  848. void xfs_trans_init(struct xfs_mount *);
  849. xfs_trans_t *xfs_trans_alloc(struct xfs_mount *, uint);
  850. xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint);
  851. xfs_trans_t *xfs_trans_dup(xfs_trans_t *);
  852. int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint,
  853. uint, uint);
  854. void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
  855. struct xfs_buf *xfs_trans_get_buf(xfs_trans_t *, struct xfs_buftarg *, xfs_daddr_t,
  856. int, uint);
  857. int xfs_trans_read_buf(struct xfs_mount *, xfs_trans_t *,
  858. struct xfs_buftarg *, xfs_daddr_t, int, uint,
  859. struct xfs_buf **);
  860. struct xfs_buf *xfs_trans_getsb(xfs_trans_t *, struct xfs_mount *, int);
  861. void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *);
  862. void xfs_trans_bjoin(xfs_trans_t *, struct xfs_buf *);
  863. void xfs_trans_bhold(xfs_trans_t *, struct xfs_buf *);
  864. void xfs_trans_bhold_release(xfs_trans_t *, struct xfs_buf *);
  865. void xfs_trans_binval(xfs_trans_t *, struct xfs_buf *);
  866. void xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *);
  867. void xfs_trans_stale_inode_buf(xfs_trans_t *, struct xfs_buf *);
  868. void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint);
  869. void xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *);
  870. int xfs_trans_iget(struct xfs_mount *, xfs_trans_t *,
  871. xfs_ino_t , uint, uint, struct xfs_inode **);
  872. void xfs_trans_ijoin(xfs_trans_t *, struct xfs_inode *, uint);
  873. void xfs_trans_ihold(xfs_trans_t *, struct xfs_inode *);
  874. void xfs_trans_log_buf(xfs_trans_t *, struct xfs_buf *, uint, uint);
  875. void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint);
  876. struct xfs_efi_log_item *xfs_trans_get_efi(xfs_trans_t *, uint);
  877. void xfs_efi_release(struct xfs_efi_log_item *, uint);
  878. void xfs_trans_log_efi_extent(xfs_trans_t *,
  879. struct xfs_efi_log_item *,
  880. xfs_fsblock_t,
  881. xfs_extlen_t);
  882. struct xfs_efd_log_item *xfs_trans_get_efd(xfs_trans_t *,
  883. struct xfs_efi_log_item *,
  884. uint);
  885. void xfs_trans_log_efd_extent(xfs_trans_t *,
  886. struct xfs_efd_log_item *,
  887. xfs_fsblock_t,
  888. xfs_extlen_t);
  889. int _xfs_trans_commit(xfs_trans_t *,
  890. uint flags,
  891. int *);
  892. #define xfs_trans_commit(tp, flags) _xfs_trans_commit(tp, flags, NULL)
  893. void xfs_trans_cancel(xfs_trans_t *, int);
  894. int xfs_trans_ail_init(struct xfs_mount *);
  895. void xfs_trans_ail_destroy(struct xfs_mount *);
  896. void xfs_trans_push_ail(struct xfs_mount *, xfs_lsn_t);
  897. xfs_lsn_t xfs_trans_tail_ail(struct xfs_mount *);
  898. void xfs_trans_unlocked_item(struct xfs_mount *,
  899. xfs_log_item_t *);
  900. xfs_log_busy_slot_t *xfs_trans_add_busy(xfs_trans_t *tp,
  901. xfs_agnumber_t ag,
  902. xfs_extlen_t idx);
  903. extern kmem_zone_t *xfs_trans_zone;
  904. #endif /* __KERNEL__ */
  905. #endif /* __XFS_TRANS_H__ */