mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-11-24 20:54:17 +08:00
btrfs-progs: mkfs: use blocks_nr to determine the super used bytes
We were setting the super block's used bytes to a static number. However the number of blocks we have to write has the correct used size, so just add up the total number of blocks we're allocating as we determine their offsets. This value will be used later which is why I'm calculating it this way instead of doing the math to set the bytes_super specifically. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
5a164401e9
commit
6ee697fb25
@ -161,6 +161,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
|
|||||||
u64 ref_root;
|
u64 ref_root;
|
||||||
u32 array_size;
|
u32 array_size;
|
||||||
u32 item_size;
|
u32 item_size;
|
||||||
|
u64 total_used = 0;
|
||||||
int skinny_metadata = !!(cfg->features &
|
int skinny_metadata = !!(cfg->features &
|
||||||
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA);
|
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA);
|
||||||
u64 num_bytes;
|
u64 num_bytes;
|
||||||
@ -203,6 +204,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
|
|||||||
for (i = 0; i < blocks_nr; i++) {
|
for (i = 0; i < blocks_nr; i++) {
|
||||||
blk = blocks[i];
|
blk = blocks[i];
|
||||||
cfg->blocks[blk] = system_group_offset + cfg->nodesize * i;
|
cfg->blocks[blk] = system_group_offset + cfg->nodesize * i;
|
||||||
|
total_used += cfg->nodesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
btrfs_set_super_bytenr(&super, BTRFS_SUPER_INFO_OFFSET);
|
btrfs_set_super_bytenr(&super, BTRFS_SUPER_INFO_OFFSET);
|
||||||
@ -212,7 +214,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
|
|||||||
btrfs_set_super_root(&super, cfg->blocks[MKFS_ROOT_TREE]);
|
btrfs_set_super_root(&super, cfg->blocks[MKFS_ROOT_TREE]);
|
||||||
btrfs_set_super_chunk_root(&super, cfg->blocks[MKFS_CHUNK_TREE]);
|
btrfs_set_super_chunk_root(&super, cfg->blocks[MKFS_CHUNK_TREE]);
|
||||||
btrfs_set_super_total_bytes(&super, num_bytes);
|
btrfs_set_super_total_bytes(&super, num_bytes);
|
||||||
btrfs_set_super_bytes_used(&super, 6 * cfg->nodesize);
|
btrfs_set_super_bytes_used(&super, total_used);
|
||||||
btrfs_set_super_sectorsize(&super, cfg->sectorsize);
|
btrfs_set_super_sectorsize(&super, cfg->sectorsize);
|
||||||
super.__unused_leafsize = cpu_to_le32(cfg->nodesize);
|
super.__unused_leafsize = cpu_to_le32(cfg->nodesize);
|
||||||
btrfs_set_super_nodesize(&super, cfg->nodesize);
|
btrfs_set_super_nodesize(&super, cfg->nodesize);
|
||||||
|
Loading…
Reference in New Issue
Block a user