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