btrfs-progs/check
Qu Wenruo 3c555beabf btrfs-progs: introduce btrfs_make_subvolume()
There are two different subvolume/data reloc tree creation routines:

- create_subvol() from convert/main.c
  * calls btrfs_copy_root() to create an empty root
    This is not safe, as it relies on the source root to be empty.
  * calls btrfs_read_fs_root() to add it to the cache and trace it
    properly
  * calls btrfs_make_root_dir() to initialize the empty new root

- create_data_reloc_tree() from mkfs/main.c
  * calls btrfs_create_tree() to create an empty root
  * Manually add the root to fs_root cache
    This is only safe for data reloc tree as it's never updated
    inside btrfs-progs.
    But not safe for other subvolume trees.
  * manually setup the root dir

Both have their good and bad aspects, so here we introduce a new helper,
btrfs_make_subvolume():

- Calls btrfs_create_tree() to create an empty root
- Calls btrfs_read_fs_root() to setup the cache and tracking properly
- Calls btrfs_make_root_dir() to initialize the root dir
- Calls btrfs_update_root() to reflect the rootdir change

So this new helper can replace both create_subvol() and
create_data_reloc_tree().

Signed-off-by: Qu Wenruo <wqu@suse.com>
2024-07-30 19:54:04 +02:00
..
common.h btrfs-progs: add extra chunk alignment checks 2024-01-16 19:14:37 +01:00
main.c btrfs-progs: introduce btrfs_make_subvolume() 2024-07-30 19:54:04 +02:00
mode-common.c btrfs-progs: fix warnings reported by -Wold-style-definition 2024-07-30 19:53:32 +02:00
mode-common.h btrfs-progs: check: use bool for option status variables 2024-04-30 19:34:52 +02:00
mode-lowmem.c btrfs-progs: do not check ram_bytes for non-compressed data extents 2024-06-25 17:42:17 +02:00
mode-lowmem.h btrfs-progs: do not check ram_bytes for non-compressed data extents 2024-06-25 17:42:17 +02:00
mode-original.h btrfs-progs: do not check ram_bytes for non-compressed data extents 2024-06-25 17:42:17 +02:00
qgroup-verify.c btrfs-progs: reorder key initializations 2024-04-30 21:49:15 +02:00
qgroup-verify.h btrfs-progs: check: update include lists 2022-10-11 09:06:12 +02:00
repair.c btrfs-progs: reorder key initializations 2024-04-30 21:49:15 +02:00
repair.h btrfs-progs: clean up includes, using include-what-you-use 2023-10-03 01:11:57 +02:00