btrfs-progs: mkfs: make make_cfg::blocks an internal member

The caller of make_btrfs does not need to set it, it's for internal use
and can be read after mkfs ends.

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2017-02-01 14:25:18 +01:00
parent a2ed85a11d
commit 6783002cd3
3 changed files with 9 additions and 10 deletions

View File

@ -92,6 +92,12 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
uuid_generate(super.dev_item.uuid);
uuid_generate(chunk_tree_uuid);
cfg->blocks[0] = BTRFS_SUPER_INFO_OFFSET;
for (i = 1; i < 7; i++) {
cfg->blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 +
cfg->nodesize * i;
}
btrfs_set_super_bytenr(&super, cfg->blocks[0]);
btrfs_set_super_num_devices(&super, 1);
btrfs_set_super_magic(&super, BTRFS_MAGIC_PARTIAL);

View File

@ -39,10 +39,11 @@ struct btrfs_mkfs_config {
u64 features;
/* Size of the filesystem in bytes */
u64 num_bytes;
/* Logical addresses of superblock [0] and other tree roots */
u64 blocks[8];
/* Output fields, set during creation */
/* Logical addresses of superblock [0] and other tree roots */
u64 blocks[8];
char fs_uuid[BTRFS_UUID_UNPARSED_SIZE];
char chunk_uuid[BTRFS_UUID_UNPARSED_SIZE];

View File

@ -1400,7 +1400,6 @@ int main(int argc, char **argv)
char *label = NULL;
u64 block_count = 0;
u64 dev_block_count = 0;
u64 blocks[7];
u64 alloc_start = 0;
u64 metadata_profile = 0;
u64 data_profile = 0;
@ -1723,12 +1722,6 @@ int main(int argc, char **argv)
exit(1);
}
blocks[0] = BTRFS_SUPER_INFO_OFFSET;
for (i = 1; i < 7; i++) {
blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 +
nodesize * i;
}
if (group_profile_max_safe_loss(metadata_profile) <
group_profile_max_safe_loss(data_profile)){
warning("metadata has lower redundancy than data!\n");
@ -1736,7 +1729,6 @@ int main(int argc, char **argv)
mkfs_cfg.label = label;
memcpy(mkfs_cfg.fs_uuid, fs_uuid, sizeof(mkfs_cfg.fs_uuid));
memcpy(mkfs_cfg.blocks, blocks, sizeof(blocks));
mkfs_cfg.num_bytes = dev_block_count;
mkfs_cfg.nodesize = nodesize;
mkfs_cfg.sectorsize = sectorsize;