]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/xfs_trans_resv.h
xfs: make struct xfs_perag kernel only
[thirdparty/xfsprogs-dev.git] / include / xfs_trans_resv.h
CommitLineData
364e85ec
DC
1/*
2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * 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.
13 *
14 * 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
17 */
18#ifndef __XFS_TRANS_RESV_H__
19#define __XFS_TRANS_RESV_H__
20
21struct xfs_mount;
22
23/*
24 * structure for maintaining pre-calculated transaction reservations.
25 */
26struct xfs_trans_resv {
27 uint tr_write; /* extent alloc trans */
28 uint tr_itruncate; /* truncate trans */
29 uint tr_rename; /* rename trans */
30 uint tr_link; /* link trans */
31 uint tr_remove; /* unlink trans */
32 uint tr_symlink; /* symlink trans */
33 uint tr_create; /* create trans */
34 uint tr_mkdir; /* mkdir trans */
35 uint tr_ifree; /* inode free trans */
36 uint tr_ichange; /* inode update trans */
37 uint tr_growdata; /* fs data section grow trans */
38 uint tr_swrite; /* sync write inode trans */
39 uint tr_addafork; /* cvt inode to attributed trans */
40 uint tr_writeid; /* write setuid/setgid file */
41 uint tr_attrinval; /* attr fork buffer invalidation */
42 uint tr_attrsetm; /* set/create an attribute at mount time */
43 uint tr_attrsetrt; /* set/create an attribute at runtime */
44 uint tr_attrrm; /* remove an attribute */
45 uint tr_clearagi; /* clear bad agi unlinked ino bucket */
46 uint tr_growrtalloc; /* grow realtime allocations */
47 uint tr_growrtzero; /* grow realtime zeroing */
48 uint tr_growrtfree; /* grow realtime freeing */
49 uint tr_qm_sbchange; /* change quota flags */
50 uint tr_qm_setqlim; /* adjust quota limits */
51 uint tr_qm_dqalloc; /* allocate quota on disk */
52 uint tr_qm_quotaoff; /* turn quota off */
53 uint tr_qm_equotaoff;/* end of turn quota off */
54 uint tr_sb; /* modify superblock */
55};
56
57/*
58 * Per-extent log reservation for the allocation btree changes
59 * involved in freeing or allocating an extent.
60 * 2 trees * (2 blocks/level * max depth - 1) * block size
61 */
62#define XFS_ALLOCFREE_LOG_RES(mp,nx) \
63 ((nx) * (2 * XFS_FSB_TO_B((mp), 2 * XFS_AG_MAXLEVELS(mp) - 1)))
64#define XFS_ALLOCFREE_LOG_COUNT(mp,nx) \
65 ((nx) * (2 * (2 * XFS_AG_MAXLEVELS(mp) - 1)))
66
67/*
68 * Per-directory log reservation for any directory change.
69 * dir blocks: (1 btree block per level + data block + free block) * dblock size
70 * bmap btree: (levels + 2) * max depth * block size
71 * v2 directory blocks can be fragmented below the dirblksize down to the fsb
72 * size, so account for that in the DAENTER macros.
73 */
74#define XFS_DIROP_LOG_RES(mp) \
75 (XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \
76 (XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)))
77#define XFS_DIROP_LOG_COUNT(mp) \
78 (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \
79 XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)
80
81
82#define XFS_WRITE_LOG_RES(mp) ((mp)->m_reservations.tr_write)
83#define XFS_ITRUNCATE_LOG_RES(mp) ((mp)->m_reservations.tr_itruncate)
84#define XFS_RENAME_LOG_RES(mp) ((mp)->m_reservations.tr_rename)
85#define XFS_LINK_LOG_RES(mp) ((mp)->m_reservations.tr_link)
86#define XFS_REMOVE_LOG_RES(mp) ((mp)->m_reservations.tr_remove)
87#define XFS_SYMLINK_LOG_RES(mp) ((mp)->m_reservations.tr_symlink)
88#define XFS_CREATE_LOG_RES(mp) ((mp)->m_reservations.tr_create)
89#define XFS_MKDIR_LOG_RES(mp) ((mp)->m_reservations.tr_mkdir)
90#define XFS_IFREE_LOG_RES(mp) ((mp)->m_reservations.tr_ifree)
91#define XFS_ICHANGE_LOG_RES(mp) ((mp)->m_reservations.tr_ichange)
92#define XFS_GROWDATA_LOG_RES(mp) ((mp)->m_reservations.tr_growdata)
93#define XFS_GROWRTALLOC_LOG_RES(mp) ((mp)->m_reservations.tr_growrtalloc)
94#define XFS_GROWRTZERO_LOG_RES(mp) ((mp)->m_reservations.tr_growrtzero)
95#define XFS_GROWRTFREE_LOG_RES(mp) ((mp)->m_reservations.tr_growrtfree)
96#define XFS_SWRITE_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)
97/*
98 * Logging the inode timestamps on an fsync -- same as SWRITE
99 * as long as SWRITE logs the entire inode core
100 */
101#define XFS_FSYNC_TS_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)
102#define XFS_WRITEID_LOG_RES(mp) ((mp)->m_reservations.tr_swrite)
103#define XFS_ADDAFORK_LOG_RES(mp) ((mp)->m_reservations.tr_addafork)
104#define XFS_ATTRINVAL_LOG_RES(mp) ((mp)->m_reservations.tr_attrinval)
105#define XFS_ATTRSETM_LOG_RES(mp) ((mp)->m_reservations.tr_attrsetm)
106#define XFS_ATTRSETRT_LOG_RES(mp) ((mp)->m_reservations.tr_attrsetrt)
107#define XFS_ATTRRM_LOG_RES(mp) ((mp)->m_reservations.tr_attrrm)
108#define XFS_CLEAR_AGI_BUCKET_LOG_RES(mp) ((mp)->m_reservations.tr_clearagi)
109#define XFS_QM_SBCHANGE_LOG_RES(mp) ((mp)->m_reservations.tr_qm_sbchange)
110#define XFS_QM_SETQLIM_LOG_RES(mp) ((mp)->m_reservations.tr_qm_setqlim)
111#define XFS_QM_DQALLOC_LOG_RES(mp) ((mp)->m_reservations.tr_qm_dqalloc)
112#define XFS_QM_QUOTAOFF_LOG_RES(mp) ((mp)->m_reservations.tr_qm_quotaoff)
113#define XFS_QM_QUOTAOFF_END_LOG_RES(mp) ((mp)->m_reservations.tr_qm_equotaoff)
114#define XFS_SB_LOG_RES(mp) ((mp)->m_reservations.tr_sb)
115
116/*
117 * Various log count values.
118 */
119#define XFS_DEFAULT_LOG_COUNT 1
120#define XFS_DEFAULT_PERM_LOG_COUNT 2
121#define XFS_ITRUNCATE_LOG_COUNT 2
122#define XFS_INACTIVE_LOG_COUNT 2
123#define XFS_CREATE_LOG_COUNT 2
124#define XFS_MKDIR_LOG_COUNT 3
125#define XFS_SYMLINK_LOG_COUNT 3
126#define XFS_REMOVE_LOG_COUNT 2
127#define XFS_LINK_LOG_COUNT 2
128#define XFS_RENAME_LOG_COUNT 2
129#define XFS_WRITE_LOG_COUNT 2
130#define XFS_ADDAFORK_LOG_COUNT 2
131#define XFS_ATTRINVAL_LOG_COUNT 1
132#define XFS_ATTRSET_LOG_COUNT 3
133#define XFS_ATTRRM_LOG_COUNT 3
134
135void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp);
136
137#endif /* __XFS_TRANS_RESV_H__ */