blob: 2d5bdfce6d8fd2627fcc46603eb83faed12780e9 [file] [log] [blame]
Dave Chinner7fd36c42013-08-12 20:49:32 +10001/*
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 */
Jie Liu0eadd102013-08-12 20:49:56 +100026struct xfs_trans_res {
27 uint tr_logres; /* log space unit in bytes per log ticket */
28 int tr_logcount; /* number of log operations per log ticket */
29 int tr_logflags; /* log flags, currently only used for indicating
30 * a reservation request is permanent or not */
31};
32
Dave Chinner7fd36c42013-08-12 20:49:32 +100033struct xfs_trans_resv {
Jie Liu0eadd102013-08-12 20:49:56 +100034 struct xfs_trans_res tr_write; /* extent alloc trans */
35 struct xfs_trans_res tr_itruncate; /* truncate trans */
36 struct xfs_trans_res tr_rename; /* rename trans */
37 struct xfs_trans_res tr_link; /* link trans */
38 struct xfs_trans_res tr_remove; /* unlink trans */
39 struct xfs_trans_res tr_symlink; /* symlink trans */
40 struct xfs_trans_res tr_create; /* create trans */
Zhi Yong Wu99b64362013-12-18 08:22:40 +080041 struct xfs_trans_res tr_create_tmpfile; /* create O_TMPFILE trans */
Jie Liu0eadd102013-08-12 20:49:56 +100042 struct xfs_trans_res tr_mkdir; /* mkdir trans */
43 struct xfs_trans_res tr_ifree; /* inode free trans */
44 struct xfs_trans_res tr_ichange; /* inode update trans */
45 struct xfs_trans_res tr_growdata; /* fs data section grow trans */
Jie Liu0eadd102013-08-12 20:49:56 +100046 struct xfs_trans_res tr_addafork; /* add inode attr fork trans */
47 struct xfs_trans_res tr_writeid; /* write setuid/setgid file */
48 struct xfs_trans_res tr_attrinval; /* attr fork buffer
49 * invalidation */
50 struct xfs_trans_res tr_attrsetm; /* set/create an attribute at
51 * mount time */
52 struct xfs_trans_res tr_attrsetrt; /* set/create an attribute at
53 * runtime */
54 struct xfs_trans_res tr_attrrm; /* remove an attribute */
55 struct xfs_trans_res tr_clearagi; /* clear agi unlinked bucket */
56 struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */
57 struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */
58 struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */
Jie Liu0eadd102013-08-12 20:49:56 +100059 struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */
60 struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */
61 struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */
62 struct xfs_trans_res tr_qm_equotaoff;/* end of turn quota off */
63 struct xfs_trans_res tr_sb; /* modify superblock */
Jie Liu20996c92013-08-12 20:49:57 +100064 struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */
Dave Chinner7fd36c42013-08-12 20:49:32 +100065};
66
Jie Liu3d3c8b52013-08-12 20:49:59 +100067/* shorthand way of accessing reservation structure */
68#define M_RES(mp) (&(mp)->m_resv)
69
Dave Chinner7fd36c42013-08-12 20:49:32 +100070/*
71 * Per-extent log reservation for the allocation btree changes
72 * involved in freeing or allocating an extent.
73 * 2 trees * (2 blocks/level * max depth - 1) * block size
74 */
75#define XFS_ALLOCFREE_LOG_RES(mp,nx) \
76 ((nx) * (2 * XFS_FSB_TO_B((mp), 2 * XFS_AG_MAXLEVELS(mp) - 1)))
77#define XFS_ALLOCFREE_LOG_COUNT(mp,nx) \
78 ((nx) * (2 * (2 * XFS_AG_MAXLEVELS(mp) - 1)))
79
80/*
81 * Per-directory log reservation for any directory change.
82 * dir blocks: (1 btree block per level + data block + free block) * dblock size
83 * bmap btree: (levels + 2) * max depth * block size
84 * v2 directory blocks can be fragmented below the dirblksize down to the fsb
85 * size, so account for that in the DAENTER macros.
86 */
87#define XFS_DIROP_LOG_RES(mp) \
88 (XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \
89 (XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)))
90#define XFS_DIROP_LOG_COUNT(mp) \
91 (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \
92 XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)
93
Dave Chinner7fd36c42013-08-12 20:49:32 +100094/*
95 * Various log count values.
96 */
97#define XFS_DEFAULT_LOG_COUNT 1
98#define XFS_DEFAULT_PERM_LOG_COUNT 2
99#define XFS_ITRUNCATE_LOG_COUNT 2
100#define XFS_INACTIVE_LOG_COUNT 2
101#define XFS_CREATE_LOG_COUNT 2
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800102#define XFS_CREATE_TMPFILE_LOG_COUNT 2
Dave Chinner7fd36c42013-08-12 20:49:32 +1000103#define XFS_MKDIR_LOG_COUNT 3
104#define XFS_SYMLINK_LOG_COUNT 3
105#define XFS_REMOVE_LOG_COUNT 2
106#define XFS_LINK_LOG_COUNT 2
107#define XFS_RENAME_LOG_COUNT 2
108#define XFS_WRITE_LOG_COUNT 2
109#define XFS_ADDAFORK_LOG_COUNT 2
110#define XFS_ATTRINVAL_LOG_COUNT 1
111#define XFS_ATTRSET_LOG_COUNT 3
112#define XFS_ATTRRM_LOG_COUNT 3
113
114void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp);
115
116#endif /* __XFS_TRANS_RESV_H__ */