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