📄 xfs_trans.h
字号:
* the inode being freed: inode size * the super block free inode counter: sector size * the agi hash list and counters: sector size * the inode btree entry: block size * the on disk inode before ours in the agi hash list: inode cluster size * the inode btree: max depth * blocksize * the allocation btrees: 2 trees * (max depth - 1) * block size */#define XFS_CALC_IFREE_LOG_RES(mp) \ ((mp)->m_sb.sb_inodesize + \ (mp)->m_sb.sb_sectsize + \ (mp)->m_sb.sb_sectsize + \ XFS_FSB_TO_B((mp), 1) + \ MAX((__uint16_t)XFS_FSB_TO_B((mp), 1), XFS_INODE_CLUSTER_SIZE(mp)) + \ (128 * 5) + \ XFS_ALLOCFREE_LOG_RES(mp, 1) + \ (128 * (2 + XFS_IALLOC_BLOCKS(mp) + XFS_IN_MAXLEVELS(mp) + \ XFS_ALLOCFREE_LOG_COUNT(mp, 1))))#define XFS_IFREE_LOG_RES(mp) ((mp)->m_reservations.tr_ifree)/* * When only changing the inode we log the inode and possibly the superblock * We also add a bit of slop for the transaction stuff. */#define XFS_CALC_ICHANGE_LOG_RES(mp) ((mp)->m_sb.sb_inodesize + \ (mp)->m_sb.sb_sectsize + 512)#define XFS_ICHANGE_LOG_RES(mp) ((mp)->m_reservations.tr_ichange)/* * Growing the data section of the filesystem. * superblock * agi and agf * allocation btrees */#define XFS_CALC_GROWDATA_LOG_RES(mp) \ ((mp)->m_sb.sb_sectsize * 3 + \ XFS_ALLOCFREE_LOG_RES(mp, 1) + \ (128 * (3 + XFS_ALLOCFREE_LOG_COUNT(mp, 1))))#define XFS_GROWDATA_LOG_RES(mp) ((mp)->m_reservations.tr_growdata)/* * Growing the rt section of the filesystem. * In the first set of transactions (ALLOC) we allocate space to the * bitmap or summary files. * superblock: sector size * agf of the ag from which the extent is allocated: sector size * bmap btree for bitmap/summary inode: max depth * blocksize * bitmap/summary inode: inode size * allocation btrees for 1 block alloc: 2 * (2 * maxdepth - 1) * blocksize */#define XFS_CALC_GROWRTALLOC_LOG_RES(mp) \ (2 * (mp)->m_sb.sb_sectsize + \ XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)) + \ (mp)->m_sb.sb_inodesize + \ XFS_ALLOCFREE_LOG_RES(mp, 1) + \ (128 * \ (3 + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + \ XFS_ALLOCFREE_LOG_COUNT(mp, 1))))#define XFS_GROWRTALLOC_LOG_RES(mp) ((mp)->m_reservations.tr_growrtalloc)/* * Growing the rt section of the filesystem. * In the second set of transactions (ZERO) we zero the new metadata blocks. * one bitmap/summary block: blocksize */#define XFS_CALC_GROWRTZERO_LOG_RES(mp) \ ((mp)->m_sb.sb_blocksize + 128)#define XFS_GROWRTZERO_LOG_RES(mp) ((mp)->m_reservations.tr_growrtzero)/* * Growing the rt section of the filesystem. * In the third set of transactions (FREE) we update metadata without * allocating any new blocks. * superblock: sector size * bitmap inode: inode size * summary inode: inode size * one bitmap block: blocksize * summary blocks: new summary size */#define XFS_CALC_GROWRTFREE_LOG_RES(mp) \ ((mp)->m_sb.sb_sectsize + \ 2 * (mp)->m_sb.sb_inodesize + \ (mp)->m_sb.sb_blocksize + \ (mp)->m_rsumsize + \ (128 * 5))#define XFS_GROWRTFREE_LOG_RES(mp) ((mp)->m_reservations.tr_growrtfree)/* * Logging the inode modification timestamp on a synchronous write. * inode */#define XFS_CALC_SWRITE_LOG_RES(mp) \ ((mp)->m_sb.sb_inodesize + 128)#define XFS_SWRITE_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)/* * Logging the inode timestamps on an fsync -- same as SWRITE * as long as SWRITE logs the entire inode core */#define XFS_FSYNC_TS_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)/* * Logging the inode mode bits when writing a setuid/setgid file * inode */#define XFS_CALC_WRITEID_LOG_RES(mp) \ ((mp)->m_sb.sb_inodesize + 128)#define XFS_WRITEID_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)/* * Converting the inode from non-attributed to attributed. * the inode being converted: inode size * agf block and superblock (for block allocation) * the new block (directory sized) * bmap blocks for the new directory block * allocation btrees */#define XFS_CALC_ADDAFORK_LOG_RES(mp) \ ((mp)->m_sb.sb_inodesize + \ (mp)->m_sb.sb_sectsize * 2 + \ (mp)->m_dirblksize + \ XFS_FSB_TO_B(mp, (XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1)) + \ XFS_ALLOCFREE_LOG_RES(mp, 1) + \ (128 * (4 + (XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1) + \ XFS_ALLOCFREE_LOG_COUNT(mp, 1))))#define XFS_ADDAFORK_LOG_RES(mp) ((mp)->m_reservations.tr_addafork)/* * Removing the attribute fork of a file * the inode being truncated: inode size * the inode\'s bmap btree: max depth * block size * And the bmap_finish transaction can free the blocks and bmap blocks: * the agf for each of the ags: 4 * sector size * the agfl for each of the ags: 4 * sector size * the super block to reflect the freed blocks: sector size * worst case split in allocation btrees per extent assuming 4 extents: * 4 exts * 2 trees * (2 * max depth - 1) * block size */#define XFS_CALC_ATTRINVAL_LOG_RES(mp) \ (MAX( \ ((mp)->m_sb.sb_inodesize + \ XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)) + \ (128 * (1 + XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)))), \ ((4 * (mp)->m_sb.sb_sectsize) + \ (4 * (mp)->m_sb.sb_sectsize) + \ (mp)->m_sb.sb_sectsize + \ XFS_ALLOCFREE_LOG_RES(mp, 4) + \ (128 * (9 + XFS_ALLOCFREE_LOG_COUNT(mp, 4))))))#define XFS_ATTRINVAL_LOG_RES(mp) ((mp)->m_reservations.tr_attrinval)/* * Setting an attribute. * the inode getting the attribute * the superblock for allocations * the agfs extents are allocated from * the attribute btree * max depth * the inode allocation btree * Since attribute transaction space is dependent on the size of the attribute, * the calculation is done partially at mount time and partially at runtime. */#define XFS_CALC_ATTRSET_LOG_RES(mp) \ ((mp)->m_sb.sb_inodesize + \ (mp)->m_sb.sb_sectsize + \ XFS_FSB_TO_B((mp), XFS_DA_NODE_MAXDEPTH) + \ (128 * (2 + XFS_DA_NODE_MAXDEPTH)))#define XFS_ATTRSET_LOG_RES(mp, ext) \ ((mp)->m_reservations.tr_attrset + \ (ext * (mp)->m_sb.sb_sectsize) + \ (ext * XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK))) + \ (128 * (ext + (ext * XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)))))/* * Removing an attribute. * the inode: inode size * the attribute btree could join: max depth * block size * the inode bmap btree could join or split: max depth * block size * And the bmap_finish transaction can free the attr blocks freed giving: * the agf for the ag in which the blocks live: 2 * sector size * the agfl for the ag in which the blocks live: 2 * sector size * the superblock for the free block count: sector size * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size */#define XFS_CALC_ATTRRM_LOG_RES(mp) \ (MAX( \ ((mp)->m_sb.sb_inodesize + \ XFS_FSB_TO_B((mp), XFS_DA_NODE_MAXDEPTH) + \ XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)) + \ (128 * (1 + XFS_DA_NODE_MAXDEPTH + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)))), \ ((2 * (mp)->m_sb.sb_sectsize) + \ (2 * (mp)->m_sb.sb_sectsize) + \ (mp)->m_sb.sb_sectsize + \ XFS_ALLOCFREE_LOG_RES(mp, 2) + \ (128 * (5 + XFS_ALLOCFREE_LOG_COUNT(mp, 2))))))#define XFS_ATTRRM_LOG_RES(mp) ((mp)->m_reservations.tr_attrrm)/* * Clearing a bad agino number in an agi hash bucket. */#define XFS_CALC_CLEAR_AGI_BUCKET_LOG_RES(mp) \ ((mp)->m_sb.sb_sectsize + 128)#define XFS_CLEAR_AGI_BUCKET_LOG_RES(mp) ((mp)->m_reservations.tr_clearagi)/* * Various log count values. */#define XFS_DEFAULT_LOG_COUNT 1#define XFS_DEFAULT_PERM_LOG_COUNT 2#define XFS_ITRUNCATE_LOG_COUNT 2#define XFS_INACTIVE_LOG_COUNT 2#define XFS_CREATE_LOG_COUNT 2#define XFS_MKDIR_LOG_COUNT 3#define XFS_SYMLINK_LOG_COUNT 3#define XFS_REMOVE_LOG_COUNT 2#define XFS_LINK_LOG_COUNT 2#define XFS_RENAME_LOG_COUNT 2#define XFS_WRITE_LOG_COUNT 2#define XFS_ADDAFORK_LOG_COUNT 2#define XFS_ATTRINVAL_LOG_COUNT 1#define XFS_ATTRSET_LOG_COUNT 3#define XFS_ATTRRM_LOG_COUNT 3/* * Here we centralize the specification of XFS meta-data buffer * reference count values. This determine how hard the buffer * cache tries to hold onto the buffer. */#define XFS_AGF_REF 4#define XFS_AGI_REF 4#define XFS_AGFL_REF 3#define XFS_INO_BTREE_REF 3#define XFS_ALLOC_BTREE_REF 2#define XFS_BMAP_BTREE_REF 2#define XFS_DIR_BTREE_REF 2#define XFS_ATTR_BTREE_REF 1#define XFS_INO_REF 1#define XFS_DQUOT_REF 1#ifdef __KERNEL__/* * XFS transaction mechanism exported interfaces that are * actually macros. */#define xfs_trans_get_log_res(tp) ((tp)->t_log_res)#define xfs_trans_get_log_count(tp) ((tp)->t_log_count)#define xfs_trans_get_block_res(tp) ((tp)->t_blk_res)#define xfs_trans_set_sync(tp) ((tp)->t_flags |= XFS_TRANS_SYNC)#ifdef DEBUG#define xfs_trans_agblocks_delta(tp, d) ((tp)->t_ag_freeblks_delta += (int64_t)d)#define xfs_trans_agflist_delta(tp, d) ((tp)->t_ag_flist_delta += (int64_t)d)#define xfs_trans_agbtree_delta(tp, d) ((tp)->t_ag_btree_delta += (int64_t)d)#else#define xfs_trans_agblocks_delta(tp, d)#define xfs_trans_agflist_delta(tp, d)#define xfs_trans_agbtree_delta(tp, d)#endif/* * XFS transaction mechanism exported interfaces. */void xfs_trans_init(struct xfs_mount *);xfs_trans_t *xfs_trans_alloc(struct xfs_mount *, uint);xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint);xfs_trans_t *xfs_trans_dup(xfs_trans_t *);int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint, uint, uint);void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);struct xfs_buf *xfs_trans_get_buf(xfs_trans_t *, struct xfs_buftarg *, xfs_daddr_t, int, uint);int xfs_trans_read_buf(struct xfs_mount *, xfs_trans_t *, struct xfs_buftarg *, xfs_daddr_t, int, uint, struct xfs_buf **);struct xfs_buf *xfs_trans_getsb(xfs_trans_t *, struct xfs_mount *, int);void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *);void xfs_trans_bjoin(xfs_trans_t *, struct xfs_buf *);void xfs_trans_bhold(xfs_trans_t *, struct xfs_buf *);void xfs_trans_bhold_release(xfs_trans_t *, struct xfs_buf *);void xfs_trans_binval(xfs_trans_t *, struct xfs_buf *);void xfs_trans_inode_buf(xfs_trans_t *, struct xfs_buf *);void xfs_trans_stale_inode_buf(xfs_trans_t *, struct xfs_buf *);void xfs_trans_dquot_buf(xfs_trans_t *, struct xfs_buf *, uint);void xfs_trans_inode_alloc_buf(xfs_trans_t *, struct xfs_buf *);int xfs_trans_iget(struct xfs_mount *, xfs_trans_t *, xfs_ino_t , uint, uint, struct xfs_inode **);void xfs_trans_ijoin(xfs_trans_t *, struct xfs_inode *, uint);void xfs_trans_ihold(xfs_trans_t *, struct xfs_inode *);void xfs_trans_log_buf(xfs_trans_t *, struct xfs_buf *, uint, uint);void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint);struct xfs_efi_log_item *xfs_trans_get_efi(xfs_trans_t *, uint);void xfs_efi_release(struct xfs_efi_log_item *, uint);void xfs_trans_log_efi_extent(xfs_trans_t *, struct xfs_efi_log_item *, xfs_fsblock_t, xfs_extlen_t);struct xfs_efd_log_item *xfs_trans_get_efd(xfs_trans_t *, struct xfs_efi_log_item *, uint);void xfs_trans_log_efd_extent(xfs_trans_t *, struct xfs_efd_log_item *, xfs_fsblock_t, xfs_extlen_t);int _xfs_trans_commit(xfs_trans_t *, uint flags, int *);#define xfs_trans_commit(tp, flags) _xfs_trans_commit(tp, flags, NULL)void xfs_trans_cancel(xfs_trans_t *, int);void xfs_trans_ail_init(struct xfs_mount *);xfs_lsn_t xfs_trans_push_ail(struct xfs_mount *, xfs_lsn_t);xfs_lsn_t xfs_trans_tail_ail(struct xfs_mount *);void xfs_trans_unlocked_item(struct xfs_mount *, xfs_log_item_t *);xfs_log_busy_slot_t *xfs_trans_add_busy(xfs_trans_t *tp, xfs_agnumber_t ag, xfs_extlen_t idx);#endif /* __KERNEL__ */#endif /* __XFS_TRANS_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -