btrfs-progs: store LEAF_DATA_SIZE in the mkfs_config
We use __BTRFS_LEAF_DATA_SIZE() in a few places for mkfs. With extent tree v2 we'll be increasing the size of btrfs_header, so it'll be kind of annoying to add flags to all callers of __BTRFS_LEAF_DATA_SIZE, so simply calculate it once and put it in the mkfs_config and use that. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
babbfa8ac2
commit
7300aeecff
|
@ -93,7 +93,7 @@ static int btrfs_create_tree_root(int fd, struct btrfs_mkfs_config *cfg,
|
||||||
|
|
||||||
btrfs_set_disk_key_type(&disk_key, BTRFS_ROOT_ITEM_KEY);
|
btrfs_set_disk_key_type(&disk_key, BTRFS_ROOT_ITEM_KEY);
|
||||||
btrfs_set_disk_key_offset(&disk_key, 0);
|
btrfs_set_disk_key_offset(&disk_key, 0);
|
||||||
itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize) - sizeof(root_item);
|
itemoff = cfg->leaf_data_size - sizeof(root_item);
|
||||||
|
|
||||||
for (i = 0; i < blocks_nr; i++) {
|
for (i = 0; i < blocks_nr; i++) {
|
||||||
blk = blocks[i];
|
blk = blocks[i];
|
||||||
|
@ -148,7 +148,7 @@ static int create_free_space_tree(int fd, struct btrfs_mkfs_config *cfg,
|
||||||
{
|
{
|
||||||
struct btrfs_free_space_info *info;
|
struct btrfs_free_space_info *info;
|
||||||
struct btrfs_disk_key disk_key;
|
struct btrfs_disk_key disk_key;
|
||||||
int itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize);
|
int itemoff = cfg->leaf_data_size;
|
||||||
int nritems = 0;
|
int nritems = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -427,7 +427,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
|
||||||
cfg->nodesize - sizeof(struct btrfs_header));
|
cfg->nodesize - sizeof(struct btrfs_header));
|
||||||
nritems = 0;
|
nritems = 0;
|
||||||
item_size = sizeof(*dev_item);
|
item_size = sizeof(*dev_item);
|
||||||
itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize) - item_size;
|
itemoff = cfg->leaf_data_size - 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);
|
||||||
|
@ -515,8 +515,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
|
||||||
memset(buf->data + sizeof(struct btrfs_header), 0,
|
memset(buf->data + sizeof(struct btrfs_header), 0,
|
||||||
cfg->nodesize - sizeof(struct btrfs_header));
|
cfg->nodesize - sizeof(struct btrfs_header));
|
||||||
nritems = 0;
|
nritems = 0;
|
||||||
itemoff = __BTRFS_LEAF_DATA_SIZE(cfg->nodesize) -
|
itemoff = cfg->leaf_data_size - 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);
|
||||||
btrfs_set_disk_key_offset(&disk_key, system_group_offset);
|
btrfs_set_disk_key_offset(&disk_key, system_group_offset);
|
||||||
|
|
|
@ -76,6 +76,7 @@ struct btrfs_mkfs_config {
|
||||||
u32 nodesize;
|
u32 nodesize;
|
||||||
u32 sectorsize;
|
u32 sectorsize;
|
||||||
u32 stripesize;
|
u32 stripesize;
|
||||||
|
u32 leaf_data_size;
|
||||||
/* Bitfield of incompat features, BTRFS_FEATURE_INCOMPAT_* */
|
/* Bitfield of incompat features, BTRFS_FEATURE_INCOMPAT_* */
|
||||||
u64 features;
|
u64 features;
|
||||||
/* Bitfield of BTRFS_RUNTIME_FEATURE_* */
|
/* Bitfield of BTRFS_RUNTIME_FEATURE_* */
|
||||||
|
|
|
@ -1413,6 +1413,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
|
||||||
mkfs_cfg.features = features;
|
mkfs_cfg.features = features;
|
||||||
mkfs_cfg.runtime_features = runtime_features;
|
mkfs_cfg.runtime_features = runtime_features;
|
||||||
mkfs_cfg.csum_type = csum_type;
|
mkfs_cfg.csum_type = csum_type;
|
||||||
|
mkfs_cfg.leaf_data_size = __BTRFS_LEAF_DATA_SIZE(nodesize);
|
||||||
if (zoned)
|
if (zoned)
|
||||||
mkfs_cfg.zone_size = zone_size(file);
|
mkfs_cfg.zone_size = zone_size(file);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue