Skip to content

Commit f7717d8

Browse files
lorddoskiaskdave
authored andcommitted
btrfs-progs: Remove fsid/metdata_uuid fields from fs_info
Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 493dfc9 commit f7717d8

File tree

8 files changed

+30
-29
lines changed

8 files changed

+30
-29
lines changed

btrfstune.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ static int change_fsid_prepare(struct btrfs_fs_info *fs_info)
359359
return ret;
360360

361361
/* Also need to change the metadatauuid of the fs info */
362-
memcpy(fs_info->metadata_uuid, fs_info->new_fsid, BTRFS_FSID_SIZE);
362+
memcpy(fs_info->fs_devices->metadata_uuid, fs_info->new_fsid,
363+
BTRFS_FSID_SIZE);
363364

364365
/* also restore new chunk_tree_id into tree_root for restore */
365366
write_extent_buffer(tree_root->node, fs_info->new_chunk_tree_uuid,
@@ -416,7 +417,7 @@ static int change_uuid(struct btrfs_fs_info *fs_info, const char *new_fsid_str)
416417
fs_info->new_fsid = new_fsid;
417418
fs_info->new_chunk_tree_uuid = new_chunk_id;
418419

419-
memcpy(old_fsid, (const char*)fs_info->fsid, BTRFS_UUID_SIZE);
420+
memcpy(old_fsid, (const char*)fs_info->fs_devices->fsid, BTRFS_UUID_SIZE);
420421
uuid_unparse(old_fsid, uuid_buf);
421422
printf("Current fsid: %s\n", uuid_buf);
422423

check/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8424,7 +8424,7 @@ static int btrfs_fsck_reinit_root(struct btrfs_trans_handle *trans,
84248424
btrfs_set_header_backref_rev(c, BTRFS_MIXED_BACKREF_REV);
84258425
btrfs_set_header_owner(c, root->root_key.objectid);
84268426

8427-
write_extent_buffer(c, root->fs_info->metadata_uuid,
8427+
write_extent_buffer(c, root->fs_info->fs_devices->metadata_uuid,
84288428
btrfs_header_fsid(), BTRFS_FSID_SIZE);
84298429

84308430
write_extent_buffer(c, root->fs_info->chunk_tree_uuid,

chunk-recover.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ static int __rebuild_chunk_root(struct btrfs_trans_handle *trans,
11551155
btrfs_set_header_level(cow, 0);
11561156
btrfs_set_header_backref_rev(cow, BTRFS_MIXED_BACKREF_REV);
11571157
btrfs_set_header_owner(cow, BTRFS_CHUNK_TREE_OBJECTID);
1158-
write_extent_buffer(cow, root->fs_info->metadata_uuid,
1158+
write_extent_buffer(cow, root->fs_info->fs_devices->metadata_uuid,
11591159
btrfs_header_fsid(), BTRFS_FSID_SIZE);
11601160

11611161
write_extent_buffer(cow, root->fs_info->chunk_tree_uuid,
@@ -1457,7 +1457,7 @@ open_ctree_with_broken_chunk(struct recover_control *rc)
14571457
goto out_devices;
14581458
}
14591459

1460-
memcpy(fs_info->fsid, &disk_super->fsid, BTRFS_FSID_SIZE);
1460+
ASSERT(!memcmp(disk_super->fsid, rc->fs_devices->fsid, BTRFS_FSID_SIZE));
14611461
fs_info->sectorsize = btrfs_super_sectorsize(disk_super);
14621462
fs_info->nodesize = btrfs_super_nodesize(disk_super);
14631463
fs_info->stripesize = btrfs_super_stripesize(disk_super);
@@ -1469,10 +1469,9 @@ open_ctree_with_broken_chunk(struct recover_control *rc)
14691469
features = btrfs_super_incompat_flags(disk_super);
14701470

14711471
if (features & BTRFS_FEATURE_INCOMPAT_METADATA_UUID)
1472-
memcpy(fs_info->metadata_uuid, disk_super->metadata_uuid,
1473-
BTRFS_FSID_SIZE);
1474-
else
1475-
memcpy(fs_info->metadata_uuid, fs_info->fsid, BTRFS_FSID_SIZE);
1472+
ASSERT(!memcmp(disk_super->metadata_uuid,
1473+
fs_info->fs_devices->metadata_uuid,
1474+
BTRFS_FSID_SIZE));
14761475

14771476
btrfs_setup_root(fs_info->chunk_root, fs_info,
14781477
BTRFS_CHUNK_TREE_OBJECTID);

ctree.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "internal.h"
2424
#include "sizes.h"
2525
#include "messages.h"
26+
#include "volumes.h"
2627

2728
static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root
2829
*root, struct btrfs_path *path, int level);
@@ -134,7 +135,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
134135
else
135136
btrfs_set_header_owner(cow, new_root_objectid);
136137

137-
write_extent_buffer(cow, root->fs_info->metadata_uuid,
138+
write_extent_buffer(cow, root->fs_info->fs_devices->metadata_uuid,
138139
btrfs_header_fsid(), BTRFS_FSID_SIZE);
139140

140141
WARN_ON(btrfs_header_generation(buf) > trans->transid);
@@ -308,7 +309,7 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
308309
else
309310
btrfs_set_header_owner(cow, root->root_key.objectid);
310311

311-
write_extent_buffer(cow, root->fs_info->metadata_uuid,
312+
write_extent_buffer(cow, root->fs_info->fs_devices->metadata_uuid,
312313
btrfs_header_fsid(), BTRFS_FSID_SIZE);
313314

314315
WARN_ON(!(buf->flags & EXTENT_BAD_TRANSID) &&
@@ -1548,7 +1549,7 @@ static int noinline insert_new_root(struct btrfs_trans_handle *trans,
15481549

15491550
root_add_used(root, root->fs_info->nodesize);
15501551

1551-
write_extent_buffer(c, root->fs_info->metadata_uuid,
1552+
write_extent_buffer(c, root->fs_info->fs_devices->metadata_uuid,
15521553
btrfs_header_fsid(), BTRFS_FSID_SIZE);
15531554

15541555
write_extent_buffer(c, root->fs_info->chunk_tree_uuid,
@@ -1669,7 +1670,7 @@ static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root
16691670
btrfs_set_header_generation(split, trans->transid);
16701671
btrfs_set_header_backref_rev(split, BTRFS_MIXED_BACKREF_REV);
16711672
btrfs_set_header_owner(split, root->root_key.objectid);
1672-
write_extent_buffer(split, root->fs_info->metadata_uuid,
1673+
write_extent_buffer(split, root->fs_info->fs_devices->metadata_uuid,
16731674
btrfs_header_fsid(), BTRFS_FSID_SIZE);
16741675
write_extent_buffer(split, root->fs_info->chunk_tree_uuid,
16751676
btrfs_header_chunk_tree_uuid(split),
@@ -2251,7 +2252,7 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans,
22512252
btrfs_set_header_backref_rev(right, BTRFS_MIXED_BACKREF_REV);
22522253
btrfs_set_header_owner(right, root->root_key.objectid);
22532254
btrfs_set_header_level(right, 0);
2254-
write_extent_buffer(right, root->fs_info->metadata_uuid,
2255+
write_extent_buffer(right, root->fs_info->fs_devices->metadata_uuid,
22552256
btrfs_header_fsid(), BTRFS_FSID_SIZE);
22562257

22572258
write_extent_buffer(right, root->fs_info->chunk_tree_uuid,

ctree.h

-2
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,6 @@ struct btrfs_block_group_cache {
10931093
struct btrfs_device;
10941094
struct btrfs_fs_devices;
10951095
struct btrfs_fs_info {
1096-
u8 fsid[BTRFS_FSID_SIZE];
1097-
u8 metadata_uuid[BTRFS_FSID_SIZE];
10981096
u8 *new_fsid;
10991097
u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
11001098
u8 *new_chunk_tree_uuid;

disk-io.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void print_tree_block_error(struct btrfs_fs_info *fs_info,
118118
read_extent_buffer(eb, buf, btrfs_header_fsid(),
119119
BTRFS_UUID_SIZE);
120120
uuid_unparse(buf, found_uuid);
121-
uuid_unparse(fs_info->metadata_uuid, fs_uuid);
121+
uuid_unparse(fs_info->fs_devices->metadata_uuid, fs_uuid);
122122
fprintf(stderr, "fsid mismatch, want=%s, have=%s\n",
123123
fs_uuid, found_uuid);
124124
break;
@@ -1184,13 +1184,12 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
11841184
goto out_devices;
11851185
}
11861186

1187-
memcpy(fs_info->fsid, &disk_super->fsid, BTRFS_FSID_SIZE);
1188-
if (btrfs_fs_incompat(fs_info, METADATA_UUID)) {
1189-
memcpy(fs_info->metadata_uuid, disk_super->metadata_uuid,
1190-
BTRFS_FSID_SIZE);
1191-
} else {
1192-
memcpy(fs_info->metadata_uuid, fs_info->fsid, BTRFS_FSID_SIZE);
1193-
}
1187+
ASSERT(!memcmp(disk_super->fsid, fs_devices->fsid, BTRFS_FSID_SIZE));
1188+
ASSERT(!memcmp(disk_super->fsid, fs_devices->fsid, BTRFS_FSID_SIZE));
1189+
if (btrfs_fs_incompat(fs_info, METADATA_UUID))
1190+
ASSERT(!memcmp(disk_super->metadata_uuid,
1191+
fs_devices->metadata_uuid, BTRFS_FSID_SIZE));
1192+
11941193
fs_info->sectorsize = btrfs_super_sectorsize(disk_super);
11951194
fs_info->nodesize = btrfs_super_nodesize(disk_super);
11961195
fs_info->stripesize = btrfs_super_stripesize(disk_super);
@@ -1646,7 +1645,8 @@ int write_all_supers(struct btrfs_fs_info *fs_info)
16461645
btrfs_set_stack_device_io_width(dev_item, dev->io_width);
16471646
btrfs_set_stack_device_sector_size(dev_item, dev->sector_size);
16481647
memcpy(dev_item->uuid, dev->uuid, BTRFS_UUID_SIZE);
1649-
memcpy(dev_item->fsid, fs_info->metadata_uuid, BTRFS_FSID_SIZE);
1648+
memcpy(dev_item->fsid, fs_info->fs_devices->metadata_uuid,
1649+
BTRFS_FSID_SIZE);
16501650

16511651
flags = btrfs_super_flags(sb);
16521652
btrfs_set_super_flags(sb, flags | BTRFS_HEADER_FLAG_WRITTEN);

free-space-tree.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "disk-io.h"
2121
#include "free-space-cache.h"
2222
#include "free-space-tree.h"
23+
#include "volumes.h"
2324
#include "transaction.h"
2425
#include "bitops.h"
2526
#include "internal.h"
@@ -1453,8 +1454,8 @@ static struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
14531454
btrfs_set_header_backref_rev(leaf, BTRFS_MIXED_BACKREF_REV);
14541455
btrfs_set_header_owner(leaf, objectid);
14551456
root->node = leaf;
1456-
write_extent_buffer(leaf, fs_info->metadata_uuid, btrfs_header_fsid(),
1457-
BTRFS_FSID_SIZE);
1457+
write_extent_buffer(leaf, fs_info->fs_devices->metadata_uuid,
1458+
btrfs_header_fsid(), BTRFS_FSID_SIZE);
14581459
write_extent_buffer(leaf, fs_info->chunk_tree_uuid,
14591460
btrfs_header_chunk_tree_uuid(leaf),
14601461
BTRFS_UUID_SIZE);

volumes.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,8 @@ int btrfs_add_device(struct btrfs_trans_handle *trans,
741741
ptr = (unsigned long)btrfs_device_uuid(dev_item);
742742
write_extent_buffer(leaf, device->uuid, ptr, BTRFS_UUID_SIZE);
743743
ptr = (unsigned long)btrfs_device_fsid(dev_item);
744-
write_extent_buffer(leaf, fs_info->metadata_uuid, ptr, BTRFS_UUID_SIZE);
744+
write_extent_buffer(leaf, fs_info->fs_devices->metadata_uuid, ptr,
745+
BTRFS_UUID_SIZE);
745746
btrfs_mark_buffer_dirty(leaf);
746747
ret = 0;
747748

@@ -2041,7 +2042,7 @@ static int read_one_dev(struct btrfs_fs_info *fs_info,
20412042
(unsigned long)btrfs_device_fsid(dev_item),
20422043
BTRFS_FSID_SIZE);
20432044

2044-
if (memcmp(fs_uuid, fs_info->fsid, BTRFS_UUID_SIZE)) {
2045+
if (memcmp(fs_uuid, fs_info->fs_devices->fsid, BTRFS_UUID_SIZE)) {
20452046
ret = open_seed_devices(fs_info, fs_uuid);
20462047
if (ret)
20472048
return ret;

0 commit comments

Comments
 (0)