btrfs-progs/mkfs
Qu Wenruo cc4a249e99 btrfs-progs: mkfs: dynamically modify mkfs blocks array
In mkfs_btrfs(), we have a btrfs_mkfs_block array to store how many tree
blocks we need to reserve for the initial btrfs image.

Currently we have two very similar arrays, extent_tree_v1_blocks and
extent_tree_v2_blocks.

The only difference is just v2 has an extra block for block group tree.

This patch will add two helpers, mkfs_blocks_add() and
mkfs_blocks_remove() to properly add/remove one block dynamically from
the array.

This allows 3 things:

- Merge extent_tree_v1_blocks and extent_tree_v2_blocks into one array
  The new array will be the same as extent_tree_v1_blocks.
  For extent-tree-v2, we just dynamically add MKFS_BLOCK_GROUP_TREE.

- Remove free space tree block on-demand
  This only works for extent-tree-v1 case, as v2 has a hard requirement
  on free space tree.
  But this still make code much cleaner, not doing any special hacks.

- Allow future expansion without introduce new array
  I strongly doubt why this is not properly done in extent-tree-v2
  preparation patches.
  We should not allow bad practice to sneak in just because it's some
  preparation patches for a larger feature.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-09-12 15:31:26 +02:00
..
common.c btrfs-progs: mkfs: dynamically modify mkfs blocks array 2022-09-12 15:31:26 +02:00
common.h btrfs-progs: mkfs: dynamically modify mkfs blocks array 2022-09-12 15:31:26 +02:00
main.c btrfs-progs: add constant for initial getopt values 2022-08-16 15:18:11 +02:00
Makefile btrfs-progs: build: add stub makefile to image and mkfs 2019-07-04 15:36:01 +02:00
rootdir.c btrfs-progs: stop passing root to csum related functions 2021-11-22 21:45:37 +01:00
rootdir.h btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00