btrfs-progs/convert
Qu Wenruo d3cf350e21 btrfs-progs: introduce btrfs_rebuild_uuid_tree() for mkfs and btrfs-convert
Currently mkfs uses its own create_uuid_tree(), but that function is
only handling FS_TREE.  This means for btrfs-convert we do not generate
the uuid tree, nor add the UUID of the image subvolume.  This can be a
problem if we're going to support multiple subvolumes during mkfs time.

To address this, introduce a new helper, btrfs_rebuild_uuid_tree():

- Create a new uuid tree if there is not one

- Remove all the existing items from uuid tree

- Iterate through all subvolumes
  * If the subvolume has no valid UUID, regenerate one
  * Add the uuid entry for the subvolume UUID
  * If the subvolume has received UUID, also add it to UUID tree

By this, this new helper can handle all the uuid tree generation needs for:

- Current mkfs
  Only one uuid entry for FS_TREE

- Current btrfs-convert
  Only FS_TREE and the image subvolume

- Future multi-subvolume mkfs
  As we do the scan for all subvolumes.

- Future "btrfs rescue rebuild-uuid-tree"

Signed-off-by: Qu Wenruo <wqu@suse.com>
2024-07-30 20:02:56 +02:00
..
Makefile
common.c btrfs-progs: rename and move __strncpy_null to string-utils 2024-06-24 19:18:46 +02:00
common.h btrfs-progs: convert: move simple_range into common.h 2022-10-11 09:08:08 +02:00
main.c btrfs-progs: introduce btrfs_rebuild_uuid_tree() for mkfs and btrfs-convert 2024-07-30 20:02:56 +02:00
source-ext2.c btrfs-progs: do interactive fixing of some ambigous typos 2024-07-30 19:56:08 +02:00
source-ext2.h btrfs-progs: convert: update include lists 2022-10-11 09:06:12 +02:00
source-fs.c btrfs-progs: reorder key initializations 2024-04-30 21:49:15 +02:00
source-fs.h btrfs-progs: convert defined constants to enums 2024-02-08 08:30:37 +01:00
source-reiserfs.c btrfs-progs: move btrfs_record_file_extent and code into a new file 2023-10-03 01:11:56 +02:00
source-reiserfs.h btrfs-progs: convert: update include lists 2022-10-11 09:06:12 +02:00