Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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