]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
9911e5dc | 2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. |
2bd0ea18 NS |
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 | ||
33 | /* | |
34 | * maxtrres | |
35 | * | |
36 | * Compute the maximum transaction reservation for every legal | |
37 | * combination of block size, inode size, directory version, | |
38 | * and directory block size. | |
39 | * Generates a table compiled into mkfs, to control the default | |
40 | * and minimum log sizes. | |
41 | */ | |
42 | ||
43 | #include <libxfs.h> | |
44 | #include "xfs_mkfs.h" | |
45 | ||
46 | xfs_trans_reservations_t tr_count = { | |
47 | XFS_WRITE_LOG_COUNT, /* extent alloc trans */ | |
48 | XFS_ITRUNCATE_LOG_COUNT, /* truncate trans */ | |
49 | XFS_RENAME_LOG_COUNT, /* rename trans */ | |
50 | XFS_LINK_LOG_COUNT, /* link trans */ | |
51 | XFS_REMOVE_LOG_COUNT, /* unlink trans */ | |
52 | XFS_SYMLINK_LOG_COUNT, /* symlink trans */ | |
53 | XFS_CREATE_LOG_COUNT, /* create trans */ | |
54 | XFS_MKDIR_LOG_COUNT, /* mkdir trans */ | |
55 | XFS_DEFAULT_LOG_COUNT, /* inode free trans */ | |
56 | XFS_DEFAULT_LOG_COUNT, /* inode update trans */ | |
57 | XFS_DEFAULT_LOG_COUNT, /* fs data section grow trans */ | |
58 | XFS_DEFAULT_LOG_COUNT, /* sync write inode trans */ | |
59 | XFS_ADDAFORK_LOG_COUNT, /* cvt inode to attributed trans */ | |
60 | XFS_DEFAULT_LOG_COUNT, /* write setuid/setgid file */ | |
61 | XFS_ATTRINVAL_LOG_COUNT, /* attr fork buffer invalidation */ | |
62 | XFS_ATTRSET_LOG_COUNT, /* set/create an attribute */ | |
63 | XFS_ATTRRM_LOG_COUNT, /* remove an attribute */ | |
64 | XFS_DEFAULT_LOG_COUNT, /* clear bad agi unlinked ino bucket */ | |
65 | XFS_DEFAULT_PERM_LOG_COUNT, /* grow realtime allocations */ | |
66 | XFS_DEFAULT_LOG_COUNT, /* grow realtime zeroing */ | |
67 | XFS_DEFAULT_LOG_COUNT, /* grow realtime freeing */ | |
68 | }; | |
69 | ||
70 | static int | |
71 | max_trans_res( | |
72 | xfs_mount_t *mp, | |
73 | int *mul) | |
74 | { | |
75 | uint *p; | |
76 | uint *q; | |
77 | int rval; | |
78 | xfs_trans_reservations_t *tr; | |
79 | xfs_da_args_t args; | |
80 | int local; | |
81 | int size; | |
82 | int nblks; | |
83 | int res; | |
84 | ||
85 | nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK); | |
86 | ||
87 | /* | |
88 | * Fill in the arg structure for this request. | |
89 | */ | |
90 | bzero(&args, sizeof(args)); | |
91 | args.name = NULL; | |
92 | args.namelen = MAXNAMELEN; | |
93 | args.value = NULL; | |
94 | args.valuelen = 65536; | |
95 | args.flags = 0; | |
96 | args.hashval = 0; | |
97 | args.dp = NULL; | |
98 | args.firstblock = NULL; | |
99 | args.flist = NULL; | |
100 | args.whichfork = XFS_ATTR_FORK; | |
101 | args.oknoent = 1; | |
102 | ||
103 | /* | |
104 | * Determine space new attribute will use, and if it will be | |
105 | * inline or out of line. | |
106 | */ | |
107 | size = libxfs_attr_leaf_newentsize( | |
108 | &args, mp->m_sb.sb_blocksize, &local); | |
109 | ||
110 | if (local) { | |
111 | printf("Uh-oh.. attribute is local\n"); | |
112 | } else { | |
113 | /* Out of line attribute, cannot double split, but make | |
114 | * room for the attribute value itself. | |
115 | */ | |
116 | nblks += XFS_B_TO_FSB(mp, size); | |
117 | nblks += XFS_NEXTENTADD_SPACE_RES(mp, size, XFS_ATTR_FORK); | |
118 | } | |
119 | res = XFS_ATTRSET_LOG_RES(mp, nblks); | |
120 | #if 0 | |
121 | printf("size = %d nblks = %d res = %d\n", size, nblks, res); | |
122 | #endif | |
123 | mp->m_reservations.tr_attrset = res; | |
124 | ||
125 | for (rval = 0, tr = &mp->m_reservations, p = (uint *)tr, | |
126 | q = (uint *)&tr_count; | |
127 | p < (uint *)(tr + 1); | |
128 | p++, q++) { | |
129 | if ((int)*p > rval) { | |
130 | rval = (int)*p; | |
131 | *mul = (int)*q; | |
132 | } | |
133 | } | |
134 | return rval; | |
135 | } | |
136 | ||
137 | int | |
138 | main(int argc, char **argv) | |
139 | { | |
140 | int bl; | |
141 | int dl; | |
142 | int dv; | |
143 | int i; | |
144 | int il; | |
145 | xfs_mount_t m; | |
146 | xfs_sb_t *sbp; | |
147 | int mul; | |
148 | ||
149 | progname = basename(argv[0]); | |
150 | if (argc > 1) { | |
151 | fprintf(stderr, "Usage: %s\n", progname); | |
152 | return 1; | |
153 | } | |
154 | memset(&m, 0, sizeof(m)); | |
155 | sbp = &m.m_sb; | |
156 | sbp->sb_magicnum = XFS_SB_MAGIC; | |
157 | sbp->sb_sectlog = 9; | |
158 | sbp->sb_sectsize = 1 << sbp->sb_sectlog; | |
159 | for (bl = XFS_MIN_BLOCKSIZE_LOG; bl <= XFS_MAX_BLOCKSIZE_LOG; bl++) { | |
160 | sbp->sb_blocklog = bl; | |
161 | sbp->sb_blocksize = 1 << bl; | |
162 | sbp->sb_agblocks = XFS_AG_MIN_BYTES / (1 << bl); | |
163 | for (il = XFS_DINODE_MIN_LOG; il <= XFS_DINODE_MAX_LOG; il++) { | |
164 | if ((1 << il) > (1 << bl) / XFS_MIN_INODE_PERBLOCK) | |
165 | continue; | |
166 | sbp->sb_inodelog = il; | |
167 | sbp->sb_inopblog = bl - il; | |
168 | sbp->sb_inodesize = 1 << il; | |
169 | sbp->sb_inopblock = 1 << (bl - il); | |
170 | for (dl = bl; dl <= XFS_MAX_BLOCKSIZE_LOG; dl++) { | |
171 | sbp->sb_dirblklog = dl - bl; | |
172 | for (dv = 1; dv <= 2; dv++) { | |
173 | if (dv == 1 && dl != bl) | |
174 | continue; | |
175 | sbp->sb_versionnum = | |
176 | XFS_SB_VERSION_4 | | |
177 | (dv == 2 ? | |
178 | XFS_SB_VERSION_DIRV2BIT : | |
179 | 0); | |
180 | libxfs_mount(&m, sbp, 0, 0, 0, 0); | |
181 | i = max_trans_res(&m, &mul); | |
182 | printf( | |
183 | "#define\tMAXTRRES_B%d_I%d_D%d_V%d\t%lld\t" | |
184 | "/* LOG_FACTOR %d */\n", | |
5b64e00a | 185 | bl, il, dl, dv, (long long) |
2bd0ea18 NS |
186 | XFS_B_TO_FSB(&m, i), mul); |
187 | libxfs_umount(&m); | |
188 | } | |
189 | } | |
190 | } | |
191 | } | |
192 | return 0; | |
193 | } |