mbox series

[0/3] btrfs-progs: a more generic uuid tree rebuild ability

Message ID cover.1721987605.git.wqu@suse.com (mailing list archive)
Headers show
Series btrfs-progs: a more generic uuid tree rebuild ability | expand

Message

Qu Wenruo July 26, 2024, 9:59 a.m. UTC
Inspired by Mark's previous attempt to add multi-subvolume mkfs support,
one of the problem he hits is the uuid tree generation.

Currently the uuid tree is only generated for mkfs, but that's
hard-coded for FS_TREE. Furthermore btrfs-convert doesn't really
generate a UUID tree at all.

Thus this patchset introduces a more generic uuid tree rebuild, without
the need to touch the existing subvolume creation code.

This is done by:

- Create a new uuid tree if there is not one

- Empty the existing 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

This can handle all the situations I can think of, include the future
multi-subvolume mkfs support.

The first two patches are just cleanup and preparation, the main dish is
the last patch.

Qu Wenruo (3):
  btrfs-progs: move uuid-tree definitions to kernel-shared/uuid-tree.h
  btrfs-progs: cross-port btrfs_uuid_tree_add() from kernel
  btrfs-progs: introduce btrfs_rebuild_uuid_tree() for mkfs and
    btrfs-convert

 common/root-tree-utils.c  | 265 ++++++++++++++++++++++++++++++++++++++
 common/root-tree-utils.h  |   1 +
 common/send-utils.c       |   1 +
 convert/main.c            |   5 +
 kernel-shared/ctree.h     |  11 --
 kernel-shared/uuid-tree.c | 120 +++++++++++++++++
 kernel-shared/uuid-tree.h |  35 +++++
 mkfs/main.c               |  94 +-------------
 8 files changed, 431 insertions(+), 101 deletions(-)
 create mode 100644 kernel-shared/uuid-tree.h

--
2.45.2