~ubuntu-branches/debian/jessie/btrfs-tools/jessie

« back to all changes in this revision

Viewing changes to mkfs.c

  • Committer: Package Import Robot
  • Author(s): Dimitri John Ledkov
  • Date: 2014-09-21 02:05:14 UTC
  • mfrom: (1.2.13) (6.1.38 sid)
  • Revision ID: package-import@ubuntu.com-20140921020514-kx4b23aw4grvevrc
Tags: 3.16-1
* New upstream release.
* Add asciidoc & xmlto build dependencies.
* Disable test-suites for now, should be run as autopkgtests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
210
210
static int create_raid_groups(struct btrfs_trans_handle *trans,
211
211
                              struct btrfs_root *root, u64 data_profile,
212
212
                              int data_profile_opt, u64 metadata_profile,
213
 
                              int metadata_profile_opt, int mixed, int ssd)
 
213
                              int mixed)
214
214
{
215
215
        u64 num_devices = btrfs_super_num_devices(root->fs_info->super_copy);
216
216
        int ret;
288
288
        fprintf(stderr, "\t -r --rootdir the source directory\n");
289
289
        fprintf(stderr, "\t -K --nodiscard do not perform whole device TRIM\n");
290
290
        fprintf(stderr, "\t -O --features comma separated list of filesystem features\n");
 
291
        fprintf(stderr, "\t -U --uuid specify the filesystem UUID\n");
291
292
        fprintf(stderr, "\t -V --version print the mkfs.btrfs version and exit\n");
292
293
        fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
293
294
        exit(1);
350
351
        { "version", 0, NULL, 'V' },
351
352
        { "rootdir", 1, NULL, 'r' },
352
353
        { "nodiscard", 0, NULL, 'K' },
353
 
        { "features", 0, NULL, 'O' },
 
354
        { "features", 1, NULL, 'O' },
 
355
        { "uuid", required_argument, NULL, 'U' },
354
356
        { NULL, 0, NULL, 0}
355
357
};
356
358
 
1273
1275
        int dev_cnt = 0;
1274
1276
        int saved_optind;
1275
1277
        char estr[100];
 
1278
        char *fs_uuid = NULL;
1276
1279
        u64 features = DEFAULT_MKFS_FEATURES;
1277
1280
 
1278
1281
        while(1) {
1279
1282
                int c;
1280
 
                c = getopt_long(ac, av, "A:b:fl:n:s:m:d:L:O:r:VMK",
 
1283
                c = getopt_long(ac, av, "A:b:fl:n:s:m:d:L:O:r:U:VMK",
1281
1284
                                long_options, &option_index);
1282
1285
                if (c < 0)
1283
1286
                        break;
1332
1335
                                break;
1333
1336
                        case 'b':
1334
1337
                                block_count = parse_size(optarg);
1335
 
                                if (block_count <= 1024*1024*1024) {
1336
 
                                        printf("SMALL VOLUME: forcing mixed "
1337
 
                                               "metadata/data groups\n");
 
1338
                                if (block_count <= BTRFS_MKFS_SMALL_VOLUME_SIZE) {
 
1339
                                        fprintf(stdout,
 
1340
                                "SMALL VOLUME: forcing mixed metadata/data groups\n");
1338
1341
                                        mixed = 1;
1339
1342
                                }
1340
1343
                                zero_end = 0;
1346
1349
                                source_dir = optarg;
1347
1350
                                source_dir_set = 1;
1348
1351
                                break;
 
1352
                        case 'U':
 
1353
                                fs_uuid = optarg;
 
1354
                                break;
1349
1355
                        case 'K':
1350
1356
                                discard = 0;
1351
1357
                                break;
1368
1374
                        "The -r option is limited to a single device\n");
1369
1375
                exit(1);
1370
1376
        }
 
1377
 
 
1378
        if (fs_uuid) {
 
1379
                uuid_t dummy_uuid;
 
1380
 
 
1381
                if (uuid_parse(fs_uuid, dummy_uuid) != 0) {
 
1382
                        fprintf(stderr, "could not parse UUID: %s\n", fs_uuid);
 
1383
                        exit(1);
 
1384
                }
 
1385
                if (!test_uuid_unique(fs_uuid)) {
 
1386
                        fprintf(stderr, "non-unique UUID: %s\n", fs_uuid);
 
1387
                        exit(1);
 
1388
                }
 
1389
        }
 
1390
        
1371
1391
        while (dev_cnt-- > 0) {
1372
1392
                file = av[optind++];
1373
1393
                if (is_block_device(file))
1431
1451
                }
1432
1452
        }
1433
1453
 
 
1454
        /* Check device/block_count after the leafsize is determined */
 
1455
        if (block_count && block_count < btrfs_min_dev_size(leafsize)) {
 
1456
                fprintf(stderr,
 
1457
                        "Size '%llu' is too small to make a usable filesystem\n",
 
1458
                        block_count);
 
1459
                fprintf(stderr,
 
1460
                        "Minimum size for btrfs filesystem is %llu\n",
 
1461
                        btrfs_min_dev_size(leafsize));
 
1462
                exit(1);
 
1463
        }
 
1464
        for (i = saved_optind; i < saved_optind + dev_cnt; i++) {
 
1465
                char *path;
 
1466
 
 
1467
                path = av[i];
 
1468
                ret = test_minimum_size(path, leafsize);
 
1469
                if (ret < 0) {
 
1470
                        fprintf(stderr, "Failed to check size for '%s': %s\n",
 
1471
                                path, strerror(-ret));
 
1472
                        exit (1);
 
1473
                }
 
1474
                if (ret > 0) {
 
1475
                        fprintf(stderr,
 
1476
                                "'%s' is too small to make a usable filesystem\n",
 
1477
                                path);
 
1478
                        fprintf(stderr,
 
1479
                                "Minimum size for each btrfs device is %llu.\n",
 
1480
                                btrfs_min_dev_size(leafsize));
 
1481
                        exit(1);
 
1482
                }
 
1483
        }
1434
1484
        ret = test_num_disk_vs_raid(metadata_profile, data_profile,
1435
1485
                        dev_cnt, mixed, estr);
1436
1486
        if (ret) {
1439
1489
        }
1440
1490
 
1441
1491
        /* if we are here that means all devs are good to btrfsify */
1442
 
        printf("\nWARNING! - %s IS EXPERIMENTAL\n", BTRFS_BUILD_VERSION);
1443
 
        printf("WARNING! - see http://btrfs.wiki.kernel.org before using\n\n");
 
1492
        printf("%s\n", BTRFS_BUILD_VERSION);
 
1493
        printf("See http://btrfs.wiki.kernel.org for more information.\n\n");
1444
1494
 
1445
1495
        dev_cnt--;
1446
1496
 
1514
1564
 
1515
1565
        process_fs_features(features);
1516
1566
 
1517
 
        ret = make_btrfs(fd, file, label, blocks, dev_block_count,
 
1567
        ret = make_btrfs(fd, file, label, fs_uuid, blocks, dev_block_count,
1518
1568
                         nodesize, leafsize,
1519
1569
                         sectorsize, stripesize, features);
1520
1570
        if (ret) {
1543
1593
 
1544
1594
        btrfs_register_one_device(file);
1545
1595
 
1546
 
        zero_end = 1;
1547
1596
        while (dev_cnt-- > 0) {
1548
1597
                int old_mixed = mixed;
1549
1598
 
1586
1635
        if (!source_dir_set) {
1587
1636
                ret = create_raid_groups(trans, root, data_profile,
1588
1637
                                 data_profile_opt, metadata_profile,
1589
 
                                 metadata_profile_opt, mixed, ssd);
 
1638
                                 mixed);
1590
1639
                BUG_ON(ret);
1591
1640
        }
1592
1641
 
1598
1647
            label, first_file, nodesize, leafsize, sectorsize,
1599
1648
            pretty_size(btrfs_super_total_bytes(root->fs_info->super_copy)));
1600
1649
 
1601
 
        printf("%s\n", BTRFS_BUILD_VERSION);
1602
1650
        btrfs_commit_transaction(trans, root);
1603
1651
 
1604
1652
        if (source_dir_set) {