Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Dave Chinner | 7fd36c4 | 2013-08-12 20:49:32 +1000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
| 4 | * All Rights Reserved. |
Dave Chinner | 7fd36c4 | 2013-08-12 20:49:32 +1000 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __XFS_TRANS_RESV_H__ |
| 7 | #define __XFS_TRANS_RESV_H__ |
| 8 | |
| 9 | struct xfs_mount; |
| 10 | |
| 11 | /* |
| 12 | * structure for maintaining pre-calculated transaction reservations. |
| 13 | */ |
Jie Liu | 0eadd10 | 2013-08-12 20:49:56 +1000 | [diff] [blame] | 14 | struct xfs_trans_res { |
| 15 | uint tr_logres; /* log space unit in bytes per log ticket */ |
| 16 | int tr_logcount; /* number of log operations per log ticket */ |
| 17 | int tr_logflags; /* log flags, currently only used for indicating |
| 18 | * a reservation request is permanent or not */ |
| 19 | }; |
| 20 | |
Dave Chinner | 7fd36c4 | 2013-08-12 20:49:32 +1000 | [diff] [blame] | 21 | struct xfs_trans_resv { |
Jie Liu | 0eadd10 | 2013-08-12 20:49:56 +1000 | [diff] [blame] | 22 | struct xfs_trans_res tr_write; /* extent alloc trans */ |
| 23 | struct xfs_trans_res tr_itruncate; /* truncate trans */ |
| 24 | struct xfs_trans_res tr_rename; /* rename trans */ |
| 25 | struct xfs_trans_res tr_link; /* link trans */ |
| 26 | struct xfs_trans_res tr_remove; /* unlink trans */ |
| 27 | struct xfs_trans_res tr_symlink; /* symlink trans */ |
| 28 | struct xfs_trans_res tr_create; /* create trans */ |
Zhi Yong Wu | 99b6436 | 2013-12-18 08:22:40 +0800 | [diff] [blame] | 29 | struct xfs_trans_res tr_create_tmpfile; /* create O_TMPFILE trans */ |
Jie Liu | 0eadd10 | 2013-08-12 20:49:56 +1000 | [diff] [blame] | 30 | struct xfs_trans_res tr_mkdir; /* mkdir trans */ |
| 31 | struct xfs_trans_res tr_ifree; /* inode free trans */ |
| 32 | struct xfs_trans_res tr_ichange; /* inode update trans */ |
| 33 | struct xfs_trans_res tr_growdata; /* fs data section grow trans */ |
Jie Liu | 0eadd10 | 2013-08-12 20:49:56 +1000 | [diff] [blame] | 34 | struct xfs_trans_res tr_addafork; /* add inode attr fork trans */ |
| 35 | struct xfs_trans_res tr_writeid; /* write setuid/setgid file */ |
| 36 | struct xfs_trans_res tr_attrinval; /* attr fork buffer |
| 37 | * invalidation */ |
| 38 | struct xfs_trans_res tr_attrsetm; /* set/create an attribute at |
| 39 | * mount time */ |
| 40 | struct xfs_trans_res tr_attrsetrt; /* set/create an attribute at |
| 41 | * runtime */ |
| 42 | struct xfs_trans_res tr_attrrm; /* remove an attribute */ |
| 43 | struct xfs_trans_res tr_clearagi; /* clear agi unlinked bucket */ |
| 44 | struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */ |
| 45 | struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */ |
| 46 | struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */ |
Jie Liu | 0eadd10 | 2013-08-12 20:49:56 +1000 | [diff] [blame] | 47 | struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */ |
| 48 | struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */ |
| 49 | struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */ |
| 50 | struct xfs_trans_res tr_qm_equotaoff;/* end of turn quota off */ |
| 51 | struct xfs_trans_res tr_sb; /* modify superblock */ |
Jie Liu | 20996c9 | 2013-08-12 20:49:57 +1000 | [diff] [blame] | 52 | struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */ |
Dave Chinner | 7fd36c4 | 2013-08-12 20:49:32 +1000 | [diff] [blame] | 53 | }; |
| 54 | |
Jie Liu | 3d3c8b5 | 2013-08-12 20:49:59 +1000 | [diff] [blame] | 55 | /* shorthand way of accessing reservation structure */ |
| 56 | #define M_RES(mp) (&(mp)->m_resv) |
| 57 | |
Dave Chinner | 7fd36c4 | 2013-08-12 20:49:32 +1000 | [diff] [blame] | 58 | /* |
Dave Chinner | 7fd36c4 | 2013-08-12 20:49:32 +1000 | [diff] [blame] | 59 | * Per-directory log reservation for any directory change. |
| 60 | * dir blocks: (1 btree block per level + data block + free block) * dblock size |
| 61 | * bmap btree: (levels + 2) * max depth * block size |
| 62 | * v2 directory blocks can be fragmented below the dirblksize down to the fsb |
| 63 | * size, so account for that in the DAENTER macros. |
| 64 | */ |
| 65 | #define XFS_DIROP_LOG_RES(mp) \ |
| 66 | (XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \ |
| 67 | (XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1))) |
| 68 | #define XFS_DIROP_LOG_COUNT(mp) \ |
| 69 | (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \ |
| 70 | XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1) |
| 71 | |
Dave Chinner | 7fd36c4 | 2013-08-12 20:49:32 +1000 | [diff] [blame] | 72 | /* |
| 73 | * Various log count values. |
| 74 | */ |
| 75 | #define XFS_DEFAULT_LOG_COUNT 1 |
| 76 | #define XFS_DEFAULT_PERM_LOG_COUNT 2 |
| 77 | #define XFS_ITRUNCATE_LOG_COUNT 2 |
Darrick J. Wong | 80de462 | 2016-10-03 09:11:47 -0700 | [diff] [blame] | 78 | #define XFS_ITRUNCATE_LOG_COUNT_REFLINK 8 |
Dave Chinner | 7fd36c4 | 2013-08-12 20:49:32 +1000 | [diff] [blame] | 79 | #define XFS_INACTIVE_LOG_COUNT 2 |
| 80 | #define XFS_CREATE_LOG_COUNT 2 |
Zhi Yong Wu | 99b6436 | 2013-12-18 08:22:40 +0800 | [diff] [blame] | 81 | #define XFS_CREATE_TMPFILE_LOG_COUNT 2 |
Dave Chinner | 7fd36c4 | 2013-08-12 20:49:32 +1000 | [diff] [blame] | 82 | #define XFS_MKDIR_LOG_COUNT 3 |
| 83 | #define XFS_SYMLINK_LOG_COUNT 3 |
| 84 | #define XFS_REMOVE_LOG_COUNT 2 |
| 85 | #define XFS_LINK_LOG_COUNT 2 |
| 86 | #define XFS_RENAME_LOG_COUNT 2 |
| 87 | #define XFS_WRITE_LOG_COUNT 2 |
Darrick J. Wong | 80de462 | 2016-10-03 09:11:47 -0700 | [diff] [blame] | 88 | #define XFS_WRITE_LOG_COUNT_REFLINK 8 |
Dave Chinner | 7fd36c4 | 2013-08-12 20:49:32 +1000 | [diff] [blame] | 89 | #define XFS_ADDAFORK_LOG_COUNT 2 |
| 90 | #define XFS_ATTRINVAL_LOG_COUNT 1 |
| 91 | #define XFS_ATTRSET_LOG_COUNT 3 |
| 92 | #define XFS_ATTRRM_LOG_COUNT 3 |
| 93 | |
| 94 | void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp); |
Darrick J. Wong | 1946b91 | 2016-10-03 09:11:18 -0700 | [diff] [blame] | 95 | uint xfs_allocfree_log_count(struct xfs_mount *mp, uint num_ops); |
Dave Chinner | 7fd36c4 | 2013-08-12 20:49:32 +1000 | [diff] [blame] | 96 | |
| 97 | #endif /* __XFS_TRANS_RESV_H__ */ |