~ubuntu-branches/ubuntu/edgy/xfsprogs/edgy

« back to all changes in this revision

Viewing changes to mkfs/xfs_mkfs.c

  • Committer: Bazaar Package Importer
  • Author(s): Nathan Scott
  • Date: 2004-07-28 21:11:38 UTC
  • Revision ID: james.westby@ubuntu.com-20040728211138-0v4pdnunnp7na5lm
Tags: 2.6.20-1
* New upstream release.
* Fix xfs_io segfault on non-XFS files.  (closes: #260470)
* Fix packaging botch, deleted files included.  (closes: #260491)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
 
2
 * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
3
3
 * 
4
4
 * This program is free software; you can redistribute it and/or modify it
5
5
 * under the terms of version 2 of the GNU General Public License as
30
30
 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31
31
 */
32
32
 
33
 
#include <fstyp.h>
34
 
#include <stdio.h>
35
 
#include <volume.h>
36
 
#include <mountinfo.h>
37
 
#include <libxfs.h>
38
 
 
 
33
#include <xfs/libxfs.h>
 
34
#include <disk/fstyp.h>
 
35
#include <disk/volume.h>
 
36
#include <ctype.h>
39
37
#include "xfs_mkfs.h"
40
 
#include "maxtrres.h"
41
 
#include "proto.h"
42
38
 
43
39
/*
44
40
 * Prototypes for internal functions.
49
45
static void respec(char opt, char *tab[], int idx);
50
46
static void unknown(char opt, char *s);
51
47
static int  ispow2(unsigned int i);
52
 
static int  max_trans_res(xfs_mount_t *mp);
53
48
 
54
49
/*
55
50
 * option tables for getsubopt calls
56
51
 */
57
 
char    *bopts[] = {
 
52
char *bopts[] = {
58
53
#define B_LOG           0
59
54
        "log",
60
55
#define B_SIZE          1
83
78
        "su",
84
79
#define D_SW            9
85
80
        "sw",
 
81
#define D_SECTLOG       10
 
82
        "sectlog",
 
83
#define D_SECTSIZE      11
 
84
        "sectsize",
86
85
        NULL
87
86
};
88
87
 
107
106
        "internal",
108
107
#define L_SIZE          2
109
108
        "size",
110
 
#define L_DEV           3
 
109
#define L_VERSION       3
 
110
        "version",
 
111
#define L_SUNIT         4
 
112
        "sunit",
 
113
#define L_SU            5
 
114
        "su",
 
115
#define L_DEV           6
111
116
        "logdev",
 
117
#define L_SECTLOG       7
 
118
        "sectlog",
 
119
#define L_SECTSIZE      8
 
120
        "sectsize",
112
121
#ifdef MKFS_SIMULATION
113
 
#define L_FILE          4
 
122
#define L_FILE          9
114
123
        "file",
115
 
#define L_NAME          5
 
124
#define L_NAME          10
116
125
        "name",
117
126
#endif
118
127
        NULL
144
153
        NULL
145
154
};
146
155
 
147
 
/*
148
 
 * max transaction reservation values
149
 
 * version 1:
150
 
 * first dimension log(blocksize) (base XFS_MIN_BLOCKSIZE_LOG)
151
 
 * second dimension log(inodesize) (base XFS_DINODE_MIN_LOG)
152
 
 * version 2:
153
 
 * first dimension log(blocksize) (base XFS_MIN_BLOCKSIZE_LOG)
154
 
 * second dimension log(inodesize) (base XFS_DINODE_MIN_LOG)
155
 
 * third dimension log(dirblocksize) (base XFS_MIN_BLOCKSIZE_LOG)
156
 
 */
157
 
#define DFL_B   (XFS_MAX_BLOCKSIZE_LOG + 1 - XFS_MIN_BLOCKSIZE_LOG)
158
 
#define DFL_I   (XFS_DINODE_MAX_LOG + 1 - XFS_DINODE_MIN_LOG)
159
 
#define DFL_D   (XFS_MAX_BLOCKSIZE_LOG + 1 - XFS_MIN_BLOCKSIZE_LOG)
160
 
 
161
 
static const int max_trres_v1[DFL_B][DFL_I] = {
162
 
        { MAXTRRES_B9_I8_D9_V1, 0, 0, 0 },
163
 
        { MAXTRRES_B10_I8_D10_V1, MAXTRRES_B10_I9_D10_V1, 0, 0 },
164
 
        { MAXTRRES_B11_I8_D11_V1, MAXTRRES_B11_I9_D11_V1,
165
 
          MAXTRRES_B11_I10_D11_V1, 0 },
166
 
        { MAXTRRES_B12_I8_D12_V1, MAXTRRES_B12_I9_D12_V1,
167
 
          MAXTRRES_B12_I10_D12_V1, MAXTRRES_B12_I11_D12_V1 },
168
 
        { MAXTRRES_B13_I8_D13_V1, MAXTRRES_B13_I9_D13_V1,
169
 
          MAXTRRES_B13_I10_D13_V1, MAXTRRES_B13_I11_D13_V1 },
170
 
        { MAXTRRES_B14_I8_D14_V1, MAXTRRES_B14_I9_D14_V1,
171
 
          MAXTRRES_B14_I10_D14_V1, MAXTRRES_B14_I11_D14_V1 },
172
 
        { MAXTRRES_B15_I8_D15_V1, MAXTRRES_B15_I9_D15_V1,
173
 
          MAXTRRES_B15_I10_D15_V1, MAXTRRES_B15_I11_D15_V1 },
174
 
        { MAXTRRES_B16_I8_D16_V1, MAXTRRES_B16_I9_D16_V1,
175
 
          MAXTRRES_B16_I10_D16_V1, MAXTRRES_B16_I11_D16_V1 },
176
 
};
177
 
 
178
 
static const int max_trres_v2[DFL_B][DFL_I][DFL_D] = {
179
 
        { { MAXTRRES_B9_I8_D9_V2, MAXTRRES_B9_I8_D10_V2, MAXTRRES_B9_I8_D11_V2,
180
 
            MAXTRRES_B9_I8_D12_V2, MAXTRRES_B9_I8_D13_V2, MAXTRRES_B9_I8_D14_V2,
181
 
            MAXTRRES_B9_I8_D15_V2, MAXTRRES_B9_I8_D16_V2 },
182
 
          { 0, 0, 0, 0, 0, 0, 0, 0 },
183
 
          { 0, 0, 0, 0, 0, 0, 0, 0 },
184
 
          { 0, 0, 0, 0, 0, 0, 0, 0 } },
185
 
        { { 0, MAXTRRES_B10_I8_D10_V2, MAXTRRES_B10_I8_D11_V2,
186
 
            MAXTRRES_B10_I8_D12_V2, MAXTRRES_B10_I8_D13_V2,
187
 
            MAXTRRES_B10_I8_D14_V2, MAXTRRES_B10_I8_D15_V2,
188
 
            MAXTRRES_B10_I8_D16_V2 },
189
 
          { 0, MAXTRRES_B10_I9_D10_V2, MAXTRRES_B10_I9_D11_V2,
190
 
            MAXTRRES_B10_I9_D12_V2, MAXTRRES_B10_I9_D13_V2,
191
 
            MAXTRRES_B10_I9_D14_V2, MAXTRRES_B10_I9_D15_V2,
192
 
            MAXTRRES_B10_I9_D16_V2 },
193
 
          { 0, 0, 0, 0, 0, 0, 0, 0 },
194
 
          { 0, 0, 0, 0, 0, 0, 0, 0 } },
195
 
        { { 0, 0, MAXTRRES_B11_I8_D11_V2, MAXTRRES_B11_I8_D12_V2,
196
 
            MAXTRRES_B11_I8_D13_V2, MAXTRRES_B11_I8_D14_V2,
197
 
            MAXTRRES_B11_I8_D15_V2, MAXTRRES_B11_I8_D16_V2 },
198
 
          { 0, 0, MAXTRRES_B11_I9_D11_V2, MAXTRRES_B11_I9_D12_V2,
199
 
            MAXTRRES_B11_I9_D13_V2, MAXTRRES_B11_I9_D14_V2,
200
 
            MAXTRRES_B11_I9_D15_V2, MAXTRRES_B11_I9_D16_V2 },
201
 
          { 0, 0, MAXTRRES_B11_I10_D11_V2, MAXTRRES_B11_I10_D12_V2,
202
 
            MAXTRRES_B11_I10_D13_V2, MAXTRRES_B11_I10_D14_V2,
203
 
            MAXTRRES_B11_I10_D15_V2, MAXTRRES_B11_I10_D16_V2 },
204
 
          { 0, 0, 0, 0, 0, 0, 0, 0 } },
205
 
        { { 0, 0, 0, MAXTRRES_B12_I8_D12_V2, MAXTRRES_B12_I8_D13_V2,
206
 
            MAXTRRES_B12_I8_D14_V2, MAXTRRES_B12_I8_D15_V2,
207
 
            MAXTRRES_B12_I8_D16_V2 },
208
 
          { 0, 0, 0, MAXTRRES_B12_I9_D12_V2, MAXTRRES_B12_I9_D13_V2,
209
 
            MAXTRRES_B12_I9_D14_V2, MAXTRRES_B12_I9_D15_V2,
210
 
            MAXTRRES_B12_I9_D16_V2 },
211
 
          { 0, 0, 0, MAXTRRES_B12_I10_D12_V2, MAXTRRES_B12_I10_D13_V2,
212
 
            MAXTRRES_B12_I10_D14_V2, MAXTRRES_B12_I10_D15_V2,
213
 
            MAXTRRES_B12_I10_D16_V2 },
214
 
          { 0, 0, 0, MAXTRRES_B12_I11_D12_V2, MAXTRRES_B12_I11_D13_V2,
215
 
            MAXTRRES_B12_I11_D14_V2, MAXTRRES_B12_I11_D15_V2,
216
 
            MAXTRRES_B12_I11_D16_V2 } },
217
 
        { { 0, 0, 0, 0, MAXTRRES_B13_I8_D13_V2, MAXTRRES_B13_I8_D14_V2,
218
 
            MAXTRRES_B13_I8_D15_V2, MAXTRRES_B13_I8_D16_V2 },
219
 
          { 0, 0, 0, 0, MAXTRRES_B13_I9_D13_V2, MAXTRRES_B13_I9_D14_V2,
220
 
            MAXTRRES_B13_I9_D15_V2, MAXTRRES_B13_I9_D16_V2 },
221
 
          { 0, 0, 0, 0, MAXTRRES_B13_I10_D13_V2, MAXTRRES_B13_I10_D14_V2,
222
 
            MAXTRRES_B13_I10_D15_V2, MAXTRRES_B13_I10_D16_V2 },
223
 
          { 0, 0, 0, 0, MAXTRRES_B13_I11_D13_V2, MAXTRRES_B13_I11_D14_V2,
224
 
            MAXTRRES_B13_I11_D15_V2, MAXTRRES_B13_I11_D16_V2 } },
225
 
        { { 0, 0, 0, 0, 0, MAXTRRES_B14_I8_D14_V2, MAXTRRES_B14_I8_D15_V2,
226
 
            MAXTRRES_B14_I8_D16_V2 },
227
 
          { 0, 0, 0, 0, 0, MAXTRRES_B14_I9_D14_V2, MAXTRRES_B14_I9_D15_V2,
228
 
            MAXTRRES_B14_I9_D16_V2 },
229
 
          { 0, 0, 0, 0, 0, MAXTRRES_B14_I10_D14_V2, MAXTRRES_B14_I10_D15_V2,
230
 
            MAXTRRES_B14_I10_D16_V2 },
231
 
          { 0, 0, 0, 0, 0, MAXTRRES_B14_I11_D14_V2, MAXTRRES_B14_I11_D15_V2,
232
 
            MAXTRRES_B14_I11_D16_V2 } },
233
 
        { { 0, 0, 0, 0, 0, 0, MAXTRRES_B15_I8_D15_V2, MAXTRRES_B15_I8_D16_V2 },
234
 
          { 0, 0, 0, 0, 0, 0, MAXTRRES_B15_I9_D15_V2, MAXTRRES_B15_I9_D16_V2 },
235
 
          { 0, 0, 0, 0, 0, 0, MAXTRRES_B15_I10_D15_V2,
236
 
            MAXTRRES_B15_I10_D16_V2 },
237
 
          { 0, 0, 0, 0, 0, 0, MAXTRRES_B15_I11_D15_V2,
238
 
            MAXTRRES_B15_I11_D16_V2 } },
239
 
        { { 0, 0, 0, 0, 0, 0, 0, MAXTRRES_B16_I8_D16_V2 },
240
 
          { 0, 0, 0, 0, 0, 0, 0, MAXTRRES_B16_I9_D16_V2 },
241
 
          { 0, 0, 0, 0, 0, 0, 0, MAXTRRES_B16_I10_D16_V2 },
242
 
          { 0, 0, 0, 0, 0, 0, 0, MAXTRRES_B16_I11_D16_V2, } },
243
 
};
244
 
 
245
 
/*
246
 
 * Use this before we have a superblock, else would use XFS_DTOBT
 
156
char    *sopts[] = {
 
157
#define S_LOG           0
 
158
        "log",
 
159
#define S_SECTLOG       1
 
160
        "sectlog",
 
161
#define S_SIZE          2
 
162
        "size",
 
163
#define S_SECTSIZE      3
 
164
        "sectsize",
 
165
        NULL
 
166
};
 
167
 
 
168
#define TERABYTES(count, blog)  ((__uint64_t)(count) << (40 - (blog)))
 
169
#define GIGABYTES(count, blog)  ((__uint64_t)(count) << (30 - (blog)))
 
170
#define MEGABYTES(count, blog)  ((__uint64_t)(count) << (20 - (blog)))
 
171
 
 
172
/*
 
173
 * Use this macro before we have superblock and mount structure
247
174
 */
248
175
#define DTOBT(d)        ((xfs_drfsbno_t)((d) >> (blocklog - BBSHIFT)))
249
176
 
257
184
        ((uint)(MKFS_BLOCKRES_INODE + XFS_DA_NODE_MAXDEPTH + \
258
185
        (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1) + (rb)))
259
186
 
 
187
/* amount (in bytes) we zero at the beginning and end of the device to
 
188
 * remove traces of other filesystems, raid superblocks, etc.
 
189
 */
 
190
#define WHACK_SIZE (128 * 1024)
 
191
 
260
192
static void
261
 
calc_stripe_factors(int dsu, int dsw, int *dsunit, int *dswidth)
 
193
calc_stripe_factors(
 
194
        int             dsu,
 
195
        int             dsw,
 
196
        int             dsectsz,
 
197
        int             lsu,
 
198
        int             lsectsz,
 
199
        int             *dsunit,
 
200
        int             *dswidth,
 
201
        int             *lsunit)
262
202
{
 
203
        /* Handle data sunit/swidth options */
263
204
        if (*dsunit || *dswidth) {
264
205
                if (dsu || dsw) {
265
206
                        fprintf(stderr,
266
 
        "su/sw should not be used in conjunction with sunit/swidth\n");
 
207
                                _("data su/sw must not be used in "
 
208
                                "conjunction with data sunit/swidth\n"));
267
209
                        usage();
268
210
                }
269
211
 
270
212
                if ((*dsunit && !*dswidth) || (!*dsunit && *dswidth)) {
271
213
                        fprintf(stderr,
272
 
        "both sunit and swidth options have to be specified\n");
 
214
                                _("both data sunit and data swidth options "
 
215
                                "must be specified\n"));
273
216
                        usage();
274
217
                }
275
218
        }
277
220
        if (dsu || dsw) {
278
221
                if (*dsunit || *dswidth) {
279
222
                        fprintf(stderr,
280
 
        "sunit/swidth should not be used in conjunction with su/sw\n");
 
223
                                _("data sunit/swidth must not be used in "
 
224
                                "conjunction with data su/sw\n"));
281
225
                        usage();
282
226
                }
283
227
 
284
228
                if ((dsu && !dsw) || (!dsu && dsw)) {
285
229
                        fprintf(stderr,
286
 
        "both su and sw options have to be specified\n");
 
230
                                _("both data su and data sw options "
 
231
                                "must be specified\n"));
287
232
                        usage();
288
233
                }
289
234
 
290
 
                if (dsu % BBSIZE) {
291
 
                        fprintf(stderr, "su must be a multiple of %d\n",
292
 
                                                                BBSIZE);
 
235
                if (dsu % dsectsz) {
 
236
                        fprintf(stderr,
 
237
                                _("data su must be a multiple of the "
 
238
                                "sector size (%d)\n"), dsectsz);
293
239
                        usage();
294
240
                }
295
241
 
299
245
 
300
246
        if (*dsunit && (*dswidth % *dsunit != 0)) {
301
247
                fprintf(stderr,
302
 
        "stripe width (%d) has to be a multiple of the stripe unit (%d)\n",
303
 
                        *dswidth, *dsunit);
 
248
                        _("data stripe width (%d) must be a multiple of the "
 
249
                        "data stripe unit (%d)\n"), *dswidth, *dsunit);
304
250
                usage();
305
251
        }
306
 
}
307
 
 
308
 
static int
309
 
get_default_blocksize(void)
310
 
{
311
 
        size_t  pagesize = getpagesize();
312
 
        int     i;
313
 
 
314
 
        /* default is between 4K and 16K */
315
 
        for (i = 12; i <= 16; i++)
316
 
                if ((1 << i) == pagesize)
317
 
                        return pagesize;
318
 
        return (1 << XFS_DFL_BLOCKSIZE_LOG);
319
 
}
320
 
 
321
 
static int
322
 
check_overwrite(char *device)
323
 
{
324
 
        char *type;
 
252
 
 
253
        /* Handle log sunit options */
 
254
 
 
255
        if (*lsunit) {
 
256
                if (lsu) {
 
257
                        fprintf(stderr,
 
258
                                _("log su should not be used in "
 
259
                                "conjunction with log sunit\n"));
 
260
                        usage();
 
261
                }
 
262
        }
 
263
 
 
264
        if (lsu) {
 
265
                if (*lsunit) {
 
266
                        fprintf(stderr,
 
267
                                _("log sunit should not be used in "
 
268
                                "conjunction with log su\n"));
 
269
                        usage();
 
270
                }
 
271
                *lsunit = (int)BTOBBT(lsu);
 
272
        }
 
273
}
 
274
 
 
275
static int
 
276
check_overwrite(
 
277
        char            *device)
 
278
{
 
279
        char            *type;
325
280
 
326
281
        if (device && *device) {
327
282
                if ((type = fstype(device)) != NULL) {
328
283
                        fprintf(stderr,
329
 
                "%s: %s appears to contain an existing filesystem (%s).\n",
330
 
                                progname, device, type);
 
284
                                _("%s: %s appears to contain an existing "
 
285
                                "filesystem (%s).\n"), progname, device, type);
331
286
                        return 1;
332
287
                }
333
288
                if ((type = pttype(device)) != NULL) {
334
289
                        fprintf(stderr,
335
 
                "%s: %s appears to contain a partition table (%s).\n",
336
 
                                progname, device, type);
 
290
                                _("%s: %s appears to contain a partition "
 
291
                                "table (%s).\n"), progname, device, type);
337
292
                        return 1;
338
293
                }
339
294
        }
340
295
        return 0;
341
296
}
342
297
 
 
298
static xfs_dfsbno_t
 
299
fixup_log_stripe(
 
300
        xfs_mount_t     *mp,
 
301
        int             lsflag,
 
302
        xfs_dfsbno_t    logstart,
 
303
        __uint64_t      agsize,
 
304
        int             sunit,
 
305
        xfs_drfsbno_t   *logblocks,
 
306
        int             blocklog,
 
307
        int             *lalign)
 
308
{
 
309
        __uint64_t      tmp_logblocks;
 
310
 
 
311
        if ((logstart % sunit) != 0) {
 
312
                logstart = ((logstart + (sunit - 1))/sunit) * sunit;
 
313
                *lalign = 1;
 
314
        }
 
315
 
 
316
        /* 
 
317
         * Make sure that the log size is a multiple of the
 
318
         * stripe unit
 
319
         */
 
320
        if ((*logblocks % sunit) != 0) {
 
321
                if (!lsflag) {
 
322
                        tmp_logblocks = ((*logblocks + (sunit - 1))
 
323
                                                / sunit) * sunit;
 
324
                        /*
 
325
                         * If the log is too large, round down
 
326
                         * instead of round up
 
327
                         */
 
328
                        if ((tmp_logblocks > XFS_MAX_LOG_BLOCKS) ||
 
329
                            ((tmp_logblocks << blocklog) > XFS_MAX_LOG_BYTES)) {
 
330
                                tmp_logblocks = (*logblocks / sunit) * sunit;
 
331
                        }
 
332
                        *logblocks = tmp_logblocks;
 
333
                } else {
 
334
                        fprintf(stderr,
 
335
                                _("internal log size %lld is not a multiple "
 
336
                                "of the log stripe unit %d\n"),
 
337
                                (long long) *logblocks, sunit);
 
338
                        usage();
 
339
                }
 
340
        }
 
341
 
 
342
        if (*logblocks > agsize - XFS_FSB_TO_AGBNO(mp, logstart)) {
 
343
                fprintf(stderr,
 
344
                        _("Due to stripe alignment, the internal log size "
 
345
                        "(%lld) is too large.\n"), (long long) *logblocks);
 
346
                fprintf(stderr, _("Must fit within an allocation group.\n"));
 
347
                usage();
 
348
        }
 
349
        return logstart;
 
350
}
 
351
 
 
352
void
 
353
validate_log_size(__uint64_t logblocks, int blocklog, int min_logblocks)
 
354
{
 
355
        if (logblocks < min_logblocks) {
 
356
                fprintf(stderr,
 
357
        _("log size %lld blocks too small, minimum size is %d blocks\n"),
 
358
                        (long long)logblocks, min_logblocks);
 
359
                usage();
 
360
        }
 
361
        if (logblocks > XFS_MAX_LOG_BLOCKS) {
 
362
                fprintf(stderr,
 
363
        _("log size %lld blocks too large, maximum size is %d blocks\n"),
 
364
                        (long long)logblocks, XFS_MAX_LOG_BLOCKS);
 
365
                usage();
 
366
        }
 
367
        if ((logblocks << blocklog) > XFS_MAX_LOG_BYTES) {
 
368
                fprintf(stderr,
 
369
        _("log size %lld bytes too large, maximum size is %d bytes\n"),
 
370
                        (long long)(logblocks << blocklog), XFS_MAX_LOG_BYTES);
 
371
                usage();
 
372
        }
 
373
}
 
374
 
 
375
void
 
376
calc_default_ag_geometry(
 
377
        int             blocklog,
 
378
        __uint64_t      dblocks,
 
379
        __uint64_t      *agsize,
 
380
        __uint64_t      *agcount)
 
381
{
 
382
        __uint64_t      blocks;
 
383
        __uint64_t      count = 0;
 
384
        int             shift = 0;
 
385
 
 
386
        /*
 
387
         * First handle the extremes - the points at which we will
 
388
         * always use the maximum AG size, the points at which we
 
389
         * always use the minimum, and a "small-step" for 16-128Mb.
 
390
         */
 
391
        if (dblocks >= TERABYTES(64, blocklog)) {
 
392
                blocks = XFS_AG_MAX_BLOCKS(blocklog);
 
393
                goto done;
 
394
        } else if (dblocks < MEGABYTES(16, blocklog)) {
 
395
                blocks = dblocks;
 
396
                count = 1;
 
397
                goto done;
 
398
        } else if (dblocks < MEGABYTES(128, blocklog)) {
 
399
                blocks = MEGABYTES(16, blocklog);
 
400
                goto done;
 
401
        }
 
402
 
 
403
        /*
 
404
         * For the remainder we choose an AG size based on the
 
405
         * number of data blocks available, trying to keep the
 
406
         * number of AGs relatively small (especially compared
 
407
         * to the original algorithm).  AG count is calculated
 
408
         * based on the prefered AG size, not vice-versa - the
 
409
         * count can be increased by growfs, so prefer to use
 
410
         * smaller counts at mkfs time.
 
411
         * 
 
412
         * This scales us up smoothly between min/max AG sizes.
 
413
         */
 
414
        if (dblocks > GIGABYTES(512, blocklog))
 
415
                shift = 5;
 
416
        else if (dblocks > GIGABYTES(8, blocklog))
 
417
                shift = 4;
 
418
        else if (dblocks >= MEGABYTES(128, blocklog))
 
419
                shift = 3;
 
420
        else
 
421
                ASSERT(0);
 
422
        blocks = dblocks >> shift;
 
423
 
 
424
done:
 
425
        if (!count)
 
426
                count = dblocks / blocks + (dblocks % blocks != 0);
 
427
        *agsize = blocks;
 
428
        *agcount = count;
 
429
}
 
430
 
 
431
static void
 
432
validate_ag_geometry(
 
433
        int             blocklog,
 
434
        __uint64_t      dblocks,
 
435
        __uint64_t      agsize,
 
436
        __uint64_t      agcount)
 
437
{
 
438
        if (agsize < XFS_AG_MIN_BLOCKS(blocklog)) {
 
439
                fprintf(stderr,
 
440
        _("agsize (%lldb) too small, need at least %lld blocks\n"),
 
441
                        (long long)agsize,
 
442
                        (long long)XFS_AG_MIN_BLOCKS(blocklog));
 
443
                usage();
 
444
        }
 
445
 
 
446
        if (agsize > XFS_AG_MAX_BLOCKS(blocklog)) {
 
447
                fprintf(stderr,
 
448
        _("agsize (%lldb) too big, maximum is %lld blocks\n"),
 
449
                        (long long)agsize,
 
450
                        (long long)XFS_AG_MAX_BLOCKS(blocklog));
 
451
                usage();
 
452
        }
 
453
 
 
454
        if (agsize > dblocks) {
 
455
                fprintf(stderr,
 
456
        _("agsize (%lldb) too big, data area is %lld blocks\n"),
 
457
                        (long long)agsize, (long long)dblocks);
 
458
                        usage();
 
459
        }
 
460
 
 
461
        if (agsize < XFS_AG_MIN_BLOCKS(blocklog)) {
 
462
                fprintf(stderr,
 
463
        _("too many allocation groups for size = %lld\n"),
 
464
                                (long long)agsize);
 
465
                fprintf(stderr, _("need at most %lld allocation groups\n"),
 
466
                        (long long)(dblocks / XFS_AG_MIN_BLOCKS(blocklog) +
 
467
                                (dblocks % XFS_AG_MIN_BLOCKS(blocklog) != 0)));
 
468
                usage();
 
469
        }
 
470
 
 
471
        if (agsize > XFS_AG_MAX_BLOCKS(blocklog)) {
 
472
                fprintf(stderr,
 
473
        _("too few allocation groups for size = %lld\n"), (long long)agsize);
 
474
                fprintf(stderr,
 
475
        _("need at least %lld allocation groups\n"),
 
476
                (long long)(dblocks / XFS_AG_MAX_BLOCKS(blocklog) + 
 
477
                        (dblocks % XFS_AG_MAX_BLOCKS(blocklog) != 0)));
 
478
                usage();
 
479
        }
 
480
 
 
481
        /*
 
482
         * If the last AG is too small, reduce the filesystem size
 
483
         * and drop the blocks.
 
484
         */
 
485
        if ( dblocks % agsize != 0 &&
 
486
             (dblocks % agsize < XFS_AG_MIN_BLOCKS(blocklog))) {
 
487
                fprintf(stderr,
 
488
        _("last AG size %lld blocks too small, minimum size is %lld blocks\n"),
 
489
                        (long long)(dblocks % agsize),
 
490
                        (long long)XFS_AG_MIN_BLOCKS(blocklog));
 
491
                usage();
 
492
        }
 
493
 
 
494
        /*
 
495
         * If agcount is too large, make it smaller.
 
496
         */
 
497
        if (agcount > XFS_MAX_AGNUMBER + 1) {
 
498
                fprintf(stderr,
 
499
        _("%lld allocation groups is too many, maximum is %lld\n"),
 
500
                        (long long)agcount, (long long)XFS_MAX_AGNUMBER + 1);
 
501
                usage();
 
502
        }
 
503
}
343
504
 
344
505
int
345
 
main(int argc, char **argv)
 
506
main(
 
507
        int                     argc,
 
508
        char                    **argv)
346
509
{
347
510
        __uint64_t              agcount;
348
511
        xfs_agf_t               *agf;
365
528
        int                     dirblocklog;
366
529
        int                     dirblocksize;
367
530
        int                     dirversion;
368
 
        int                     do_overlap_checks;
369
531
        char                    *dsize;
370
532
        int                     dsu;
371
533
        int                     dsw;
373
535
        int                     dswidth;
374
536
        int                     extent_flagging;
375
537
        int                     force_overwrite;
376
 
        int                     i;
377
538
        int                     iaflag;
378
539
        int                     ilflag;
379
540
        int                     imaxpct;
394
555
        int                     loginternal;
395
556
        char                    *logsize;
396
557
        xfs_dfsbno_t            logstart;
 
558
        int                     logversion;
 
559
        int                     lvflag;
397
560
        int                     lsflag;
 
561
        int                     lsectorlog;
 
562
        int                     lsectorsize;
 
563
        int                     lslflag;
 
564
        int                     lssflag;
 
565
        int                     lsu;
 
566
        int                     lsunit;
 
567
        int                     max_tr_res;
398
568
        int                     min_logblocks;
399
 
        mnt_check_state_t       *mnt_check_state;
400
 
        int                     mnt_partition_count;
401
569
        xfs_mount_t             *mp;
402
570
        xfs_mount_t             mbuf;
403
571
        xfs_extlen_t            nbmblocks;
406
574
        xfs_alloc_rec_t         *nrec;
407
575
        int                     nsflag;
408
576
        int                     nvflag;
 
577
        int                     Nflag;
409
578
        char                    *p;
410
579
        char                    *protofile;
411
580
        char                    *protostring;
417
586
        char                    *rtfile;
418
587
        char                    *rtsize;
419
588
        xfs_sb_t                *sbp;
420
 
        int                     sectlog;
 
589
        int                     sectorlog;
 
590
        int                     sectorsize;
 
591
        int                     slflag;
 
592
        int                     ssflag;
421
593
        __uint64_t              tmp_agsize;
422
 
        __uint64_t              tmp_logblocks;
423
594
        uuid_t                  uuid;
424
595
        int                     worst_freelist;
425
596
        libxfs_init_t           xi;
427
598
        int                     xlv_dswidth;
428
599
 
429
600
        progname = basename(argv[0]);
430
 
        agcount = 8;
431
 
        blflag = bsflag = 0;
432
 
        dasize = daflag = 0;
433
 
        blocksize = get_default_blocksize();
434
 
        blocklog = libxfs_highbit32(blocksize);
435
 
        agsize = daflag = dblocks = 0;
 
601
        setlocale(LC_ALL, "");
 
602
        bindtextdomain(PACKAGE, LOCALEDIR);
 
603
        textdomain(PACKAGE);
 
604
 
 
605
        blflag = bsflag = slflag = ssflag = lslflag = lssflag = 0;
 
606
        blocklog = blocksize = 0;
 
607
        sectorlog = lsectorlog = XFS_MIN_SECTORSIZE_LOG;
 
608
        sectorsize = lsectorsize = XFS_MIN_SECTORSIZE;
 
609
        agsize = daflag = dasize = dblocks = 0;
436
610
        ilflag = imflag = ipflag = isflag = 0;
437
 
        liflag = laflag = lsflag = ldflag = 0;
 
611
        liflag = laflag = lsflag = ldflag = lvflag = 0;
438
612
        loginternal = 1;
 
613
        logversion = 1;
439
614
        logagno = logblocks = rtblocks = 0;
440
 
        nlflag = nsflag = nvflag = 0;
 
615
        Nflag = nlflag = nsflag = nvflag = 0;
441
616
        dirblocklog = dirblocksize = dirversion = 0;
442
617
        qflag = 0;
443
618
        imaxpct = inodelog = inopblock = isize = 0;
444
619
        iaflag = XFS_IFLAG_ALIGN;
445
 
        bzero(&xi, sizeof(xi));
446
 
        xi.notvolok = 1;
447
 
        xi.setblksize = 1;
448
620
        dfile = logfile = rtfile = NULL;
449
621
        dsize = logsize = rtsize = rtextsize = protofile = NULL;
450
 
        opterr = 0;
451
 
        dsu = dsw = dsunit = dswidth = nodsflag = lalign = 0;
452
 
        do_overlap_checks = 1;
453
 
        extent_flagging = 0;
 
622
        dsu = dsw = dsunit = dswidth = nodsflag = lalign = lsu = lsunit = 0;
 
623
        extent_flagging = 1;
454
624
        force_overwrite = 0;
455
625
        worst_freelist = 0;
456
626
 
457
 
        while ((c = getopt(argc, argv, "b:d:i:l:L:n:p:qr:CfV")) != EOF) {
 
627
        bzero(&xi, sizeof(xi));
 
628
        xi.notvolok = 1;
 
629
        xi.setblksize = 1;
 
630
        xi.isreadonly = LIBXFS_EXCLUSIVELY;
 
631
 
 
632
        while ((c = getopt(argc, argv, "b:d:i:l:L:n:Np:qr:s:CfV")) != EOF) {
458
633
                switch (c) {
459
634
                case 'C':
460
 
                        do_overlap_checks = 0;
461
 
                        break;
462
635
                case 'f':
463
636
                        force_overwrite = 1;
464
637
                        break;
490
663
                                        if (blflag)
491
664
                                                conflict('b', bopts, B_LOG,
492
665
                                                         B_SIZE);
493
 
                                        blocksize = cvtnum(0, value);
 
666
                                        blocksize = cvtnum(
 
667
                                                blocksize, sectorsize, value);
494
668
                                        if (blocksize <= 0 ||
495
669
                                            !ispow2(blocksize))
496
670
                                                illegal(value, "b size");
513
687
                                                reqval('d', dopts, D_AGCOUNT);
514
688
                                        if (daflag)
515
689
                                                respec('d', dopts, D_AGCOUNT);
516
 
                                        agcount = (__uint64_t)atoll(value);
 
690
                                        agcount = (__uint64_t)
 
691
                                                strtoul(value, NULL, 10);
517
692
                                        if ((__int64_t)agcount <= 0)
518
693
                                                illegal(value, "d agcount");
519
694
                                        daflag = 1;
523
698
                                                reqval('d', dopts, D_AGSIZE);
524
699
                                        if (dasize)
525
700
                                                respec('d', dopts, D_AGSIZE);
526
 
                                        if (blflag || bsflag)
527
 
                                                agsize = cvtnum(blocksize,
528
 
                                                                value);
529
 
                                        else
530
 
                                                agsize = cvtnum(0, value);
 
701
                                        agsize = cvtnum(
 
702
                                                blocksize, sectorsize, value);
531
703
                                        dasize = 1;
532
704
                                        break;
533
705
                                case D_FILE:
558
730
                                                reqval('d', dopts, D_SUNIT);
559
731
                                        if (dsunit)
560
732
                                                respec('d', dopts, D_SUNIT);
561
 
                                        if (blflag || bsflag)
562
 
                                                dsunit = cvtnum(blocksize,
563
 
                                                                value);
564
 
                                        else
565
 
                                                dsunit = cvtnum(0, value);
 
733
                                        if (!isdigits(value)) {
 
734
                                                fprintf(stderr,
 
735
        _("%s: Specify data sunit in 512-byte blocks, no unit suffix\n"),
 
736
                                                        progname);
 
737
                                                exit(1);
 
738
                                        }
 
739
                                        dsunit = cvtnum(0, 0, value);
566
740
                                        break;
567
741
                                case D_SWIDTH:
568
742
                                        if (!value)
569
743
                                                reqval('d', dopts, D_SWIDTH);
570
744
                                        if (dswidth)
571
745
                                                respec('d', dopts, D_SWIDTH);
572
 
                                        if (blflag || bsflag)
573
 
                                                dswidth = cvtnum(blocksize,
574
 
                                                                 value);
575
 
                                        else
576
 
                                                dswidth = cvtnum(0, value);
 
746
                                        if (!isdigits(value)) {
 
747
                                                fprintf(stderr,
 
748
        _("%s: Specify data swidth in 512-byte blocks, no unit suffix\n"),
 
749
                                                        progname);
 
750
                                                exit(1);
 
751
                                        }
 
752
                                        dswidth = cvtnum(0, 0, value);
577
753
                                        break;
578
754
                                case D_SU:
579
755
                                        if (!value)
580
756
                                                reqval('d', dopts, D_SU);
581
757
                                        if (dsu)
582
758
                                                respec('d', dopts, D_SU);
583
 
                                        dsu = cvtnum(0, value);
 
759
                                        dsu = cvtnum(
 
760
                                                blocksize, sectorsize, value);
584
761
                                        break;
585
762
                                case D_SW:
586
763
                                        if (!value)
587
764
                                                reqval('d', dopts, D_SW);
588
765
                                        if (dsw)
589
766
                                                respec('d', dopts, D_SW);
590
 
                                        dsw = cvtnum(0, value);
 
767
                                        if (!isdigits(value)) {
 
768
                                                fprintf(stderr,
 
769
                _("%s: Specify data sw as multiple of su, no unit suffix\n"),
 
770
                                                        progname);
 
771
                                                exit(1);
 
772
                                        }
 
773
                                        dsw = cvtnum(0, 0, value);
591
774
                                        break;
592
775
                                case D_UNWRITTEN:
593
776
                                        if (!value)
594
 
                                            reqval('d', dopts, D_UNWRITTEN);
595
 
                                        i = atoi(value);
596
 
                                        if (i < 0 || i > 1)
597
 
                                            illegal(value, "d unwritten");
598
 
                                        extent_flagging = i;
 
777
                                                reqval('d', dopts, D_UNWRITTEN);
 
778
                                        c = atoi(value);
 
779
                                        if (c < 0 || c > 1)
 
780
                                                illegal(value, "d unwritten");
 
781
                                        extent_flagging = c;
 
782
                                        break;
 
783
                                case D_SECTLOG:
 
784
                                        if (!value)
 
785
                                                reqval('d', dopts, D_SECTLOG);
 
786
                                        if (slflag)
 
787
                                                respec('d', dopts, D_SECTLOG);
 
788
                                        if (ssflag)
 
789
                                                conflict('d', dopts, D_SECTSIZE,
 
790
                                                         D_SECTLOG);
 
791
                                        sectorlog = atoi(value);
 
792
                                        if (sectorlog <= 0)
 
793
                                                illegal(value, "d sectlog");
 
794
                                        sectorsize = 1 << sectorlog;
 
795
                                        slflag = 1;
 
796
                                        break;
 
797
                                case D_SECTSIZE:
 
798
                                        if (!value)
 
799
                                                reqval('d', dopts, D_SECTSIZE);
 
800
                                        if (ssflag)
 
801
                                                respec('d', dopts, D_SECTSIZE);
 
802
                                        if (slflag)
 
803
                                                conflict('d', dopts, D_SECTLOG,
 
804
                                                         D_SECTSIZE);
 
805
                                        sectorsize = cvtnum(
 
806
                                                blocksize, sectorsize, value);
 
807
                                        if (sectorsize <= 0 ||
 
808
                                            !ispow2(sectorsize))
 
809
                                                illegal(value, "d sectsize");
 
810
                                        sectorlog =
 
811
                                                libxfs_highbit32(sectorsize);
 
812
                                        ssflag = 1;
599
813
                                        break;
600
814
                                default:
601
815
                                        unknown('d', value);
671
885
                                                         I_SIZE);
672
886
                                        if (isflag)
673
887
                                                respec('i', iopts, I_SIZE);
674
 
                                        isize = cvtnum(0, value);
 
888
                                        isize = cvtnum(0, 0, value);
675
889
                                        if (isize <= 0 || !ispow2(isize))
676
890
                                                illegal(value, "i size");
677
891
                                        inodelog = libxfs_highbit32(isize);
700
914
                                        break;
701
915
                                case L_DEV:
702
916
                                        if (!value) {
703
 
                                                fprintf (stderr, "Must specify log device\n");
 
917
                                                fprintf(stderr,
 
918
                                        _("Must specify log device\n"));
704
919
                                                usage();
705
920
                                        }
706
921
 
750
965
                                                illegal(value, "l internal");
751
966
                                        liflag = 1;
752
967
                                        break;
 
968
                                case L_SU:
 
969
                                        if (!value)
 
970
                                                reqval('l', lopts, L_SU);
 
971
                                        if (lsu)
 
972
                                                respec('l', lopts, L_SU);
 
973
                                        lsu = cvtnum(
 
974
                                                blocksize, sectorsize, value);
 
975
                                        break;
 
976
                                case L_SUNIT:
 
977
                                        if (!value)
 
978
                                                reqval('l', lopts, L_SUNIT);
 
979
                                        if (lsunit)
 
980
                                                respec('l', lopts, L_SUNIT);
 
981
                                        if (!isdigits(value)) {
 
982
                                                fprintf(stderr,
 
983
                _("Specify log sunit in 512-byte blocks, no size suffix\n"));
 
984
                                                usage();
 
985
                                        }
 
986
                                        lsunit = cvtnum(0, 0, value);
 
987
                                        break;
753
988
#ifdef HAVE_VOLUME_MANAGER
754
989
                                case L_NAME:
755
990
                                        if (!value)
762
997
                                        xi.logname = value;
763
998
                                        break;
764
999
#endif
 
1000
                                case L_VERSION:
 
1001
                                        if (!value)
 
1002
                                                reqval('l', lopts, L_VERSION);
 
1003
                                        if (lvflag)
 
1004
                                                respec('l', lopts, L_VERSION);
 
1005
                                        logversion = atoi(value);
 
1006
                                        if (logversion < 1 || logversion > 2)
 
1007
                                                illegal(value, "l version");
 
1008
                                        lvflag = 1;
 
1009
                                        break;
765
1010
                                case L_SIZE:
766
1011
                                        if (!value)
767
1012
                                                reqval('l', lopts, L_SIZE);
770
1015
                                        logsize = value;
771
1016
                                        lsflag = 1;
772
1017
                                        break;
 
1018
                                case L_SECTLOG:
 
1019
                                        if (!value)
 
1020
                                                reqval('l', lopts, L_SECTLOG);
 
1021
                                        if (lslflag)
 
1022
                                                respec('l', lopts, L_SECTLOG);
 
1023
                                        if (lssflag)
 
1024
                                                conflict('l', lopts, L_SECTSIZE,
 
1025
                                                         L_SECTLOG);
 
1026
                                        lsectorlog = atoi(value);
 
1027
                                        if (lsectorlog <= 0)
 
1028
                                                illegal(value, "l sectlog");
 
1029
                                        lsectorsize = 1 << lsectorlog;
 
1030
                                        lslflag = 1;
 
1031
                                        break;
 
1032
                                case L_SECTSIZE:
 
1033
                                        if (!value)
 
1034
                                                reqval('l', lopts, L_SECTSIZE);
 
1035
                                        if (lssflag)
 
1036
                                                respec('l', lopts, L_SECTSIZE);
 
1037
                                        if (lslflag)
 
1038
                                                conflict('l', lopts, L_SECTLOG,
 
1039
                                                         L_SECTSIZE);
 
1040
                                        lsectorsize = cvtnum(
 
1041
                                                blocksize, sectorsize, value);
 
1042
                                        if (lsectorsize <= 0 ||
 
1043
                                            !ispow2(lsectorsize))
 
1044
                                                illegal(value, "l sectsize");
 
1045
                                        lsectorlog =
 
1046
                                                libxfs_highbit32(lsectorsize);
 
1047
                                        lssflag = 1;
 
1048
                                        break;
773
1049
                                default:
774
1050
                                        unknown('l', value);
775
1051
                                }
808
1084
                                        if (nlflag)
809
1085
                                                conflict('n', nopts, N_LOG,
810
1086
                                                         N_SIZE);
811
 
                                        dirblocksize = cvtnum(0, value);
 
1087
                                        dirblocksize = cvtnum(
 
1088
                                                blocksize, sectorsize, value);
812
1089
                                        if (dirblocksize <= 0 ||
813
1090
                                            !ispow2(dirblocksize))
814
1091
                                                illegal(value, "n size");
831
1108
                                }
832
1109
                        }
833
1110
                        break;
 
1111
                case 'N':
 
1112
                        Nflag = 1;
 
1113
                        break;
834
1114
                case 'p':
835
1115
                        if (protofile)
836
1116
                                respec('p', 0, 0);
888
1168
                                }
889
1169
                        }
890
1170
                        break;
 
1171
                case 's':
 
1172
                        p = optarg;
 
1173
                        while (*p != '\0') {
 
1174
                                char    *value;
 
1175
 
 
1176
                                switch (getsubopt(&p, (constpp)sopts, &value)) {
 
1177
                                case S_LOG:
 
1178
                                case S_SECTLOG:
 
1179
                                        if (!value)
 
1180
                                                reqval('s', sopts, S_SECTLOG);
 
1181
                                        if (slflag || lslflag)
 
1182
                                                respec('s', sopts, S_SECTLOG);
 
1183
                                        if (ssflag || lssflag)
 
1184
                                                conflict('s', sopts, S_SECTSIZE,
 
1185
                                                         S_SECTLOG);
 
1186
                                        sectorlog = atoi(value);
 
1187
                                        if (sectorlog <= 0)
 
1188
                                                illegal(value, "s sectlog");
 
1189
                                        lsectorlog = sectorlog;
 
1190
                                        sectorsize = 1 << sectorlog;
 
1191
                                        lsectorsize = sectorsize;
 
1192
                                        lslflag = slflag = 1;
 
1193
                                        break;
 
1194
                                case S_SIZE:
 
1195
                                case S_SECTSIZE:
 
1196
                                        if (!value)
 
1197
                                                reqval('s', sopts, S_SECTSIZE);
 
1198
                                        if (ssflag || lssflag)
 
1199
                                                respec('s', sopts, S_SECTSIZE);
 
1200
                                        if (slflag || lslflag)
 
1201
                                                conflict('s', sopts, S_SECTLOG,
 
1202
                                                         S_SECTSIZE);
 
1203
                                        sectorsize = cvtnum(
 
1204
                                                blocksize, sectorsize, value);
 
1205
                                        if (sectorsize <= 0 ||
 
1206
                                            !ispow2(sectorsize))
 
1207
                                                illegal(value, "s sectsize");
 
1208
                                        lsectorsize = sectorsize;
 
1209
                                        sectorlog =
 
1210
                                                libxfs_highbit32(sectorsize);
 
1211
                                        lsectorlog = sectorlog;
 
1212
                                        lssflag = ssflag = 1;
 
1213
                                        break;
 
1214
                                default:
 
1215
                                        unknown('s', value);
 
1216
                                }
 
1217
                        }
 
1218
                        break;
891
1219
                case 'V':
892
 
                        printf("%s version %s\n", progname, VERSION);
 
1220
                        printf(_("%s version %s\n"), progname, VERSION);
893
1221
                        exit(0);
894
1222
                case '?':
895
1223
                        unknown(optopt, "");
896
1224
                }
897
1225
        }
898
1226
        if (argc - optind > 1) {
899
 
                fprintf(stderr, "extra arguments\n");
 
1227
                fprintf(stderr, _("extra arguments\n"));
900
1228
                usage();
901
1229
        } else if (argc - optind == 1) {
902
1230
                dfile = xi.volname = argv[optind];
903
1231
                if (xi.dname) {
904
1232
                        fprintf(stderr,
905
 
                                "cannot specify both %s and -d name=%s\n",
 
1233
                                _("cannot specify both %s and -d name=%s\n"),
906
1234
                                xi.volname, xi.dname);
907
1235
                        usage();
908
1236
                }
909
1237
        } else
910
1238
                dfile = xi.dname;
911
 
        /* option post-processing */
 
1239
 
 
1240
        /*
 
1241
         * Blocksize and sectorsize first, other things depend on them
 
1242
         */
 
1243
        if (!blflag && !bsflag) {
 
1244
                blocklog = XFS_DFL_BLOCKSIZE_LOG;
 
1245
                blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG;
 
1246
        }
912
1247
        if (blocksize < XFS_MIN_BLOCKSIZE || blocksize > XFS_MAX_BLOCKSIZE) {
913
 
                fprintf(stderr, "illegal block size %d\n", blocksize);
914
 
                usage();
915
 
        }
 
1248
                fprintf(stderr, _("illegal block size %d\n"), blocksize);
 
1249
                usage();
 
1250
        }
 
1251
        if (sectorsize < XFS_MIN_SECTORSIZE ||
 
1252
            sectorsize > XFS_MAX_SECTORSIZE || sectorsize > blocksize) {
 
1253
                fprintf(stderr, _("illegal sector size %d\n"), sectorsize);
 
1254
                usage();
 
1255
        }
 
1256
        if (lsectorsize < XFS_MIN_SECTORSIZE ||
 
1257
            lsectorsize > XFS_MAX_SECTORSIZE || lsectorsize > blocksize) {
 
1258
                fprintf(stderr, _("illegal log sector size %d\n"), lsectorsize);
 
1259
                usage();
 
1260
        } else if (lsectorsize > XFS_MIN_SECTORSIZE && !lsu && !lsunit) {
 
1261
                lsu = blocksize;
 
1262
                logversion = 2;
 
1263
        }
 
1264
 
916
1265
        if (!nvflag)
917
1266
                dirversion = (nsflag || nlflag) ? 2 : XFS_DFL_DIR_VERSION;
918
1267
        switch (dirversion) {
919
1268
        case 1:
920
1269
                if ((nsflag || nlflag) && dirblocklog != blocklog) {
921
 
                        fprintf(stderr, "illegal directory block size %d\n",
 
1270
                        fprintf(stderr, _("illegal directory block size %d\n"),
922
1271
                                dirblocksize);
923
1272
                        usage();
924
1273
                }
928
1277
                        if (dirblocksize < blocksize ||
929
1278
                            dirblocksize > XFS_MAX_BLOCKSIZE) {
930
1279
                                fprintf(stderr,
931
 
                                        "illegal directory block size %d\n",
 
1280
                                        _("illegal directory block size %d\n"),
932
1281
                                        dirblocksize);
933
1282
                                usage();
934
1283
                        }
944
1293
 
945
1294
        if (daflag && dasize) {
946
1295
                fprintf(stderr,
947
 
        "both -d agcount= and agsize= specified, use one or the other\n");
 
1296
        _("both -d agcount= and agsize= specified, use one or the other\n"));
948
1297
                usage();
949
1298
        }
950
1299
 
951
 
        if (!daflag)
952
 
                agcount = 8;
953
 
 
954
1300
        if (xi.disfile && (!dsize || !xi.dname)) {
955
1301
                fprintf(stderr,
956
 
                        "if -d file then -d name and -d size are required\n");
 
1302
        _("if -d file then -d name and -d size are required\n"));
957
1303
                usage();
958
1304
        }
959
1305
        if (dsize) {
960
1306
                __uint64_t dbytes;
961
1307
 
962
 
                dbytes = cvtnum(blocksize, dsize);
 
1308
                dbytes = cvtnum(blocksize, sectorsize, dsize);
963
1309
                if (dbytes % XFS_MIN_BLOCKSIZE) {
964
1310
                        fprintf(stderr,
965
 
                        "illegal data length %lld, not a multiple of %d\n",
 
1311
                        _("illegal data length %lld, not a multiple of %d\n"),
966
1312
                                (long long)dbytes, XFS_MIN_BLOCKSIZE);
967
1313
                        usage();
968
1314
                }
969
1315
                dblocks = (xfs_drfsbno_t)(dbytes >> blocklog);
970
1316
                if (dbytes % blocksize)
971
 
                        fprintf(stderr,
972
 
        "warning: data length %lld not a multiple of %d, truncated to %lld\n",
 
1317
                        fprintf(stderr, _("warning: "
 
1318
        "data length %lld not a multiple of %d, truncated to %lld\n"),
973
1319
                                (long long)dbytes, blocksize,
974
1320
                                (long long)(dblocks << blocklog));
975
1321
        }
983
1329
#ifdef HAVE_VOLUME_MANAGER
984
1330
        if (xi.lisfile && (!logsize || !xi.logname)) {
985
1331
                fprintf(stderr,
986
 
                        "if -l file then -l name and -l size are required\n");
 
1332
                _("if -l file then -l name and -l size are required\n"));
987
1333
                usage();
988
1334
        }
989
1335
#endif
990
1336
        if (logsize) {
991
1337
                __uint64_t logbytes;
992
1338
 
993
 
                logbytes = cvtnum(blocksize, logsize);
 
1339
                logbytes = cvtnum(blocksize, sectorsize, logsize);
994
1340
                if (logbytes % XFS_MIN_BLOCKSIZE) {
995
1341
                        fprintf(stderr,
996
 
                        "illegal log length %lld, not a multiple of %d\n",
 
1342
                        _("illegal log length %lld, not a multiple of %d\n"),
997
1343
                                (long long)logbytes, XFS_MIN_BLOCKSIZE);
998
1344
                        usage();
999
1345
                }
1000
1346
                logblocks = (xfs_drfsbno_t)(logbytes >> blocklog);
1001
1347
                if (logbytes % blocksize)
1002
1348
                        fprintf(stderr,
1003
 
        "warning: log length %lld not a multiple of %d, truncated to %lld\n",
 
1349
        _("warning: log length %lld not a multiple of %d, truncated to %lld\n"),
1004
1350
                                (long long)logbytes, blocksize,
1005
1351
                                (long long)(logblocks << blocklog));
1006
1352
        }
1007
1353
#ifdef HAVE_VOLUME_MANAGER
1008
1354
        if (xi.risfile && (!rtsize || !xi.rtname)) {
1009
1355
                fprintf(stderr,
1010
 
                        "if -r file then -r name and -r size are required\n");
 
1356
                _("if -r file then -r name and -r size are required\n"));
1011
1357
                usage();
1012
1358
        }
1013
1359
#endif
1014
1360
        if (rtsize) {
1015
1361
                __uint64_t rtbytes;
1016
1362
 
1017
 
                rtbytes = cvtnum(blocksize, rtsize);
 
1363
                rtbytes = cvtnum(blocksize, sectorsize, rtsize);
1018
1364
                if (rtbytes % XFS_MIN_BLOCKSIZE) {
1019
1365
                        fprintf(stderr,
1020
 
                        "illegal rt length %lld, not a multiple of %d\n",
 
1366
                        _("illegal rt length %lld, not a multiple of %d\n"),
1021
1367
                                (long long)rtbytes, XFS_MIN_BLOCKSIZE);
1022
1368
                        usage();
1023
1369
                }
1024
1370
                rtblocks = (xfs_drfsbno_t)(rtbytes >> blocklog);
1025
1371
                if (rtbytes % blocksize)
1026
1372
                        fprintf(stderr,
1027
 
        "warning: rt length %lld not a multiple of %d, truncated to %lld\n",
 
1373
        _("warning: rt length %lld not a multiple of %d, truncated to %lld\n"),
1028
1374
                                (long long)rtbytes, blocksize,
1029
1375
                                (long long)(rtblocks << blocklog));
1030
1376
        }
1034
1380
        if (rtextsize) {
1035
1381
                __uint64_t rtextbytes;
1036
1382
 
1037
 
                rtextbytes = cvtnum(blocksize, rtextsize);
 
1383
                rtextbytes = cvtnum(blocksize, sectorsize, rtextsize);
1038
1384
                if (rtextbytes % blocksize) {
1039
1385
                        fprintf(stderr,
1040
 
                        "illegal rt extent size %lld, not a multiple of %d\n",
 
1386
                _("illegal rt extent size %lld, not a multiple of %d\n"),
1041
1387
                                (long long)rtextbytes, blocksize);
1042
1388
                        usage();
1043
1389
                }
1044
1390
                if (rtextbytes > XFS_MAX_RTEXTSIZE) {
1045
1391
                        fprintf(stderr,
1046
 
                                "rt extent size %s too large, maximum %d\n",
 
1392
                                _("rt extent size %s too large, maximum %d\n"),
1047
1393
                                rtextsize, XFS_MAX_RTEXTSIZE);
1048
1394
                        usage();
1049
1395
                }
1050
1396
                if (rtextbytes < XFS_MIN_RTEXTSIZE) {
1051
1397
                        fprintf(stderr,
1052
 
                                "rt extent size %s too small, minimum %d\n",
 
1398
                                _("rt extent size %s too small, minimum %d\n"),
1053
1399
                                rtextsize, XFS_MIN_RTEXTSIZE);
1054
1400
                        usage();
1055
1401
                }
1060
1406
                 * and the underlying volume is striped, then set rtextblocks
1061
1407
                 * to the stripe width.
1062
1408
                 */
1063
 
                int dummy1, rswidth;
1064
 
                __uint64_t rtextbytes;
 
1409
                int             dummy1, rswidth;
 
1410
                __uint64_t      rtextbytes;
 
1411
 
1065
1412
                dummy1 = rswidth = 0;
1066
 
                
1067
 
                if (!xi.disfile)
1068
 
                        get_subvol_stripe_wrapper(dfile, SVTYPE_RT, &dummy1, 
1069
 
                                                    &rswidth);
 
1413
 
 
1414
                if (!xi.disfile)
 
1415
                        get_subvol_stripe_wrapper(dfile, SVTYPE_RT, &dummy1, 
 
1416
                                                  &rswidth);
1070
1417
 
1071
1418
                /* check that rswidth is a multiple of fs blocksize */
1072
1419
                if (rswidth && !(BBTOB(rswidth) % blocksize)) {
1073
1420
                        rswidth = DTOBT(rswidth);
1074
1421
                        rtextbytes = rswidth << blocklog;
1075
1422
                        if (XFS_MIN_RTEXTSIZE <= rtextbytes &&
1076
 
                                (rtextbytes <= XFS_MAX_RTEXTSIZE))  {
1077
 
                                 rtextblocks = rswidth;
 
1423
                            (rtextbytes <= XFS_MAX_RTEXTSIZE)) {
 
1424
                                rtextblocks = rswidth;
1078
1425
                        } else {
1079
1426
                                rtextblocks = XFS_DFL_RTEXTSIZE >> blocklog;
1080
1427
                        }
1090
1437
            isize > XFS_DINODE_MAX_SIZE) {
1091
1438
                int     maxsz;
1092
1439
 
1093
 
                fprintf(stderr, "illegal inode size %d\n", isize);
 
1440
                fprintf(stderr, _("illegal inode size %d\n"), isize);
1094
1441
                maxsz = MIN(blocksize / XFS_MIN_INODE_PERBLOCK,
1095
1442
                            XFS_DINODE_MAX_SIZE);
1096
1443
                if (XFS_DINODE_MIN_SIZE == maxsz)
1097
1444
                        fprintf(stderr,
1098
 
                        "allowable inode size with %d byte blocks is %d\n",
 
1445
                        _("allowable inode size with %d byte blocks is %d\n"),
1099
1446
                                blocksize, XFS_DINODE_MIN_SIZE);
1100
1447
                else
1101
1448
                        fprintf(stderr,
1102
 
        "allowable inode size with %d byte blocks is between %d and %d\n",
 
1449
        _("allowable inode size with %d byte blocks is between %d and %d\n"),
1103
1450
                                blocksize, XFS_DINODE_MIN_SIZE, maxsz);
1104
1451
                usage();
1105
1452
        }
1106
1453
 
1107
 
        calc_stripe_factors(dsu, dsw, &dsunit, &dswidth);
 
1454
        /* if lsu or lsunit was specified, automatically use v2 logs */
 
1455
        if ((lsu || lsunit) && logversion == 1) {
 
1456
                fprintf(stderr,
 
1457
                        _("log stripe unit specified, using v2 logs\n"));
 
1458
                logversion = 2;
 
1459
        }
1108
1460
 
1109
 
        /* other global variables */
1110
 
        sectlog = 9;            /* i.e. 512 bytes */
 
1461
        calc_stripe_factors(dsu, dsw, sectorsize, lsu, lsectorsize,
 
1462
                                &dsunit, &dswidth, &lsunit);
1111
1463
 
1112
1464
        /*
1113
1465
         * Initialize.  This will open the log and rt devices as well.
1115
1467
        if (!libxfs_init(&xi))
1116
1468
                usage();
1117
1469
        if (!xi.ddev) {
1118
 
                fprintf(stderr, "no device name given in argument list\n");
 
1470
                fprintf(stderr, _("no device name given in argument list\n"));
1119
1471
                usage();
1120
1472
        }
1121
1473
 
1134
1486
                if (check_overwrite(dfile) ||
1135
1487
                    check_overwrite(logfile) ||
1136
1488
                    check_overwrite(xi.rtname)) {
1137
 
                        fprintf(stderr, "%s: "
1138
 
                                "Use the -f option to force overwrite.\n",
 
1489
                        fprintf(stderr,
 
1490
                        _("%s: Use the -f option to force overwrite.\n"),
1139
1491
                                progname);
1140
1492
                        exit(1);
1141
1493
                }
1142
1494
        }
1143
1495
 
1144
 
        if (!xi.disfile && do_overlap_checks) {
1145
 
                /*
1146
 
                 * do partition overlap check
1147
 
                 * If this is a straight file we assume that it's been created
1148
 
                 * before the call to mnt_check_init()
1149
 
                 */
1150
 
 
1151
 
                if (mnt_check_init(&mnt_check_state) == -1) {
1152
 
                        fprintf(stderr,
1153
 
                                "unable to initialize mount checking "
1154
 
                                "routines, bypassing protection checks.\n");
1155
 
                } else {
1156
 
                        mnt_partition_count = mnt_find_mount_conflicts(
1157
 
                                mnt_check_state, dfile);
1158
 
 
1159
 
                        /* 
1160
 
                         * ignore -1 return codes, since 3rd party devices
1161
 
                         * may not be part of hinv.
1162
 
                         */
1163
 
                        if (mnt_partition_count > 0) {
1164
 
                                if (mnt_causes_test(mnt_check_state, MNT_CAUSE_MOUNTED)) {
1165
 
                                        fprintf(stderr, "%s: "
1166
 
                                                "%s is already in use.\n",
1167
 
                                                progname, dfile);
1168
 
                                } else if (mnt_causes_test(mnt_check_state, MNT_CAUSE_OVERLAP)) {
1169
 
                                        fprintf(stderr, "%s: "
1170
 
                                                "%s overlaps partition(s) "
1171
 
                                                "already in use.\n",
1172
 
                                                progname, dfile);
1173
 
                                } else {
1174
 
                                        mnt_causes_show(mnt_check_state, stderr, progname);
1175
 
                                }
1176
 
                                fprintf(stderr, "\n");
1177
 
                                fflush(stderr);
1178
 
                                mnt_plist_show(mnt_check_state, stderr, progname);
1179
 
                                fprintf(stderr, "\n");
1180
 
                        }
1181
 
                        mnt_check_end(mnt_check_state);
1182
 
                        if (mnt_partition_count > 0) {
1183
 
                                usage();
1184
 
                        }
1185
 
                }
1186
 
        }
1187
 
 
1188
1496
        if (!liflag && !ldflag)
1189
1497
                loginternal = xi.logdev == 0;
1190
1498
        if (xi.logname)
1191
1499
                logfile = xi.logname;
1192
1500
        else if (loginternal)
1193
 
                logfile = "internal log";
 
1501
                logfile = _("internal log");
1194
1502
        else if (xi.volname && xi.logdev)
1195
 
                logfile = "volume log";
 
1503
                logfile = _("volume log");
1196
1504
        else if (!ldflag) {
1197
 
                fprintf(stderr, "no log subvolume or internal log\n");
 
1505
                fprintf(stderr, _("no log subvolume or internal log\n"));
1198
1506
                usage();
1199
1507
        }
1200
1508
        if (xi.rtname)
1201
1509
                rtfile = xi.rtname;
1202
1510
        else
1203
1511
        if (xi.volname && xi.rtdev)
1204
 
                rtfile = "volume rt";
 
1512
                rtfile = _("volume rt");
1205
1513
        else if (!xi.rtdev)
1206
 
                rtfile = "none";
 
1514
                rtfile = _("none");
1207
1515
        if (dsize && xi.dsize > 0 && dblocks > DTOBT(xi.dsize)) {
1208
1516
                fprintf(stderr,
1209
 
"size %s specified for data subvolume is too large, maximum is %lld blocks\n",
 
1517
                        _("size %s specified for data subvolume is too large, "
 
1518
                        "maximum is %lld blocks\n"),
1210
1519
                        dsize, (long long)DTOBT(xi.dsize));
1211
1520
                usage();
1212
1521
        } else if (!dsize && xi.dsize > 0)
1213
1522
                dblocks = DTOBT(xi.dsize);
1214
1523
        else if (!dsize) {
1215
 
                fprintf(stderr, "can't get size of data subvolume\n");
 
1524
                fprintf(stderr, _("can't get size of data subvolume\n"));
1216
1525
                usage();
1217
1526
        } 
1218
1527
        if (dblocks < XFS_MIN_DATA_BLOCKS) {
1219
1528
                fprintf(stderr,
1220
 
                "size %lld of data subvolume is too small, minimum %d blocks\n",
 
1529
        _("size %lld of data subvolume is too small, minimum %d blocks\n"),
1221
1530
                        (long long)dblocks, XFS_MIN_DATA_BLOCKS);
1222
1531
                usage();
1223
1532
        }
1224
 
        if (xi.logdev && loginternal) {
1225
 
                fprintf(stderr, "can't have both external and internal logs\n");
1226
 
                usage();
1227
 
        }
1228
 
        if (dirversion == 1)
1229
 
                i = max_trres_v1[blocklog - XFS_MIN_BLOCKSIZE_LOG]
1230
 
                                [inodelog - XFS_DINODE_MIN_LOG];
1231
 
        else
1232
 
                i = max_trres_v2[blocklog - XFS_MIN_BLOCKSIZE_LOG]
1233
 
                                [inodelog - XFS_DINODE_MIN_LOG]
1234
 
                                [dirblocklog - XFS_MIN_BLOCKSIZE_LOG];
1235
 
        min_logblocks = MAX(XFS_MIN_LOG_BLOCKS, i * XFS_MIN_LOG_FACTOR);
 
1533
 
 
1534
        if (loginternal && xi.logdev) {
 
1535
                fprintf(stderr,
 
1536
                        _("can't have both external and internal logs\n"));
 
1537
                usage();
 
1538
        } else if (loginternal && sectorsize != lsectorsize) {
 
1539
                fprintf(stderr,
 
1540
        _("data and log sector sizes must be equal for internal logs\n"));
 
1541
                usage();
 
1542
        }
 
1543
 
 
1544
        if (xi.dbsize > sectorsize) {
 
1545
                fprintf(stderr, _(
 
1546
"Warning: the data subvolume sector size %u is less than the sector size \n\
 
1547
reported by the device (%u).\n"),
 
1548
                        sectorsize, xi.dbsize);
 
1549
        }
 
1550
        if (!loginternal && xi.lbsize > lsectorsize) {
 
1551
                fprintf(stderr, _(
 
1552
"Warning: the log subvolume sector size %u is less than the sector size\n\
 
1553
reported by the device (%u).\n"),
 
1554
                        lsectorsize, xi.lbsize);
 
1555
        }
 
1556
        if (rtsize && xi.rtsize > 0 && xi.rtbsize > sectorsize) {
 
1557
                fprintf(stderr, _(
 
1558
"Warning: the realtime subvolume sector size %u is less than the sector size\n\
 
1559
reported by the device (%u).\n"),
 
1560
                        sectorsize, xi.rtbsize);
 
1561
        }
 
1562
 
 
1563
        max_tr_res = max_trans_res(dirversion,
 
1564
                                   sectorlog, blocklog, inodelog, dirblocklog);
 
1565
        ASSERT(max_tr_res);
 
1566
        min_logblocks = max_tr_res * XFS_MIN_LOG_FACTOR;
 
1567
        min_logblocks = MAX(XFS_MIN_LOG_BLOCKS, min_logblocks);
 
1568
        if (!logsize && dblocks >= (1024*1024*1024) >> blocklog)
 
1569
                min_logblocks = MAX(min_logblocks, (10*1024*1024)>>blocklog);
1236
1570
        if (logsize && xi.logBBsize > 0 && logblocks > DTOBT(xi.logBBsize)) {
1237
1571
                fprintf(stderr,
1238
 
"size %s specified for log subvolume is too large, maximum is %lld blocks\n",
 
1572
_("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
1239
1573
                        logsize, (long long)DTOBT(xi.logBBsize));
1240
1574
                usage();
1241
 
        } else if (!logsize && xi.logBBsize > 0)
 
1575
        } else if (!logsize && xi.logBBsize > 0) {
1242
1576
                logblocks = DTOBT(xi.logBBsize);
1243
 
        else if (logsize && !xi.logdev && !loginternal) {
 
1577
        } else if (logsize && !xi.logdev && !loginternal) {
1244
1578
                fprintf(stderr,
1245
 
                        "size specified for non-existent log subvolume\n");
 
1579
                        _("size specified for non-existent log subvolume\n"));
1246
1580
                usage();
1247
1581
        } else if (loginternal && logsize && logblocks >= dblocks) {
1248
 
                fprintf(stderr, "size %lld too large for internal log\n",
 
1582
                fprintf(stderr, _("size %lld too large for internal log\n"),
1249
1583
                        (long long)logblocks);
1250
1584
                usage();
1251
 
        } else if (!loginternal && !xi.logdev)
 
1585
        } else if (!loginternal && !xi.logdev) {
1252
1586
                logblocks = 0;
1253
 
        else if (loginternal && !logsize) {
 
1587
        } else if (loginternal && !logsize) {
1254
1588
                /*
1255
1589
                 * logblocks grows from min_logblocks to XFS_MAX_LOG_BLOCKS
1256
 
                 * at 1TB
 
1590
                 * at 128GB
1257
1591
                 *
1258
 
                 * 8192 = 1TB / MAX_LOG_BYTES
 
1592
                 * 2048 = 128GB / MAX_LOG_BYTES
1259
1593
                 */
1260
 
                logblocks = (dblocks << blocklog) / 8192;
 
1594
                logblocks = (dblocks << blocklog) / 2048;
1261
1595
                logblocks = logblocks >> blocklog;
1262
1596
                logblocks = MAX(min_logblocks, logblocks);
1263
 
                logblocks = MAX(logblocks,
1264
 
                                MAX(XFS_DFL_LOG_SIZE, i * XFS_DFL_LOG_FACTOR));
1265
 
                logblocks = MIN(logblocks, XFS_MAX_LOG_BLOCKS); 
 
1597
                logblocks = MAX(logblocks,
 
1598
                                MAX(XFS_DFL_LOG_SIZE,
 
1599
                                        max_tr_res * XFS_DFL_LOG_FACTOR));
 
1600
                logblocks = MIN(logblocks, XFS_MAX_LOG_BLOCKS); 
1266
1601
                if ((logblocks << blocklog) > XFS_MAX_LOG_BYTES) {
1267
1602
                        logblocks = XFS_MAX_LOG_BYTES >> blocklog;
1268
1603
                }
1269
 
        } 
1270
 
        if (logblocks < min_logblocks) {
1271
 
                fprintf(stderr,
1272
 
                "log size %lld blocks too small, minimum size is %d blocks\n",
1273
 
                        (long long)logblocks, min_logblocks);
1274
 
                usage();
1275
 
        }
1276
 
        if (logblocks > XFS_MAX_LOG_BLOCKS) {
1277
 
                fprintf(stderr,
1278
 
                "log size %lld blocks too large, maximum size is %d blocks\n",
1279
 
                        (long long)logblocks, XFS_MAX_LOG_BLOCKS);
1280
 
                usage();
1281
 
        }
1282
 
        if ((logblocks << blocklog) > XFS_MAX_LOG_BYTES) {
1283
 
                fprintf(stderr,
1284
 
                "log size %lld bytes too large, maximum size is %d bytes\n",
1285
 
                        (long long)(logblocks << blocklog), XFS_MAX_LOG_BYTES);
1286
 
                usage();
1287
 
        }
 
1604
        }
 
1605
        validate_log_size(logblocks, blocklog, min_logblocks);
 
1606
 
1288
1607
        if (rtsize && xi.rtsize > 0 && rtblocks > DTOBT(xi.rtsize)) {
1289
1608
                fprintf(stderr,
1290
 
"size %s specified for rt subvolume is too large, maximum is %lld blocks\n",
 
1609
                        _("size %s specified for rt subvolume is too large, "
 
1610
                        "maximum is %lld blocks\n"),
1291
1611
                        rtsize, (long long)DTOBT(xi.rtsize));
1292
1612
                usage();
1293
1613
        } else if (!rtsize && xi.rtsize > 0)
1294
1614
                rtblocks = DTOBT(xi.rtsize);
1295
1615
        else if (rtsize && !xi.rtdev) {
1296
1616
                fprintf(stderr,
1297
 
                        "size specified for non-existent rt subvolume\n");
 
1617
                        _("size specified for non-existent rt subvolume\n"));
1298
1618
                usage();
1299
1619
        }
1300
1620
        if (xi.rtdev) {
1305
1625
                nbmblocks = 0;
1306
1626
        }
1307
1627
 
1308
 
        if (dasize) {
 
1628
        if (dasize) {           /* User-specified AG size */
1309
1629
                /*
1310
 
                 * If the specified agsize isn't a multiple of fs blks,
1311
 
                 * complain.
 
1630
                 * Check specified agsize is a multiple of blocksize.
1312
1631
                 */
1313
1632
                if (agsize % blocksize) {
1314
1633
                        fprintf(stderr,
1315
 
                        "agsize (%lld) not a multiple of fs blk size (%d)\n",
 
1634
                _("agsize (%lld) not a multiple of fs blk size (%d)\n"),
1316
1635
                                (long long)agsize, blocksize);
1317
1636
                        usage();
1318
1637
                }
1319
 
 
1320
1638
                agsize /= blocksize;
1321
 
 
1322
 
                /*
1323
 
                 * If the specified agsize is too small, or too large,
1324
 
                 * complain.
1325
 
                 */
1326
 
                if (agsize < XFS_AG_MIN_BLOCKS(blocklog)) {
1327
 
                        fprintf(stderr,
1328
 
                        "agsize (%lldb) too small, need at least %lld blocks\n",
1329
 
                                (long long)agsize,
1330
 
                                (long long)XFS_AG_MIN_BLOCKS(blocklog));
1331
 
                        usage();
1332
 
                }
1333
 
 
1334
 
                if (agsize > XFS_AG_MAX_BLOCKS(blocklog)) {
1335
 
                        fprintf(stderr,
1336
 
                        "agsize (%lldb) too big, maximum is %lld blocks\n",
1337
 
                                (long long)agsize,
1338
 
                                (long long)XFS_AG_MAX_BLOCKS(blocklog));
1339
 
                        usage();
1340
 
                }
1341
 
 
1342
 
                if (agsize > dblocks)  {
1343
 
                        fprintf(stderr,
1344
 
                        "agsize (%lldb) too big, data area is %lld blocks\n",
1345
 
                                (long long)agsize, (long long)dblocks);
1346
 
                        usage();
1347
 
                }
1348
 
 
1349
 
                agcount = dblocks / agsize + (dblocks % agsize != 0);
1350
 
        } else {
1351
 
                agsize = dblocks / agcount + (dblocks % agcount != 0);
1352
 
        }
1353
 
 
1354
 
        /*
1355
 
         * If the ag size is too small, complain if agcount/agsize was
1356
 
         * specified, and fix it otherwise.
1357
 
         */
1358
 
        if (agsize < XFS_AG_MIN_BLOCKS(blocklog)) {
1359
 
                if (daflag || dasize) {
1360
 
                        fprintf(stderr,
1361
 
                                "too many allocation groups for size = %lld\n",
1362
 
                                (long long)agsize);
1363
 
                        fprintf(stderr, "need at most %lld allocation groups\n",
1364
 
                                (long long)
1365
 
                                (dblocks / XFS_AG_MIN_BLOCKS(blocklog) +
1366
 
                                (dblocks % XFS_AG_MIN_BLOCKS(blocklog) != 0)));
1367
 
                        usage();
1368
 
                }
1369
 
                agsize = XFS_AG_MIN_BLOCKS(blocklog);
1370
 
                if (dblocks < agsize)
1371
 
                        agcount = 1;
1372
 
                else
1373
 
                        agcount = dblocks / agsize;
1374
 
 
1375
 
                agsize = dblocks / agcount + (dblocks % agcount != 0);
1376
 
        }
1377
 
 
1378
 
        /*
1379
 
         * If the ag size is too large, complain if agcount/agsize was
1380
 
         * specified, and fix it otherwise.
1381
 
         */
1382
 
        else if (agsize > XFS_AG_MAX_BLOCKS(blocklog)) {
1383
 
                if (daflag || dasize) {
1384
 
                        fprintf(stderr, "too few allocation groups for size = %lld\n",
1385
 
                                (long long)agsize);
1386
 
                        fprintf(stderr,
1387
 
                                "need at least %lld allocation groups\n",
1388
 
                                (long long)
1389
 
                                (dblocks / XFS_AG_MAX_BLOCKS(blocklog) + 
1390
 
                                (dblocks % XFS_AG_MAX_BLOCKS(blocklog) != 0)));
1391
 
                        usage();
1392
 
                }
1393
 
                agsize = XFS_AG_MAX_BLOCKS(blocklog);
1394
 
                agcount = dblocks / agsize + (dblocks % agsize != 0);
1395
 
        }
1396
 
 
1397
 
        /*
1398
 
         * if user set the AG size, and if the last AG is too small,
1399
 
         * reduce the filesystem size and drop the blocks.
1400
 
         */
1401
 
        if (!daflag &&
1402
 
            (dblocks % agsize < XFS_AG_MIN_BLOCKS(blocklog))) {
1403
 
                dblocks -= dblocks % agsize;
1404
 
        }
1405
 
 
1406
 
        /*
1407
 
         * If agcount was not specified, and agsize is larger than
1408
 
         * we'd like, make it the size we want.
1409
 
         */
1410
 
        if (!daflag && !dasize &&
1411
 
            (agsize > XFS_AG_BEST_BLOCKS(blocklog,dblocks))) {
1412
 
                agsize = XFS_AG_BEST_BLOCKS(blocklog,dblocks);
1413
 
                /*
1414
 
                 * If the last AG is too small, reduce the filesystem size
1415
 
                 * and drop the blocks.
1416
 
                 */
1417
 
                if (dblocks % agsize < XFS_AG_MIN_BLOCKS(blocklog)) {
1418
 
                        dblocks -= dblocks % agsize;
1419
 
                }
1420
 
                agcount = dblocks / agsize + (dblocks % agsize != 0);
1421
 
        }
1422
 
 
1423
 
        /*
1424
 
         * If agcount is too large, make it smaller.
1425
 
         */
1426
 
        if (agcount > XFS_MAX_AGNUMBER + 1) {
1427
 
                agcount = XFS_MAX_AGNUMBER + 1;
1428
 
                agsize = dblocks / agcount + (dblocks % agcount != 0);
1429
 
 
1430
 
                if (dasize || daflag)
1431
 
                        fprintf(stderr,
1432
 
                "agsize set to %lld, agcount %lld > max (%lld)\n",
1433
 
                                (long long)agsize, (long long)agcount,
1434
 
                                (long long)XFS_MAX_AGNUMBER+1);
1435
 
 
1436
 
                if (agsize > XFS_AG_MAX_BLOCKS(blocklog)) {
1437
 
                        /*
1438
 
                         * We're confused.
1439
 
                         */
1440
 
                        fprintf(stderr, "%s: can't compute agsize/agcount\n",
1441
 
                                progname);
1442
 
                        exit(1);
1443
 
                }
1444
 
        }
 
1639
                agcount = dblocks / agsize + (dblocks % agsize != 0);
 
1640
 
 
1641
        } else if (daflag)      /* User-specified AG size */
 
1642
                agsize = dblocks / agcount + (dblocks % agcount != 0);
 
1643
        else
 
1644
                calc_default_ag_geometry(blocklog, dblocks, &agsize, &agcount);
 
1645
 
 
1646
        /*
 
1647
         * If the last AG is too small, reduce the filesystem size
 
1648
         * and drop the blocks.
 
1649
         */
 
1650
        if ( dblocks % agsize != 0 &&
 
1651
             (dblocks % agsize < XFS_AG_MIN_BLOCKS(blocklog))) {
 
1652
                dblocks = (xfs_drfsbno_t)((agcount - 1) * agsize);
 
1653
                agcount--;
 
1654
                ASSERT(agcount != 0);
 
1655
        }
 
1656
 
 
1657
        validate_ag_geometry(blocklog, dblocks, agsize, agcount);
1445
1658
 
1446
1659
        xlv_dsunit = xlv_dswidth = 0;
1447
 
        if (!xi.disfile)
1448
 
                get_subvol_stripe_wrapper(dfile, SVTYPE_DATA, &xlv_dsunit, 
1449
 
                                &xlv_dswidth);
 
1660
        if (!xi.disfile)
 
1661
                get_subvol_stripe_wrapper(dfile, SVTYPE_DATA,
 
1662
                                                &xlv_dsunit, &xlv_dswidth);
1450
1663
        if (dsunit) {
1451
1664
 
1452
1665
                if (xlv_dsunit && xlv_dsunit != dsunit) {
1453
 
                        fprintf(stderr, "%s: "
1454
 
  "Specified data stripe unit %d is not the same as the xlv stripe unit %d\n", 
 
1666
                        fprintf(stderr,
 
1667
                                _("%s: Specified data stripe unit %d is not "
 
1668
                                "the same as the volume stripe unit %d\n"),
1455
1669
                                progname, dsunit, xlv_dsunit);
1456
 
                        exit(1);
1457
1670
                }
1458
1671
                if (xlv_dswidth && xlv_dswidth != dswidth) {
1459
 
                        fprintf(stderr, "%s: "
1460
 
"Specified data stripe width (%d) is not the same as the xlv stripe width (%d)\n",
 
1672
                        fprintf(stderr,
 
1673
                                _("%s: Specified data stripe width %d is not "
 
1674
                                "the same as the volume stripe width %d\n"),
1461
1675
                                progname, dswidth, xlv_dswidth);
1462
 
                        exit(1);
1463
1676
                }
1464
1677
        } else {
1465
1678
                dsunit = xlv_dsunit;
1482
1695
                 * agsize is not a multiple of dsunit
1483
1696
                 */
1484
1697
                if ((agsize % dsunit) != 0) {
1485
 
                        /*
1486
 
                         * Round up to stripe unit boundary. Also make sure 
 
1698
                        /*
 
1699
                         * Round up to stripe unit boundary. Also make sure 
1487
1700
                         * that agsize is still larger than 
1488
1701
                         * XFS_AG_MIN_BLOCKS(blocklog)
1489
1702
                         */
1490
 
                        tmp_agsize = ((agsize + (dsunit - 1))/ dsunit) * dsunit;
 
1703
                        tmp_agsize = ((agsize + (dsunit - 1))/ dsunit) * dsunit;
1491
1704
                        /*
1492
1705
                         * Round down to stripe unit boundary if rounding up
1493
1706
                         * created an AG size that is larger than the AG max.
1494
1707
                         */
1495
1708
                        if (tmp_agsize > XFS_AG_MAX_BLOCKS(blocklog))
1496
1709
                                tmp_agsize = ((agsize) / dsunit) * dsunit;
1497
 
                        if ((tmp_agsize >= XFS_AG_MIN_BLOCKS(blocklog)) &&
 
1710
                        if ((tmp_agsize >= XFS_AG_MIN_BLOCKS(blocklog)) &&
1498
1711
                            (tmp_agsize <= XFS_AG_MAX_BLOCKS(blocklog)) &&
1499
1712
                            !daflag) {
1500
1713
                                agsize = tmp_agsize;
1502
1715
                                                (dblocks % agsize != 0);
1503
1716
                                if (dasize || daflag)
1504
1717
                                        fprintf(stderr,
1505
 
                                        "agsize rounded to %lld, swidth = %d\n",
 
1718
                                _("agsize rounded to %lld, swidth = %d\n"),
1506
1719
                                                (long long)agsize, dswidth);
1507
 
                        } else {
 
1720
                        } else {
1508
1721
                                if (nodsflag) {
1509
1722
                                        dsunit = dswidth = 0;
1510
1723
                                } else { 
1511
1724
                                        fprintf(stderr,
1512
 
"Allocation group size %lld is not a multiple of the stripe unit %d\n",
 
1725
_("Allocation group size (%lld) is not a multiple of the stripe unit (%d)\n"),
1513
1726
                                                (long long)agsize, dsunit);
1514
1727
                                        exit(1);
1515
1728
                                }
1516
 
                        }
 
1729
                        }
 
1730
                }
 
1731
                if (dswidth && ((agsize % dswidth) == 0) && (agcount > 1)) {
 
1732
                        /* This is a non-optimal configuration because all AGs
 
1733
                         * start on the same disk in the stripe.  Changing 
 
1734
                         * the AG size by one sunit will guarantee that this
 
1735
                         * does not happen.
 
1736
                         */
 
1737
                        tmp_agsize = agsize - dsunit;
 
1738
                        if (tmp_agsize < XFS_AG_MIN_BLOCKS(blocklog)) {
 
1739
                                tmp_agsize = agsize + dsunit;
 
1740
                                if (dblocks < agsize) {
 
1741
                                        /* oh well, nothing to do */
 
1742
                                        tmp_agsize = agsize;
 
1743
                                }
 
1744
                        }
 
1745
                        if (daflag || dasize) {
 
1746
                                fprintf(stderr, _(
 
1747
"Warning: AG size is a multiple of stripe width.  This can cause performance\n\
 
1748
problems by aligning all AGs on the same disk.  To avoid this, run mkfs with\n\
 
1749
an AG size that is one stripe unit smaller, for example %llu.\n"),
 
1750
                                        (unsigned long long)tmp_agsize);
 
1751
                        } else {
 
1752
                                agsize = tmp_agsize;
 
1753
                                agcount = dblocks/agsize + (dblocks % agsize != 0);
 
1754
                                /*
 
1755
                                 * If the last AG is too small, reduce the
 
1756
                                 * filesystem size and drop the blocks.
 
1757
                                 */
 
1758
                                if ( dblocks % agsize != 0 &&
 
1759
                                    (dblocks % agsize <
 
1760
                                    XFS_AG_MIN_BLOCKS(blocklog))) {
 
1761
                                        dblocks = (xfs_drfsbno_t)((agcount - 1) * agsize);
 
1762
                                        agcount--;
 
1763
                                        ASSERT(agcount != 0);
 
1764
                                }
 
1765
                        }
1517
1766
                }
1518
1767
        } else {
1519
1768
                if (nodsflag)
1520
1769
                        dsunit = dswidth = 0;
1521
1770
                else { 
1522
 
                        fprintf(stderr, "%s: "
1523
 
"Stripe unit(%d) or stripe width(%d) is not a multiple of the block size(%d)\n",
1524
 
                                progname, dsunit, dswidth, blocksize);  
1525
 
                        exit(1);
1526
 
                }
 
1771
                        fprintf(stderr,
 
1772
                                _("%s: Stripe unit(%d) or stripe width(%d) is "
 
1773
                                "not a multiple of the block size(%d)\n"),
 
1774
                                progname, BBTOB(dsunit), BBTOB(dswidth), 
 
1775
                                blocksize);     
 
1776
                        exit(1);
 
1777
                }
 
1778
        }
 
1779
 
 
1780
        /*
 
1781
         * check that log sunit is modulo fsblksize or default it to dsunit.
 
1782
         */
 
1783
 
 
1784
        if (lsunit) {
 
1785
                if ((BBTOB(lsunit) % blocksize != 0)) {
 
1786
                        fprintf(stderr,
 
1787
        _("log stripe unit (%d) must be a multiple of the block size (%d)\n"),
 
1788
                        BBTOB(lsunit), blocksize);
 
1789
                        exit(1);
 
1790
                }
 
1791
                /* convert from 512 byte blocks to fs blocks */
 
1792
                lsunit = DTOBT(lsunit);
 
1793
        } else if (logversion == 2 && loginternal && dsunit) {
 
1794
                /* lsunit and dsunit now in fs blocks */
 
1795
                lsunit = dsunit;
 
1796
        }
 
1797
 
 
1798
        if (logversion == 2 && (lsunit * blocksize) > 256 * 1024) {
 
1799
                fprintf(stderr,
 
1800
        _("log stripe unit (%d bytes) is too large (maximum is 256KiB)\n"),
 
1801
                        (lsunit * blocksize));
 
1802
                lsunit = (32 * 1024) >> blocklog;
 
1803
                fprintf(stderr, _("log stripe unit adjusted to 32KiB\n"));
1527
1804
        }
1528
1805
 
1529
1806
        protostring = setup_proto(protofile);
1532
1809
        sbp = &mp->m_sb;
1533
1810
        bzero(mp, sizeof(xfs_mount_t));
1534
1811
        sbp->sb_blocklog = (__uint8_t)blocklog;
 
1812
        sbp->sb_sectlog = (__uint8_t)sectorlog;
1535
1813
        sbp->sb_agblklog = (__uint8_t)libxfs_log2_roundup((unsigned int)agsize);
1536
1814
        mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT;
 
1815
        mp->m_sectbb_log = sbp->sb_sectlog - BBSHIFT;
 
1816
 
1537
1817
        if (loginternal) {
 
1818
                /*
 
1819
                 * Readjust the log size to fit within an AG if it was sized
 
1820
                 * automaticly.
 
1821
                 */
 
1822
                if (!logsize) {
 
1823
                        logblocks = MIN(logblocks,
 
1824
                                        agsize - XFS_PREALLOC_BLOCKS(mp));
 
1825
                }
1538
1826
                if (logblocks > agsize - XFS_PREALLOC_BLOCKS(mp)) {
1539
1827
                        fprintf(stderr,
1540
 
        "internal log size %lld too large, must fit in allocation group\n",
 
1828
        _("internal log size %lld too large, must fit in allocation group\n"),
1541
1829
                                (long long)logblocks);
1542
1830
                        usage();
1543
1831
                }
1544
1832
                if (laflag) {
1545
1833
                        if (logagno >= agcount) {
1546
1834
                                fprintf(stderr,
1547
 
                        "log ag number %d too large, must be less than %lld\n",
 
1835
                _("log ag number %d too large, must be less than %lld\n"),
1548
1836
                                        logagno, (long long)agcount);
1549
1837
                                usage();
1550
1838
                        }
1555
1843
                /*
1556
1844
                 * Align the logstart at stripe unit boundary.
1557
1845
                 */
1558
 
                if (dsunit && ((logstart % dsunit) != 0)) {
1559
 
                        logstart = ((logstart + (dsunit - 1))/dsunit) * dsunit;
1560
 
                        /* 
1561
 
                         * Make sure that the log size is a multiple of the
1562
 
                         * stripe unit
1563
 
                         */
1564
 
                        if ((logblocks % dsunit) != 0) {
1565
 
                            if (!lsflag) {
1566
 
                                tmp_logblocks = ((logblocks + (dsunit - 1))
1567
 
                                                        / dsunit) * dsunit;
1568
 
                                /*
1569
 
                                 * If the log is too large, round down
1570
 
                                 * instead of round up
1571
 
                                 */
1572
 
                                if ((tmp_logblocks > XFS_MAX_LOG_BLOCKS) ||
1573
 
                                    ((tmp_logblocks << blocklog) > XFS_MAX_LOG_BYTES)) {
1574
 
                                        tmp_logblocks = (logblocks / dsunit) * dsunit;
1575
 
                                }
1576
 
                                logblocks = tmp_logblocks;
1577
 
                            } else {
1578
 
                                fprintf(stderr,
1579
 
        "internal log size %lld is not a multiple of the stripe unit %d\n", 
1580
 
                                        (long long)logblocks, dsunit);
1581
 
                                usage();
1582
 
                            }
1583
 
                        }
1584
 
 
1585
 
                        if (logblocks > agsize-XFS_FSB_TO_AGBNO(mp,logstart)) {
1586
 
                                fprintf(stderr,
1587
 
        "Due to stripe alignment, the internal log size %lld is too large.\n"
1588
 
        "Must fit in allocation group\n",
1589
 
                                        (long long)logblocks);
1590
 
                                usage();
1591
 
                        }
1592
 
                        lalign = 1;
 
1846
                if (lsunit) {
 
1847
                        logstart = fixup_log_stripe(mp, lsflag, logstart,
 
1848
                                        agsize, lsunit, &logblocks, blocklog,
 
1849
                                        &lalign);
 
1850
                } else if (dsunit) {
 
1851
                        logstart = fixup_log_stripe(mp, lsflag, logstart,
 
1852
                                        agsize, dsunit, &logblocks, blocklog,
 
1853
                                        &lalign);
1593
1854
                }
 
1855
                min_logblocks = max_tr_res * XFS_MIN_LOG_FACTOR;
 
1856
                min_logblocks = MAX(min_logblocks, XFS_MIN_LOG_BLOCKS);
 
1857
                validate_log_size(logblocks, blocklog, min_logblocks);
1594
1858
        } else
1595
1859
                logstart = 0;
1596
1860
 
 
1861
        if (!qflag || Nflag) {
 
1862
                printf(_(
 
1863
                   "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n"
 
1864
                   "         =%-22s sectsz=%-5u\n"
 
1865
                   "data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
 
1866
                   "         =%-22s sunit=%-6u swidth=%u blks, unwritten=%u\n"
 
1867
                   "naming   =version %-14u bsize=%-6u\n"
 
1868
                   "log      =%-22s bsize=%-6d blocks=%lld, version=%d\n"
 
1869
                   "         =%-22s sectsz=%-5u sunit=%d blks\n"
 
1870
                   "realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),
 
1871
                        dfile, isize, (long long)agcount, (long long)agsize,
 
1872
                        "", sectorsize,
 
1873
                        "", blocksize, (long long)dblocks,
 
1874
                                imflag ? imaxpct : XFS_DFL_IMAXIMUM_PCT,
 
1875
                        "", dsunit, dswidth, extent_flagging,
 
1876
                        dirversion, dirversion == 1 ? blocksize : dirblocksize,
 
1877
                        logfile, 1 << blocklog, (long long)logblocks,
 
1878
                        logversion, "", lsectorsize, lsunit,
 
1879
                        rtfile, rtextblocks << blocklog,
 
1880
                        (long long)rtblocks, (long long)rtextents);
 
1881
                if (Nflag)
 
1882
                        exit(0);
 
1883
        }
 
1884
 
1597
1885
        if (label)
1598
1886
                strncpy(sbp->sb_fname, label, sizeof(sbp->sb_fname));
1599
1887
        sbp->sb_magicnum = XFS_SB_MAGIC;
1610
1898
        sbp->sb_agcount = (xfs_agnumber_t)agcount;
1611
1899
        sbp->sb_rbmblocks = nbmblocks;
1612
1900
        sbp->sb_logblocks = (xfs_extlen_t)logblocks;
1613
 
        sbp->sb_sectsize = 1 << sectlog;
 
1901
        sbp->sb_sectsize = (__uint16_t)sectorsize;
1614
1902
        sbp->sb_inodesize = (__uint16_t)isize;
1615
1903
        sbp->sb_inopblock = (__uint16_t)(blocksize / isize);
1616
 
        sbp->sb_sectlog = (__uint8_t)sectlog;
 
1904
        sbp->sb_sectlog = (__uint8_t)sectorlog;
1617
1905
        sbp->sb_inodelog = (__uint8_t)inodelog;
1618
1906
        sbp->sb_inopblog = (__uint8_t)(blocklog - inodelog);
1619
1907
        sbp->sb_rextslog =
1632
1920
        sbp->sb_width = dswidth;
1633
1921
        if (dirversion == 2)
1634
1922
                sbp->sb_dirblklog = dirblocklog - blocklog;
 
1923
        if (logversion == 2) {  /* This is stored in bytes */
 
1924
                lsunit = (lsunit == 0) ? 1 : XFS_FSB_TO_B(mp, lsunit);
 
1925
                sbp->sb_logsunit = lsunit;
 
1926
        } else
 
1927
                sbp->sb_logsunit = 0;
1635
1928
        if (iaflag) {
1636
1929
                sbp->sb_inoalignmt = XFS_INODE_BIG_CLUSTER_SIZE >> blocklog;
1637
1930
                iaflag = sbp->sb_inoalignmt != 0;
1638
1931
        } else
1639
1932
                sbp->sb_inoalignmt = 0;
 
1933
        if (lsectorsize != BBSIZE || sectorsize != BBSIZE) {
 
1934
                sbp->sb_logsectlog = (__uint8_t)lsectorlog;
 
1935
                sbp->sb_logsectsize = (__uint16_t)lsectorsize;
 
1936
        } else {
 
1937
                sbp->sb_logsectlog = 0;
 
1938
                sbp->sb_logsectsize = 0;
 
1939
        }
1640
1940
        sbp->sb_versionnum =
1641
1941
                XFS_SB_VERSION_MKFS(iaflag, dsunit != 0, extent_flagging,
1642
 
                        dirversion == 2);
1643
 
 
 
1942
                        dirversion == 2, logversion == 2,
 
1943
                        (sectorsize != BBSIZE || lsectorsize != BBSIZE), 0);
 
1944
        sbp->sb_features2 = XFS_SB_VERSION2_MKFS(0);
1644
1945
        /*
1645
 
         * Zero out the first 68k in on the device, to obliterate any old 
 
1946
         * Zero out the beginning of the device, to obliterate any old 
1646
1947
         * filesystem signatures out there.  This should take care of 
1647
1948
         * swap (somewhere around the page size), jfs (32k), 
1648
 
         * ext[2,3] and reiser (64k) - and hopefully all else.
 
1949
         * ext[2,3] and reiserfs (64k) - and hopefully all else.
1649
1950
         */
1650
 
         
1651
 
        buf = libxfs_getbuf(xi.ddev, 0, 136);
1652
 
        bzero(XFS_BUF_PTR(buf), 136*BBSIZE);
1653
 
        libxfs_writebuf(buf, 1);
 
1951
        buf = libxfs_getbuf(xi.ddev, 0, BTOBB(WHACK_SIZE));
 
1952
        bzero(XFS_BUF_PTR(buf), WHACK_SIZE);
 
1953
        libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1654
1954
 
1655
1955
        /* OK, now write the superblock */
1656
 
        buf = libxfs_getbuf(xi.ddev, XFS_SB_DADDR, 1);
1657
 
        bzero(XFS_BUF_PTR(buf), BBSIZE);
 
1956
        buf = libxfs_getbuf(xi.ddev, XFS_SB_DADDR, XFS_FSS_TO_BB(mp, 1));
 
1957
        bzero(XFS_BUF_PTR(buf), sectorsize);
1658
1958
        libxfs_xlate_sb(XFS_BUF_PTR(buf), sbp, -1, ARCH_CONVERT,
1659
1959
                        XFS_SB_ALL_BITS);
1660
 
        libxfs_writebuf(buf, 1);
 
1960
        libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1661
1961
 
1662
 
        if (!qflag)
1663
 
                printf(
1664
 
                   "meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n"
1665
 
                   "data     =%-22s bsize=%-6d blocks=%lld, imaxpct=%d\n"
1666
 
                   "         =%-22s sunit=%-6d swidth=%d blks, unwritten=%d\n"
1667
 
                   "naming   =version %-14d bsize=%-6d\n"
1668
 
                   "log      =%-22s bsize=%-6d blocks=%lld\n"
1669
 
                   "realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n",
1670
 
                        dfile, isize, (long long)agcount, (long long)agsize,
1671
 
                        "", blocksize, (long long)dblocks, sbp->sb_imax_pct,
1672
 
                        "", dsunit, dswidth, extent_flagging,
1673
 
                        dirversion, dirversion == 1 ? blocksize : dirblocksize,
1674
 
                        logfile, 1 << blocklog, (long long)logblocks,
1675
 
                        rtfile, rtextblocks << blocklog,
1676
 
                        (long long)rtblocks, (long long)rtextents);
1677
1962
        /*
1678
1963
         * If the data area is a file, then grow it out to its final size
1679
1964
         * so that the reads for the end of the device in the mount code
1680
1965
         * will succeed.
1681
1966
         */
1682
1967
        if (xi.disfile && ftruncate64(xi.dfd, dblocks * blocksize) < 0) {
1683
 
                fprintf(stderr, "%s: Growing the data section file failed\n",
 
1968
                fprintf(stderr, _("%s: Growing the data section failed\n"),
1684
1969
                        progname);
1685
1970
                exit(1);
1686
1971
        }
1687
1972
 
1688
1973
        /*
1689
 
         * Zero out the last 64k on the device, to obliterate any
 
1974
         * Zero out the end of the device, to obliterate any
1690
1975
         * old MD RAID (or other) metadata at the end of the device.
 
1976
         * (MD sb is ~64k from the end, take out a wider swath to be sure)
1691
1977
         */
1692
1978
        if (!xi.disfile) {
1693
 
                buf = libxfs_getbuf(xi.ddev, (xi.dsize - BTOBB(65536)), 
1694
 
                                    BTOBB(65536));
1695
 
                bzero(XFS_BUF_PTR(buf), 65536);
1696
 
                libxfs_writebuf(buf, 1);
 
1979
                buf = libxfs_getbuf(xi.ddev, (xi.dsize - BTOBB(WHACK_SIZE)), 
 
1980
                                    BTOBB(WHACK_SIZE));
 
1981
                bzero(XFS_BUF_PTR(buf), WHACK_SIZE);
 
1982
                libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1697
1983
        }
1698
1984
 
1699
1985
        /*
1702
1988
        if (loginternal)
1703
1989
                xi.logdev = xi.ddev;
1704
1990
        if (xi.logdev)
1705
 
                libxfs_log_clear(
1706
 
                    xi.logdev, 
1707
 
                    XFS_FSB_TO_DADDR(mp, logstart),
1708
 
                    (xfs_extlen_t)XFS_FSB_TO_BB(mp, logblocks),
1709
 
                    &sbp->sb_uuid,
1710
 
                    XLOG_FMT);
 
1991
                libxfs_log_clear(xi.logdev, XFS_FSB_TO_DADDR(mp, logstart),
 
1992
                        (xfs_extlen_t)XFS_FSB_TO_BB(mp, logblocks),
 
1993
                        &sbp->sb_uuid, logversion, lsunit, XLOG_FMT);
1711
1994
 
1712
1995
        mp = libxfs_mount(mp, sbp, xi.ddev, xi.logdev, xi.rtdev, 1);
1713
 
        if (!mp) {
1714
 
                fprintf(stderr, "%s: mount initialization failed\n", progname);
1715
 
                exit(1);
1716
 
        }
1717
 
        if (xi.logdev &&
1718
 
            XFS_FSB_TO_B(mp, logblocks) <
1719
 
            XFS_MIN_LOG_FACTOR * max_trans_res(mp)) {
1720
 
                fprintf(stderr, "%s: log size (%lld) is too small for "
1721
 
                                "transaction reservations\n",
1722
 
                        progname, (long long)logblocks);
 
1996
        if (mp == NULL) {
 
1997
                fprintf(stderr, _("%s: filesystem failed to initialize\n"),
 
1998
                        progname);
1723
1999
                exit(1);
1724
2000
        }
1725
2001
 
1728
2004
                 * Superblock.
1729
2005
                 */
1730
2006
                buf = libxfs_getbuf(xi.ddev,
1731
 
                                XFS_AG_DADDR(mp, agno, XFS_SB_DADDR), 1);
1732
 
                bzero(XFS_BUF_PTR(buf), BBSIZE);
1733
 
                libxfs_xlate_sb(XFS_BUF_PTR(buf), sbp, -1, ARCH_CONVERT,
 
2007
                                XFS_AG_DADDR(mp, agno, XFS_SB_DADDR),
 
2008
                                XFS_FSS_TO_BB(mp, 1));
 
2009
                bzero(XFS_BUF_PTR(buf), sectorsize);
 
2010
                libxfs_xlate_sb(XFS_BUF_PTR(buf), sbp, -1, ARCH_CONVERT,
1734
2011
                                XFS_SB_ALL_BITS);
1735
 
                libxfs_writebuf(buf, 1);
 
2012
                libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1736
2013
 
1737
2014
                /*
1738
2015
                 * AG header block: freespace
1739
2016
                 */
1740
2017
                buf = libxfs_getbuf(mp->m_dev,
1741
 
                                XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR), 1);
 
2018
                                XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
 
2019
                                XFS_FSS_TO_BB(mp, 1));
1742
2020
                agf = XFS_BUF_TO_AGF(buf);
1743
 
                bzero(agf, BBSIZE);
 
2021
                bzero(agf, sectorsize);
1744
2022
                if (agno == agcount - 1)
1745
2023
                        agsize = dblocks - (xfs_drfsbno_t)(agno * agsize);
1746
2024
                INT_SET(agf->agf_magicnum, ARCH_CONVERT, XFS_AGF_MAGIC);
1754
2032
                INT_SET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT, 1);
1755
2033
                INT_SET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT, 1);
1756
2034
                INT_SET(agf->agf_flfirst, ARCH_CONVERT, 0);
1757
 
                INT_SET(agf->agf_fllast, ARCH_CONVERT, XFS_AGFL_SIZE - 1);
 
2035
                INT_SET(agf->agf_fllast, ARCH_CONVERT, XFS_AGFL_SIZE(mp) - 1);
1758
2036
                INT_SET(agf->agf_flcount, ARCH_CONVERT, 0);
1759
2037
                nbmblocks = (xfs_extlen_t)(agsize - XFS_PREALLOC_BLOCKS(mp));
1760
2038
                INT_SET(agf->agf_freeblks, ARCH_CONVERT, nbmblocks);
1766
2044
                }
1767
2045
                if (XFS_MIN_FREELIST(agf, mp) > worst_freelist)
1768
2046
                        worst_freelist = XFS_MIN_FREELIST(agf, mp);
1769
 
                libxfs_writebuf(buf, 1);
 
2047
                libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1770
2048
 
1771
2049
                /*
1772
2050
                 * AG header block: inodes
1773
2051
                 */
1774
2052
                buf = libxfs_getbuf(mp->m_dev,
1775
 
                                XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR), 1);
 
2053
                                XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
 
2054
                                XFS_FSS_TO_BB(mp, 1));
1776
2055
                agi = XFS_BUF_TO_AGI(buf);
1777
 
                bzero(agi, BBSIZE);
 
2056
                bzero(agi, sectorsize);
1778
2057
                INT_SET(agi->agi_magicnum, ARCH_CONVERT, XFS_AGI_MAGIC);
1779
2058
                INT_SET(agi->agi_versionnum, ARCH_CONVERT, XFS_AGI_VERSION);
1780
2059
                INT_SET(agi->agi_seqno, ARCH_CONVERT, agno);
1785
2064
                INT_SET(agi->agi_freecount, ARCH_CONVERT, 0);
1786
2065
                INT_SET(agi->agi_newino, ARCH_CONVERT, NULLAGINO);
1787
2066
                INT_SET(agi->agi_dirino, ARCH_CONVERT, NULLAGINO);
1788
 
                for (i = 0; i < XFS_AGI_UNLINKED_BUCKETS; i++)
1789
 
                        INT_SET(agi->agi_unlinked[i], ARCH_CONVERT, NULLAGINO);
1790
 
                libxfs_writebuf(buf, 1);
 
2067
                for (c = 0; c < XFS_AGI_UNLINKED_BUCKETS; c++)
 
2068
                        INT_SET(agi->agi_unlinked[c], ARCH_CONVERT, NULLAGINO);
 
2069
                libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1791
2070
 
1792
2071
                /*
1793
2072
                 * BNO btree root block
1810
2089
                        if (lalign) {
1811
2090
                                /*
1812
2091
                                 * Have to insert two records
 
2092
                                 * Insert pad record for stripe align of log
1813
2093
                                 */
1814
2094
                                INT_SET(arec->ar_blockcount, ARCH_CONVERT, 
1815
2095
                                        (xfs_extlen_t)(XFS_FSB_TO_AGBNO(
1817
2097
                                        - (INT_GET(arec->ar_startblock,
1818
2098
                                                ARCH_CONVERT))));
1819
2099
                                nrec = arec + 1;
 
2100
                                /*
 
2101
                                 * Insert record at start of internal log
 
2102
                                 */
1820
2103
                                INT_SET(nrec->ar_startblock, ARCH_CONVERT,
1821
2104
                                        INT_GET(arec->ar_startblock,
1822
2105
                                                ARCH_CONVERT) +
1825
2108
                                arec = nrec;
1826
2109
                                INT_MOD(block->bb_numrecs, ARCH_CONVERT, 1);
1827
2110
                        } 
 
2111
                        /*
 
2112
                         * Change record start to after the internal log
 
2113
                         */
1828
2114
                        INT_MOD(arec->ar_startblock, ARCH_CONVERT, logblocks);
1829
2115
                } 
1830
2116
                INT_SET(arec->ar_blockcount, ARCH_CONVERT,
1831
2117
                        (xfs_extlen_t)(agsize -
1832
2118
                                INT_GET(arec->ar_startblock, ARCH_CONVERT)));
1833
 
                libxfs_writebuf(buf, 1);
 
2119
                libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1834
2120
 
1835
2121
                /*
1836
2122
                 * CNT btree root block
1867
2153
                }       
1868
2154
                INT_SET(arec->ar_blockcount, ARCH_CONVERT, (xfs_extlen_t)
1869
2155
                        (agsize - INT_GET(arec->ar_startblock, ARCH_CONVERT)));
1870
 
                libxfs_writebuf(buf, 1);
 
2156
                libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
2157
 
1871
2158
                /*
1872
2159
                 * INO btree root block
1873
2160
                 */
1881
2168
                INT_SET(block->bb_numrecs, ARCH_CONVERT, 0);
1882
2169
                INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK);
1883
2170
                INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK);
1884
 
                libxfs_writebuf(buf, 1);
 
2171
                libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1885
2172
        }
1886
2173
 
1887
2174
        /*
1890
2177
        buf = libxfs_getbuf(mp->m_dev,
1891
2178
                (xfs_daddr_t)XFS_FSB_TO_BB(mp, dblocks - 1LL), bsize);
1892
2179
        bzero(XFS_BUF_PTR(buf), blocksize);
1893
 
        libxfs_writebuf(buf, 1);
 
2180
        libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1894
2181
 
1895
2182
        /*
1896
2183
         * Make sure we can write the last block in the realtime area.
1899
2186
                buf = libxfs_getbuf(mp->m_rtdev,
1900
2187
                                XFS_FSB_TO_BB(mp, rtblocks - 1LL), bsize);
1901
2188
                bzero(XFS_BUF_PTR(buf), blocksize);
1902
 
                libxfs_writebuf(buf, 1);
 
2189
                libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1903
2190
        }
 
2191
 
1904
2192
        /*
1905
2193
         * BNO, CNT free block list
1906
2194
         */
1913
2201
                args.mp = mp;
1914
2202
                args.agno = agno;
1915
2203
                args.alignment = 1;
1916
 
                args.minalignslop = UINT_MAX;
1917
2204
                args.pag = &mp->m_perag[agno];
1918
 
                if ((i = libxfs_trans_reserve(tp, worst_freelist, 0, 0, 0, 0)))
1919
 
                        res_failed(i);
 
2205
                if ((c = libxfs_trans_reserve(tp, worst_freelist, 0, 0, 0, 0)))
 
2206
                        res_failed(c);
1920
2207
                libxfs_alloc_fix_freelist(&args, 0);
1921
2208
                libxfs_trans_commit(tp, 0, NULL);
1922
2209
        }
 
2210
 
1923
2211
        /*
1924
2212
         * Allocate the root inode and anything else in the proto file.
1925
2213
         */
1927
2215
        parseproto(mp, NULL, &protostring, NULL);
1928
2216
 
1929
2217
        /*
1930
 
         * protect ourselves against possible stupidity
 
2218
         * Protect ourselves against possible stupidity
1931
2219
         */
1932
2220
        if (XFS_INO_TO_AGNO(mp, mp->m_sb.sb_rootino) != 0) {
1933
 
                fprintf(stderr, "%s: root inode not created in AG 0, "
1934
 
                                "created in AG %u",
 
2221
                fprintf(stderr,
 
2222
                        _("%s: root inode created in AG %u, not AG 0\n"),
1935
2223
                        progname, XFS_INO_TO_AGNO(mp, mp->m_sb.sb_rootino));
1936
2224
                exit(1);
1937
2225
        }
1938
2226
 
1939
2227
        /*
1940
 
         * write out multiple copies of superblocks with the rootinode field set
 
2228
         * Write out multiple secondary superblocks with rootinode field set
1941
2229
         */
1942
2230
        if (mp->m_sb.sb_agcount > 1) {
1943
2231
                /*
1946
2234
                buf = libxfs_readbuf(mp->m_dev,
1947
2235
                                XFS_AGB_TO_DADDR(mp, mp->m_sb.sb_agcount-1,
1948
2236
                                        XFS_SB_DADDR),
1949
 
                                BTOBB(mp->m_sb.sb_sectsize), 1);
 
2237
                                XFS_FSS_TO_BB(mp, 1),
 
2238
                                LIBXFS_EXIT_ON_FAILURE);
1950
2239
                INT_SET((XFS_BUF_TO_SBP(buf))->sb_rootino,
1951
2240
                                ARCH_CONVERT, mp->m_sb.sb_rootino);
1952
 
                libxfs_writebuf(buf, 1);
 
2241
                libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1953
2242
                /*
1954
2243
                 * and one in the middle for luck
1955
2244
                 */
1957
2246
                        buf = libxfs_readbuf(mp->m_dev,
1958
2247
                                XFS_AGB_TO_DADDR(mp, (mp->m_sb.sb_agcount-1)/2,
1959
2248
                                        XFS_SB_DADDR),
1960
 
                                BTOBB(mp->m_sb.sb_sectsize), 1);
 
2249
                                XFS_FSS_TO_BB(mp, 1),
 
2250
                                LIBXFS_EXIT_ON_FAILURE);
1961
2251
                        INT_SET((XFS_BUF_TO_SBP(buf))->sb_rootino,
1962
2252
                                ARCH_CONVERT, mp->m_sb.sb_rootino);
1963
 
                        libxfs_writebuf(buf, 1);
 
2253
                        libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1964
2254
                }
1965
2255
        }
1966
2256
 
1967
2257
        /*
1968
2258
         * Mark the filesystem ok.
1969
2259
         */
1970
 
        buf = libxfs_getsb(mp, 1);
 
2260
        buf = libxfs_getsb(mp, LIBXFS_EXIT_ON_FAILURE);
1971
2261
        (XFS_BUF_TO_SBP(buf))->sb_inprogress = 0;
1972
 
        libxfs_writebuf(buf, 1);
 
2262
        libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
1973
2263
 
1974
2264
        libxfs_umount(mp);
1975
2265
        if (xi.rtdev)
1983
2273
 
1984
2274
static void
1985
2275
conflict(
1986
 
        char    opt,
1987
 
        char    *tab[],
1988
 
        int     oldidx,
1989
 
        int     newidx)
 
2276
        char            opt,
 
2277
        char            *tab[],
 
2278
        int             oldidx,
 
2279
        int             newidx)
1990
2280
{
1991
 
        fprintf(stderr, "Cannot specify both -%c %s and -%c %s\n",
 
2281
        fprintf(stderr, _("Cannot specify both -%c %s and -%c %s\n"),
1992
2282
                opt, tab[oldidx], opt, tab[newidx]);
1993
2283
        usage();
1994
2284
}
1996
2286
 
1997
2287
static void
1998
2288
illegal(
1999
 
        char    *value,
2000
 
        char    *opt)
 
2289
        char            *value,
 
2290
        char            *opt)
2001
2291
{
2002
 
        fprintf(stderr, "Illegal value %s for -%s option\n", value, opt);
 
2292
        fprintf(stderr, _("Illegal value %s for -%s option\n"), value, opt);
2003
2293
        usage();
2004
2294
}
2005
2295
 
2012
2302
 
2013
2303
static void
2014
2304
reqval(
2015
 
        char    opt,
2016
 
        char    *tab[],
2017
 
        int     idx)
 
2305
        char            opt,
 
2306
        char            *tab[],
 
2307
        int             idx)
2018
2308
{
2019
 
        fprintf(stderr, "-%c %s option requires a value\n", opt, tab[idx]);
 
2309
        fprintf(stderr, _("-%c %s option requires a value\n"), opt, tab[idx]);
2020
2310
        usage();
2021
2311
}
2022
2312
 
2023
2313
static void
2024
2314
respec(
2025
 
        char    opt,
2026
 
        char    *tab[],
2027
 
        int     idx)
 
2315
        char            opt,
 
2316
        char            *tab[],
 
2317
        int             idx)
2028
2318
{
2029
2319
        fprintf(stderr, "-%c ", opt);
2030
2320
        if (tab)
2031
2321
                fprintf(stderr, "%s ", tab[idx]);
2032
 
        fprintf(stderr, "option respecified\n");
 
2322
        fprintf(stderr, _("option respecified\n"));
2033
2323
        usage();
2034
2324
}
2035
2325
 
2036
2326
static void
2037
2327
unknown(
2038
 
        char    opt,
2039
 
        char    *s)
 
2328
        char            opt,
 
2329
        char            *s)
2040
2330
{
2041
 
        fprintf(stderr, "unknown option -%c %s\n", opt, s);
 
2331
        fprintf(stderr, _("unknown option -%c %s\n"), opt, s);
2042
2332
        usage();
2043
2333
}
2044
2334
 
2045
 
static int
2046
 
max_trans_res(
2047
 
        xfs_mount_t                     *mp)
 
2335
/*
 
2336
 * isdigits -- returns 1 if string contains nothing but [0-9], 0 otherwise
 
2337
 */
 
2338
int
 
2339
isdigits(
 
2340
        char            *str)
2048
2341
{
2049
 
        uint                            *p;
2050
 
        int                             rval;
2051
 
        xfs_trans_reservations_t        *tr;
2052
 
 
2053
 
        tr = &mp->m_reservations;
2054
 
 
2055
 
        for (rval = 0, p = (uint *)tr; p < (uint *)(tr + 1); p++) {
2056
 
                if ((int)*p > rval)
2057
 
                        rval = (int)*p;
 
2342
        int             i;
 
2343
        int             n = strlen(str);
 
2344
 
 
2345
        for (i = 0; i < n; i++) {
 
2346
                if (!isdigit((int)str[i]))
 
2347
                        return 0;
2058
2348
        }
2059
 
        return rval;
 
2349
        return 1;
2060
2350
}
2061
2351
 
2062
2352
long long
2063
2353
cvtnum(
2064
2354
        int             blocksize,
 
2355
        int             sectorsize,
2065
2356
        char            *s)
2066
2357
{
2067
2358
        long long       i;
2068
2359
        char            *sp;
2069
 
        extern void     usage(void);
2070
2360
 
2071
2361
        i = strtoll(s, &sp, 0);
2072
2362
        if (i == 0 && sp == s)
2077
2367
        if (*sp == 'b' && sp[1] == '\0') {
2078
2368
                if (blocksize)
2079
2369
                        return i * blocksize;
2080
 
 
2081
 
                fprintf(stderr, "blocksize not available yet.\n");
 
2370
                fprintf(stderr, _("blocksize not available yet.\n"));
2082
2371
                usage();
2083
2372
        }
2084
 
 
 
2373
        if (*sp == 's' && sp[1] == '\0') {
 
2374
                if (sectorsize)
 
2375
                        return i * sectorsize;
 
2376
                return i * BBSIZE;
 
2377
        }
2085
2378
        if (*sp == 'k' && sp[1] == '\0')
2086
2379
                return 1024LL * i;
2087
2380
        if (*sp == 'm' && sp[1] == '\0')
2088
2381
                return 1024LL * 1024LL * i;
2089
2382
        if (*sp == 'g' && sp[1] == '\0')
2090
2383
                return 1024LL * 1024LL * 1024LL * i;
 
2384
        if (*sp == 't' && sp[1] == '\0')
 
2385
                return 1024LL * 1024LL * 1024LL * 1024LL * i;
 
2386
        if (*sp == 'p' && sp[1] == '\0')
 
2387
                return 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * i;
2091
2388
        return -1LL;
2092
2389
}
2093
2390
 
2094
2391
void
2095
 
usage(void)
 
2392
usage( void )
2096
2393
{
2097
 
        fprintf(stderr, "Usage: %s\n\
 
2394
        fprintf(stderr, _("Usage: %s\n\
2098
2395
/* blocksize */         [-b log=n|size=num]\n\
2099
2396
/* data subvol */       [-d agcount=n,agsize=n,file,name=xxx,size=num,\n\
2100
 
                            sunit=value,swidth=value,unwritten=0|1,\n\
2101
 
                            su=value,sw=value]\n\
 
2397
                            (sunit=value,swidth=value|su=num,sw=num),\n\
 
2398
                            sectlog=n|sectsize=num,unwritten=0|1]\n\
2102
2399
/* inode size */        [-i log=n|perblock=n|size=num,maxpct=n]\n\
2103
 
/* log subvol */        [-l agnum=n,internal,size=num,logdev=xxx]\n\
2104
 
/* naming */            [-n log=n|size=num|version=n]\n\
 
2400
/* log subvol */        [-l agnum=n,internal,size=num,logdev=xxx,version=n\n\
 
2401
                            sunit=value|su=num,sectlog=n|sectsize=num]\n\
2105
2402
/* label */             [-L label (maximum 12 characters)]\n\
 
2403
/* naming */            [-n log=n|size=num,version=n]\n\
2106
2404
/* prototype file */    [-p fname]\n\
2107
2405
/* quiet */             [-q]\n\
 
2406
/* realtime subvol */   [-r extsize=num,size=num,rtdev=xxx]\n\
 
2407
/* sectorsize */        [-s log=n|size=num]\n\
2108
2408
/* version */           [-V]\n\
2109
 
/* realtime subvol */   [-r extsize=num,size=num,rtdev=xxx]\n\
2110
2409
                        devicename\n\
2111
2410
<devicename> is required unless -d name=xxx is given.\n\
2112
 
Internal log by default, size is scaled from 1,000 blocks to 32,768 blocks\n\
2113
 
based on the filesystem size.  Default log reaches its largest size at 1TB.\n\
2114
 
This can be overridden with the -l options or using a volume manager with a\n\
2115
 
log subvolume.\n\
2116
 
<num> is xxx (bytes), or xxxb (blocks), or xxxk (xxx KB), or xxxm (xxx MB)\n\
2117
 
<value> is xxx (512 blocks).\n",
 
2411
<num> is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB),\n\
 
2412
      xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB).\n\
 
2413
<value> is xxx (512 byte blocks).\n"),
2118
2414
                progname);
2119
2415
        exit(1);
2120
2416
}