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