btrfs-progs: mkfs, deprecate leafsize and clean up the code

Using the --leafsize will issue a warning. Replace leafsize with
nodesize in the mkfs-related code.

Signed-off-by: David Sterba <dsterba@suse.cz>
master
David Sterba 2015-02-02 15:51:15 +01:00
parent 445ed1f11c
commit a297698edc
4 changed files with 71 additions and 75 deletions

View File

@ -2298,7 +2298,7 @@ static int do_convert(const char *devname, int datacsum, int packing, int noxatt
fprintf(stderr, "filetype feature is missing\n"); fprintf(stderr, "filetype feature is missing\n");
goto fail; goto fail;
} }
if (btrfs_check_node_or_leaf_size(nodesize, blocksize)) if (btrfs_check_nodesize(nodesize, blocksize))
goto fail; goto fail;
blocks_per_node = nodesize / blocksize; blocks_per_node = nodesize / blocksize;
ret = -blocks_per_node; ret = -blocks_per_node;
@ -2322,7 +2322,7 @@ static int do_convert(const char *devname, int datacsum, int packing, int noxatt
goto fail; goto fail;
} }
ret = make_btrfs(fd, devname, ext2_fs->super->s_volume_name, ret = make_btrfs(fd, devname, ext2_fs->super->s_volume_name,
NULL, blocks, total_bytes, nodesize, nodesize, NULL, blocks, total_bytes, nodesize,
blocksize, blocksize, 0); blocksize, blocksize, 0);
if (ret) { if (ret) {
fprintf(stderr, "unable to create initial ctree: %s\n", fprintf(stderr, "unable to create initial ctree: %s\n",

42
mkfs.c
View File

@ -1207,17 +1207,16 @@ int main(int ac, char **av)
u64 alloc_start = 0; u64 alloc_start = 0;
u64 metadata_profile = 0; u64 metadata_profile = 0;
u64 data_profile = 0; u64 data_profile = 0;
u32 leafsize = max_t(u32, sysconf(_SC_PAGESIZE), u32 nodesize = max_t(u32, sysconf(_SC_PAGESIZE),
BTRFS_MKFS_DEFAULT_NODE_SIZE); BTRFS_MKFS_DEFAULT_NODE_SIZE);
u32 sectorsize = 4096; u32 sectorsize = 4096;
u32 nodesize = leafsize;
u32 stripesize = 4096; u32 stripesize = 4096;
int zero_end = 1; int zero_end = 1;
int fd; int fd;
int ret; int ret;
int i; int i;
int mixed = 0; int mixed = 0;
int leaf_forced = 0; int nodesize_forced = 0;
int data_profile_opt = 0; int data_profile_opt = 0;
int metadata_profile_opt = 0; int metadata_profile_opt = 0;
int discard = 1; int discard = 1;
@ -1273,10 +1272,11 @@ int main(int ac, char **av)
data_profile_opt = 1; data_profile_opt = 1;
break; break;
case 'l': case 'l':
fprintf(stderr,
"WARNING: --leafsize is deprecated, use --nodesize\n");
case 'n': case 'n':
nodesize = parse_size(optarg); nodesize = parse_size(optarg);
leafsize = parse_size(optarg); nodesize_forced = 1;
leaf_forced = 1;
break; break;
case 'L': case 'L':
label = parse_label(optarg); label = parse_label(optarg);
@ -1337,9 +1337,7 @@ int main(int ac, char **av)
} }
} }
sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE)); sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE));
if (btrfs_check_node_or_leaf_size(leafsize, sectorsize)) if (btrfs_check_nodesize(nodesize, sectorsize))
exit(1);
if (btrfs_check_node_or_leaf_size(nodesize, sectorsize))
exit(1); exit(1);
saved_optind = optind; saved_optind = optind;
dev_cnt = ac - optind; dev_cnt = ac - optind;
@ -1405,7 +1403,7 @@ int main(int ac, char **av)
BTRFS_BLOCK_GROUP_RAID0 : 0; /* raid0 or single */ BTRFS_BLOCK_GROUP_RAID0 : 0; /* raid0 or single */
} }
} else { } else {
u32 best_leafsize = max_t(u32, sysconf(_SC_PAGESIZE), sectorsize); u32 best_nodesize = max_t(u32, sysconf(_SC_PAGESIZE), sectorsize);
if (metadata_profile_opt || data_profile_opt) { if (metadata_profile_opt || data_profile_opt) {
if (metadata_profile != data_profile) { if (metadata_profile != data_profile) {
@ -1415,34 +1413,33 @@ int main(int ac, char **av)
} }
} }
if (!leaf_forced) { if (!nodesize_forced) {
leafsize = best_leafsize; nodesize = best_nodesize;
nodesize = best_leafsize; if (btrfs_check_nodesize(nodesize, sectorsize))
if (btrfs_check_node_or_leaf_size(leafsize, sectorsize))
exit(1); exit(1);
} }
if (leafsize != sectorsize) { if (nodesize != sectorsize) {
fprintf(stderr, "Error: mixed metadata/data block groups " fprintf(stderr, "Error: mixed metadata/data block groups "
"require metadata blocksizes equal to the sectorsize\n"); "require metadata blocksizes equal to the sectorsize\n");
exit(1); exit(1);
} }
} }
/* Check device/block_count after the leafsize is determined */ /* Check device/block_count after the nodesize is determined */
if (block_count && block_count < btrfs_min_dev_size(leafsize)) { if (block_count && block_count < btrfs_min_dev_size(nodesize)) {
fprintf(stderr, fprintf(stderr,
"Size '%llu' is too small to make a usable filesystem\n", "Size '%llu' is too small to make a usable filesystem\n",
block_count); block_count);
fprintf(stderr, fprintf(stderr,
"Minimum size for btrfs filesystem is %llu\n", "Minimum size for btrfs filesystem is %llu\n",
btrfs_min_dev_size(leafsize)); btrfs_min_dev_size(nodesize));
exit(1); exit(1);
} }
for (i = saved_optind; i < saved_optind + dev_cnt; i++) { for (i = saved_optind; i < saved_optind + dev_cnt; i++) {
char *path; char *path;
path = av[i]; path = av[i];
ret = test_minimum_size(path, leafsize); ret = test_minimum_size(path, nodesize);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Failed to check size for '%s': %s\n", fprintf(stderr, "Failed to check size for '%s': %s\n",
path, strerror(-ret)); path, strerror(-ret));
@ -1454,7 +1451,7 @@ int main(int ac, char **av)
path); path);
fprintf(stderr, fprintf(stderr,
"Minimum size for each btrfs device is %llu.\n", "Minimum size for each btrfs device is %llu.\n",
btrfs_min_dev_size(leafsize)); btrfs_min_dev_size(nodesize));
exit(1); exit(1);
} }
} }
@ -1524,7 +1521,7 @@ int main(int ac, char **av)
blocks[0] = BTRFS_SUPER_INFO_OFFSET; blocks[0] = BTRFS_SUPER_INFO_OFFSET;
for (i = 1; i < 7; i++) { for (i = 1; i < 7; i++) {
blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 + blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 +
leafsize * i; nodesize * i;
} }
/* /*
@ -1542,8 +1539,7 @@ int main(int ac, char **av)
process_fs_features(features); process_fs_features(features);
ret = make_btrfs(fd, file, label, fs_uuid, blocks, dev_block_count, ret = make_btrfs(fd, file, label, fs_uuid, blocks, dev_block_count,
nodesize, leafsize, nodesize, sectorsize, stripesize, features);
sectorsize, stripesize, features);
if (ret) { if (ret) {
fprintf(stderr, "error during mkfs: %s\n", strerror(-ret)); fprintf(stderr, "error during mkfs: %s\n", strerror(-ret));
exit(1); exit(1);
@ -1621,7 +1617,7 @@ raid_groups:
printf("fs created label %s on %s\n\tnodesize %u leafsize %u " printf("fs created label %s on %s\n\tnodesize %u leafsize %u "
"sectorsize %u size %s\n", "sectorsize %u size %s\n",
label, first_file, nodesize, leafsize, sectorsize, label, first_file, nodesize, nodesize, sectorsize,
pretty_size(btrfs_super_total_bytes(root->fs_info->super_copy))); pretty_size(btrfs_super_total_bytes(root->fs_info->super_copy)));
btrfs_commit_transaction(trans, root); btrfs_commit_transaction(trans, root);

96
utils.c
View File

@ -171,7 +171,7 @@ int test_uuid_unique(char *fs_uuid)
int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid, int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
u64 blocks[7], u64 num_bytes, u32 nodesize, u64 blocks[7], u64 num_bytes, u32 nodesize,
u32 leafsize, u32 sectorsize, u32 stripesize, u64 features) u32 sectorsize, u32 stripesize, u64 features)
{ {
struct btrfs_super_block super; struct btrfs_super_block super;
struct extent_buffer *buf = NULL; struct extent_buffer *buf = NULL;
@ -225,9 +225,9 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
btrfs_set_super_root(&super, blocks[1]); btrfs_set_super_root(&super, blocks[1]);
btrfs_set_super_chunk_root(&super, blocks[3]); btrfs_set_super_chunk_root(&super, blocks[3]);
btrfs_set_super_total_bytes(&super, num_bytes); btrfs_set_super_total_bytes(&super, num_bytes);
btrfs_set_super_bytes_used(&super, 6 * leafsize); btrfs_set_super_bytes_used(&super, 6 * nodesize);
btrfs_set_super_sectorsize(&super, sectorsize); btrfs_set_super_sectorsize(&super, sectorsize);
btrfs_set_super_leafsize(&super, leafsize); btrfs_set_super_leafsize(&super, nodesize);
btrfs_set_super_nodesize(&super, nodesize); btrfs_set_super_nodesize(&super, nodesize);
btrfs_set_super_stripesize(&super, stripesize); btrfs_set_super_stripesize(&super, stripesize);
btrfs_set_super_csum_type(&super, BTRFS_CSUM_TYPE_CRC32); btrfs_set_super_csum_type(&super, BTRFS_CSUM_TYPE_CRC32);
@ -237,11 +237,11 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
if (label) if (label)
strncpy(super.label, label, BTRFS_LABEL_SIZE - 1); strncpy(super.label, label, BTRFS_LABEL_SIZE - 1);
buf = malloc(sizeof(*buf) + max(sectorsize, leafsize)); buf = malloc(sizeof(*buf) + max(sectorsize, nodesize));
/* create the tree of root objects */ /* create the tree of root objects */
memset(buf->data, 0, leafsize); memset(buf->data, 0, nodesize);
buf->len = leafsize; buf->len = nodesize;
btrfs_set_header_bytenr(buf, blocks[1]); btrfs_set_header_bytenr(buf, blocks[1]);
btrfs_set_header_nritems(buf, 4); btrfs_set_header_nritems(buf, 4);
btrfs_set_header_generation(buf, 1); btrfs_set_header_generation(buf, 1);
@ -260,10 +260,10 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
btrfs_set_stack_inode_generation(inode_item, 1); btrfs_set_stack_inode_generation(inode_item, 1);
btrfs_set_stack_inode_size(inode_item, 3); btrfs_set_stack_inode_size(inode_item, 3);
btrfs_set_stack_inode_nlink(inode_item, 1); btrfs_set_stack_inode_nlink(inode_item, 1);
btrfs_set_stack_inode_nbytes(inode_item, leafsize); btrfs_set_stack_inode_nbytes(inode_item, nodesize);
btrfs_set_stack_inode_mode(inode_item, S_IFDIR | 0755); btrfs_set_stack_inode_mode(inode_item, S_IFDIR | 0755);
btrfs_set_root_refs(&root_item, 1); btrfs_set_root_refs(&root_item, 1);
btrfs_set_root_used(&root_item, leafsize); btrfs_set_root_used(&root_item, nodesize);
btrfs_set_root_generation(&root_item, 1); btrfs_set_root_generation(&root_item, 1);
memset(&disk_key, 0, sizeof(disk_key)); memset(&disk_key, 0, sizeof(disk_key));
@ -271,7 +271,7 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
btrfs_set_disk_key_offset(&disk_key, 0); btrfs_set_disk_key_offset(&disk_key, 0);
nritems = 0; nritems = 0;
itemoff = __BTRFS_LEAF_DATA_SIZE(leafsize) - sizeof(root_item); itemoff = __BTRFS_LEAF_DATA_SIZE(nodesize) - sizeof(root_item);
btrfs_set_root_bytenr(&root_item, blocks[2]); btrfs_set_root_bytenr(&root_item, blocks[2]);
btrfs_set_disk_key_objectid(&disk_key, BTRFS_EXTENT_TREE_OBJECTID); btrfs_set_disk_key_objectid(&disk_key, BTRFS_EXTENT_TREE_OBJECTID);
btrfs_set_item_key(buf, &disk_key, nritems); btrfs_set_item_key(buf, &disk_key, nritems);
@ -320,17 +320,17 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
ret = pwrite(fd, buf->data, leafsize, blocks[1]); ret = pwrite(fd, buf->data, nodesize, blocks[1]);
if (ret != leafsize) { if (ret != nodesize) {
ret = (ret < 0 ? -errno : -EIO); ret = (ret < 0 ? -errno : -EIO);
goto out; goto out;
} }
/* create the items for the extent tree */ /* create the items for the extent tree */
memset(buf->data+sizeof(struct btrfs_header), 0, memset(buf->data + sizeof(struct btrfs_header), 0,
leafsize-sizeof(struct btrfs_header)); nodesize - sizeof(struct btrfs_header));
nritems = 0; nritems = 0;
itemoff = __BTRFS_LEAF_DATA_SIZE(leafsize); itemoff = __BTRFS_LEAF_DATA_SIZE(nodesize);
for (i = 1; i < 7; i++) { for (i = 1; i < 7; i++) {
item_size = sizeof(struct btrfs_extent_item); item_size = sizeof(struct btrfs_extent_item);
if (!skinny_metadata) if (!skinny_metadata)
@ -349,7 +349,7 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
} else { } else {
btrfs_set_disk_key_type(&disk_key, btrfs_set_disk_key_type(&disk_key,
BTRFS_EXTENT_ITEM_KEY); BTRFS_EXTENT_ITEM_KEY);
btrfs_set_disk_key_offset(&disk_key, leafsize); btrfs_set_disk_key_offset(&disk_key, nodesize);
} }
btrfs_set_item_key(buf, &disk_key, nritems); btrfs_set_item_key(buf, &disk_key, nritems);
btrfs_set_item_offset(buf, btrfs_item_nr(nritems), btrfs_set_item_offset(buf, btrfs_item_nr(nritems),
@ -379,18 +379,18 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
btrfs_set_header_owner(buf, BTRFS_EXTENT_TREE_OBJECTID); btrfs_set_header_owner(buf, BTRFS_EXTENT_TREE_OBJECTID);
btrfs_set_header_nritems(buf, nritems); btrfs_set_header_nritems(buf, nritems);
csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
ret = pwrite(fd, buf->data, leafsize, blocks[2]); ret = pwrite(fd, buf->data, nodesize, blocks[2]);
if (ret != leafsize) { if (ret != nodesize) {
ret = (ret < 0 ? -errno : -EIO); ret = (ret < 0 ? -errno : -EIO);
goto out; goto out;
} }
/* create the chunk tree */ /* create the chunk tree */
memset(buf->data+sizeof(struct btrfs_header), 0, memset(buf->data + sizeof(struct btrfs_header), 0,
leafsize-sizeof(struct btrfs_header)); nodesize - sizeof(struct btrfs_header));
nritems = 0; nritems = 0;
item_size = sizeof(*dev_item); item_size = sizeof(*dev_item);
itemoff = __BTRFS_LEAF_DATA_SIZE(leafsize) - item_size; itemoff = __BTRFS_LEAF_DATA_SIZE(nodesize) - item_size;
/* first device 1 (there is no device 0) */ /* first device 1 (there is no device 0) */
btrfs_set_disk_key_objectid(&disk_key, BTRFS_DEV_ITEMS_OBJECTID); btrfs_set_disk_key_objectid(&disk_key, BTRFS_DEV_ITEMS_OBJECTID);
@ -466,17 +466,17 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
btrfs_set_header_owner(buf, BTRFS_CHUNK_TREE_OBJECTID); btrfs_set_header_owner(buf, BTRFS_CHUNK_TREE_OBJECTID);
btrfs_set_header_nritems(buf, nritems); btrfs_set_header_nritems(buf, nritems);
csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
ret = pwrite(fd, buf->data, leafsize, blocks[3]); ret = pwrite(fd, buf->data, nodesize, blocks[3]);
if (ret != leafsize) { if (ret != nodesize) {
ret = (ret < 0 ? -errno : -EIO); ret = (ret < 0 ? -errno : -EIO);
goto out; goto out;
} }
/* create the device tree */ /* create the device tree */
memset(buf->data+sizeof(struct btrfs_header), 0, memset(buf->data + sizeof(struct btrfs_header), 0,
leafsize-sizeof(struct btrfs_header)); nodesize - sizeof(struct btrfs_header));
nritems = 0; nritems = 0;
itemoff = __BTRFS_LEAF_DATA_SIZE(leafsize) - itemoff = __BTRFS_LEAF_DATA_SIZE(nodesize) -
sizeof(struct btrfs_dev_extent); sizeof(struct btrfs_dev_extent);
btrfs_set_disk_key_objectid(&disk_key, 1); btrfs_set_disk_key_objectid(&disk_key, 1);
@ -505,33 +505,33 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
btrfs_set_header_owner(buf, BTRFS_DEV_TREE_OBJECTID); btrfs_set_header_owner(buf, BTRFS_DEV_TREE_OBJECTID);
btrfs_set_header_nritems(buf, nritems); btrfs_set_header_nritems(buf, nritems);
csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
ret = pwrite(fd, buf->data, leafsize, blocks[4]); ret = pwrite(fd, buf->data, nodesize, blocks[4]);
if (ret != leafsize) { if (ret != nodesize) {
ret = (ret < 0 ? -errno : -EIO); ret = (ret < 0 ? -errno : -EIO);
goto out; goto out;
} }
/* create the FS root */ /* create the FS root */
memset(buf->data+sizeof(struct btrfs_header), 0, memset(buf->data + sizeof(struct btrfs_header), 0,
leafsize-sizeof(struct btrfs_header)); nodesize - sizeof(struct btrfs_header));
btrfs_set_header_bytenr(buf, blocks[5]); btrfs_set_header_bytenr(buf, blocks[5]);
btrfs_set_header_owner(buf, BTRFS_FS_TREE_OBJECTID); btrfs_set_header_owner(buf, BTRFS_FS_TREE_OBJECTID);
btrfs_set_header_nritems(buf, 0); btrfs_set_header_nritems(buf, 0);
csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
ret = pwrite(fd, buf->data, leafsize, blocks[5]); ret = pwrite(fd, buf->data, nodesize, blocks[5]);
if (ret != leafsize) { if (ret != nodesize) {
ret = (ret < 0 ? -errno : -EIO); ret = (ret < 0 ? -errno : -EIO);
goto out; goto out;
} }
/* finally create the csum root */ /* finally create the csum root */
memset(buf->data+sizeof(struct btrfs_header), 0, memset(buf->data + sizeof(struct btrfs_header), 0,
leafsize-sizeof(struct btrfs_header)); nodesize - sizeof(struct btrfs_header));
btrfs_set_header_bytenr(buf, blocks[6]); btrfs_set_header_bytenr(buf, blocks[6]);
btrfs_set_header_owner(buf, BTRFS_CSUM_TREE_OBJECTID); btrfs_set_header_owner(buf, BTRFS_CSUM_TREE_OBJECTID);
btrfs_set_header_nritems(buf, 0); btrfs_set_header_nritems(buf, 0);
csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0);
ret = pwrite(fd, buf->data, leafsize, blocks[6]); ret = pwrite(fd, buf->data, nodesize, blocks[6]);
if (ret != leafsize) { if (ret != nodesize) {
ret = (ret < 0 ? -errno : -EIO); ret = (ret < 0 ? -errno : -EIO);
goto out; goto out;
} }
@ -783,7 +783,7 @@ int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
btrfs_set_stack_inode_generation(&inode_item, trans->transid); btrfs_set_stack_inode_generation(&inode_item, trans->transid);
btrfs_set_stack_inode_size(&inode_item, 0); btrfs_set_stack_inode_size(&inode_item, 0);
btrfs_set_stack_inode_nlink(&inode_item, 1); btrfs_set_stack_inode_nlink(&inode_item, 1);
btrfs_set_stack_inode_nbytes(&inode_item, root->leafsize); btrfs_set_stack_inode_nbytes(&inode_item, root->nodesize);
btrfs_set_stack_inode_mode(&inode_item, S_IFDIR | 0755); btrfs_set_stack_inode_mode(&inode_item, S_IFDIR | 0755);
btrfs_set_stack_timespec_sec(&inode_item.atime, now); btrfs_set_stack_timespec_sec(&inode_item.atime, now);
btrfs_set_stack_timespec_nsec(&inode_item.atime, 0); btrfs_set_stack_timespec_nsec(&inode_item.atime, 0);
@ -2594,7 +2594,7 @@ int find_mount_root(const char *path, char **mount_root)
return ret; return ret;
} }
int test_minimum_size(const char *file, u32 leafsize) int test_minimum_size(const char *file, u32 nodesize)
{ {
int fd; int fd;
struct stat statbuf; struct stat statbuf;
@ -2606,7 +2606,7 @@ int test_minimum_size(const char *file, u32 leafsize)
close(fd); close(fd);
return -errno; return -errno;
} }
if (btrfs_device_size(fd, &statbuf) < btrfs_min_dev_size(leafsize)) { if (btrfs_device_size(fd, &statbuf) < btrfs_min_dev_size(nodesize)) {
close(fd); close(fd);
return 1; return 1;
} }
@ -2789,22 +2789,22 @@ int btrfs_tree_search2_ioctl_supported(int fd)
return v2_supported; return v2_supported;
} }
int btrfs_check_node_or_leaf_size(u32 size, u32 sectorsize) int btrfs_check_nodesize(u32 nodesize, u32 sectorsize)
{ {
if (size < sectorsize) { if (nodesize < sectorsize) {
fprintf(stderr, fprintf(stderr,
"ERROR: Illegal nodesize (or leafsize) %u (smaller than %u)\n", "ERROR: Illegal nodesize %u (smaller than %u)\n",
size, sectorsize); nodesize, sectorsize);
return -1; return -1;
} else if (size > BTRFS_MAX_METADATA_BLOCKSIZE) { } else if (nodesize > BTRFS_MAX_METADATA_BLOCKSIZE) {
fprintf(stderr, fprintf(stderr,
"ERROR: Illegal nodesize (or leafsize) %u (larger than %u)\n", "ERROR: Illegal nodesize %u (larger than %u)\n",
size, BTRFS_MAX_METADATA_BLOCKSIZE); nodesize, BTRFS_MAX_METADATA_BLOCKSIZE);
return -1; return -1;
} else if (size & (sectorsize - 1)) { } else if (nodesize & (sectorsize - 1)) {
fprintf(stderr, fprintf(stderr,
"ERROR: Illegal nodesize (or leafsize) %u (not aligned to %u)\n", "ERROR: Illegal nodesize %u (not aligned to %u)\n",
size, sectorsize); nodesize, sectorsize);
return -1; return -1;
} }
return 0; return 0;

View File

@ -82,7 +82,7 @@ void units_set_base(unsigned *units, unsigned base);
int make_btrfs(int fd, const char *device, const char *label, int make_btrfs(int fd, const char *device, const char *label,
char *fs_uuid, u64 blocks[6], u64 num_bytes, u32 nodesize, char *fs_uuid, u64 blocks[6], u64 num_bytes, u32 nodesize,
u32 leafsize, u32 sectorsize, u32 stripesize, u64 features); u32 sectorsize, u32 stripesize, u64 features);
int btrfs_make_root_dir(struct btrfs_trans_handle *trans, int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 objectid); struct btrfs_root *root, u64 objectid);
int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret, int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
@ -210,6 +210,6 @@ static inline u64 div_factor(u64 num, int factor)
} }
int btrfs_tree_search2_ioctl_supported(int fd); int btrfs_tree_search2_ioctl_supported(int fd);
int btrfs_check_node_or_leaf_size(u32 size, u32 sectorsize); int btrfs_check_nodesize(u32 nodesize, u32 sectorsize);
#endif #endif