2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
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.
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 */
78 xfs_trans_reservations_t
*tr
;
85 nblks
= XFS_DAENTER_SPACE_RES(mp
, XFS_ATTR_FORK
);
88 * Fill in the arg structure for this request.
90 bzero(&args
, sizeof(args
));
92 args
.namelen
= MAXNAMELEN
;
94 args
.valuelen
= 65536;
98 args
.firstblock
= NULL
;
100 args
.whichfork
= XFS_ATTR_FORK
;
104 * Determine space new attribute will use, and if it will be
105 * inline or out of line.
107 size
= libxfs_attr_leaf_newentsize(
108 &args
, mp
->m_sb
.sb_blocksize
, &local
);
111 printf("Uh-oh.. attribute is local\n");
113 /* Out of line attribute, cannot double split, but make
114 * room for the attribute value itself.
116 nblks
+= XFS_B_TO_FSB(mp
, size
);
117 nblks
+= XFS_NEXTENTADD_SPACE_RES(mp
, size
, XFS_ATTR_FORK
);
119 res
= XFS_ATTRSET_LOG_RES(mp
, nblks
);
121 printf("size = %d nblks = %d res = %d\n", size
, nblks
, res
);
123 mp
->m_reservations
.tr_attrset
= res
;
125 for (rval
= 0, tr
= &mp
->m_reservations
, p
= (uint
*)tr
,
126 q
= (uint
*)&tr_count
;
127 p
< (uint
*)(tr
+ 1);
129 if ((int)*p
> rval
) {
138 main(int argc
, char **argv
)
149 progname
= basename(argv
[0]);
151 fprintf(stderr
, "Usage: %s\n", progname
);
154 memset(&m
, 0, sizeof(m
));
156 sbp
->sb_magicnum
= XFS_SB_MAGIC
;
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
)
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
)
178 XFS_SB_VERSION_DIRV2BIT
:
180 libxfs_mount(&m
, sbp
, 0, 0, 0, 0);
181 i
= max_trans_res(&m
, &mul
);
183 "#define\tMAXTRRES_B%d_I%d_D%d_V%d\t%lld\t"
184 "/* LOG_FACTOR %d */\n",
185 bl
, il
, dl
, dv
, (long long)
186 XFS_B_TO_FSB(&m
, i
), mul
);