btrfs-progs: track changing_fsid flag in fs_devices

To prepare for reuniting separated devices due to an incomplete fsid
change task, consolidate and monitor the per device's changing_fsid flag
in the struct btrfs_fs_devices.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Anand Jain 2023-08-03 07:29:42 +08:00 committed by David Sterba
parent 19c337ad9a
commit cb53874f6d
3 changed files with 12 additions and 3 deletions

View File

@ -342,6 +342,9 @@ static int device_list_add(const char *path,
u64 devid = btrfs_stack_device_id(&disk_super->dev_item);
bool metadata_uuid = (btrfs_super_incompat_flags(disk_super) &
BTRFS_FEATURE_INCOMPAT_METADATA_UUID);
bool changing_fsid = (btrfs_super_flags(disk_super) &
(BTRFS_SUPER_FLAG_CHANGING_FSID |
BTRFS_SUPER_FLAG_CHANGING_FSID_V2));
if (metadata_uuid)
fs_devices = find_fsid(disk_super->fsid,
@ -424,6 +427,12 @@ static int device_list_add(const char *path,
device->name = name;
}
/*
* If changing_fsid the fs_devices will still hold the status from
* the other devices.
*/
if (changing_fsid)
fs_devices->changing_fsid = true;
if (found_transid > fs_devices->latest_trans) {
fs_devices->latest_devid = devid;

View File

@ -99,6 +99,8 @@ struct btrfs_fs_devices {
struct btrfs_fs_devices *seed;
enum btrfs_chunk_allocation_policy chunk_alloc_policy;
bool changing_fsid;
};
struct btrfs_bio_stripe {

View File

@ -214,10 +214,8 @@ int check_unfinished_fsid_change(struct btrfs_fs_info *fs_info,
uuid_t fsid_ret, uuid_t chunk_id_ret)
{
struct btrfs_root *tree_root = fs_info->tree_root;
u64 flags = btrfs_super_flags(fs_info->super_copy);
if (flags & (BTRFS_SUPER_FLAG_CHANGING_FSID |
BTRFS_SUPER_FLAG_CHANGING_FSID_V2)) {
if (fs_info->fs_devices->changing_fsid) {
memcpy(fsid_ret, fs_info->super_copy->fsid, BTRFS_FSID_SIZE);
read_extent_buffer(tree_root->node, chunk_id_ret,
btrfs_header_chunk_tree_uuid(tree_root->node),