diff options
author | David Sterba <dsterba@suse.cz> | 2015-02-02 15:51:15 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2015-04-07 19:20:17 +0200 |
commit | a297698edce56d13628411203c7c9287c78ec990 (patch) | |
tree | 63ed24c1f6c0e79144b88af8ecc44b42af14ed0c /utils.c | |
parent | 445ed1f11ce3c49c6ac180e90dcff569757c56dc (diff) |
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>
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 96 |
1 files changed, 48 insertions, 48 deletions
@@ -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, 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 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_chunk_root(&super, blocks[3]); 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_leafsize(&super, leafsize); + btrfs_set_super_leafsize(&super, nodesize); btrfs_set_super_nodesize(&super, nodesize); btrfs_set_super_stripesize(&super, stripesize); 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) 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 */ - memset(buf->data, 0, leafsize); - buf->len = leafsize; + memset(buf->data, 0, nodesize); + buf->len = nodesize; btrfs_set_header_bytenr(buf, blocks[1]); btrfs_set_header_nritems(buf, 4); 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_size(inode_item, 3); 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_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); 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); 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_disk_key_objectid(&disk_key, BTRFS_EXTENT_TREE_OBJECTID); 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); - ret = pwrite(fd, buf->data, leafsize, blocks[1]); - if (ret != leafsize) { + ret = pwrite(fd, buf->data, nodesize, blocks[1]); + if (ret != nodesize) { ret = (ret < 0 ? -errno : -EIO); goto out; } /* create the items for the extent tree */ - memset(buf->data+sizeof(struct btrfs_header), 0, - leafsize-sizeof(struct btrfs_header)); + memset(buf->data + sizeof(struct btrfs_header), 0, + nodesize - sizeof(struct btrfs_header)); nritems = 0; - itemoff = __BTRFS_LEAF_DATA_SIZE(leafsize); + itemoff = __BTRFS_LEAF_DATA_SIZE(nodesize); for (i = 1; i < 7; i++) { item_size = sizeof(struct btrfs_extent_item); if (!skinny_metadata) @@ -349,7 +349,7 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid, } else { btrfs_set_disk_key_type(&disk_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_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_nritems(buf, nritems); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); - ret = pwrite(fd, buf->data, leafsize, blocks[2]); - if (ret != leafsize) { + ret = pwrite(fd, buf->data, nodesize, blocks[2]); + if (ret != nodesize) { ret = (ret < 0 ? -errno : -EIO); goto out; } /* create the chunk tree */ - memset(buf->data+sizeof(struct btrfs_header), 0, - leafsize-sizeof(struct btrfs_header)); + memset(buf->data + sizeof(struct btrfs_header), 0, + nodesize - sizeof(struct btrfs_header)); nritems = 0; 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) */ 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_nritems(buf, nritems); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); - ret = pwrite(fd, buf->data, leafsize, blocks[3]); - if (ret != leafsize) { + ret = pwrite(fd, buf->data, nodesize, blocks[3]); + if (ret != nodesize) { ret = (ret < 0 ? -errno : -EIO); goto out; } /* create the device tree */ - memset(buf->data+sizeof(struct btrfs_header), 0, - leafsize-sizeof(struct btrfs_header)); + memset(buf->data + sizeof(struct btrfs_header), 0, + nodesize - sizeof(struct btrfs_header)); nritems = 0; - itemoff = __BTRFS_LEAF_DATA_SIZE(leafsize) - + itemoff = __BTRFS_LEAF_DATA_SIZE(nodesize) - sizeof(struct btrfs_dev_extent); 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_nritems(buf, nritems); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); - ret = pwrite(fd, buf->data, leafsize, blocks[4]); - if (ret != leafsize) { + ret = pwrite(fd, buf->data, nodesize, blocks[4]); + if (ret != nodesize) { ret = (ret < 0 ? -errno : -EIO); goto out; } /* create the FS root */ - memset(buf->data+sizeof(struct btrfs_header), 0, - leafsize-sizeof(struct btrfs_header)); + memset(buf->data + sizeof(struct btrfs_header), 0, + nodesize - sizeof(struct btrfs_header)); btrfs_set_header_bytenr(buf, blocks[5]); btrfs_set_header_owner(buf, BTRFS_FS_TREE_OBJECTID); btrfs_set_header_nritems(buf, 0); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); - ret = pwrite(fd, buf->data, leafsize, blocks[5]); - if (ret != leafsize) { + ret = pwrite(fd, buf->data, nodesize, blocks[5]); + if (ret != nodesize) { ret = (ret < 0 ? -errno : -EIO); goto out; } /* finally create the csum root */ - memset(buf->data+sizeof(struct btrfs_header), 0, - leafsize-sizeof(struct btrfs_header)); + memset(buf->data + sizeof(struct btrfs_header), 0, + nodesize - sizeof(struct btrfs_header)); btrfs_set_header_bytenr(buf, blocks[6]); btrfs_set_header_owner(buf, BTRFS_CSUM_TREE_OBJECTID); btrfs_set_header_nritems(buf, 0); csum_tree_block_size(buf, BTRFS_CRC32_SIZE, 0); - ret = pwrite(fd, buf->data, leafsize, blocks[6]); - if (ret != leafsize) { + ret = pwrite(fd, buf->data, nodesize, blocks[6]); + if (ret != nodesize) { ret = (ret < 0 ? -errno : -EIO); 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_size(&inode_item, 0); 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_timespec_sec(&inode_item.atime, now); 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; } -int test_minimum_size(const char *file, u32 leafsize) +int test_minimum_size(const char *file, u32 nodesize) { int fd; struct stat statbuf; @@ -2606,7 +2606,7 @@ int test_minimum_size(const char *file, u32 leafsize) close(fd); 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); return 1; } @@ -2789,22 +2789,22 @@ int btrfs_tree_search2_ioctl_supported(int fd) 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, - "ERROR: Illegal nodesize (or leafsize) %u (smaller than %u)\n", - size, sectorsize); + "ERROR: Illegal nodesize %u (smaller than %u)\n", + nodesize, sectorsize); return -1; - } else if (size > BTRFS_MAX_METADATA_BLOCKSIZE) { + } else if (nodesize > BTRFS_MAX_METADATA_BLOCKSIZE) { fprintf(stderr, - "ERROR: Illegal nodesize (or leafsize) %u (larger than %u)\n", - size, BTRFS_MAX_METADATA_BLOCKSIZE); + "ERROR: Illegal nodesize %u (larger than %u)\n", + nodesize, BTRFS_MAX_METADATA_BLOCKSIZE); return -1; - } else if (size & (sectorsize - 1)) { + } else if (nodesize & (sectorsize - 1)) { fprintf(stderr, - "ERROR: Illegal nodesize (or leafsize) %u (not aligned to %u)\n", - size, sectorsize); + "ERROR: Illegal nodesize %u (not aligned to %u)\n", + nodesize, sectorsize); return -1; } return 0; |