Skip to content

Commit 6bfe395

Browse files
asjkdave
authored andcommitted
btrfs: compare the correct fsid/metadata_uuid in btrfs_validate_super
The function btrfs_validate_super() should verify the metadata_uuid in the provided superblock argument. Because, all its callers expect it to do that. Such as in the following stacks: write_all_supers() sb = fs_info->super_for_commit; btrfs_validate_write_super(.., sb) btrfs_validate_super(.., sb, ..) scrub_one_super() btrfs_validate_super(.., sb, ..) And check_dev_super() btrfs_validate_super(.., sb, ..) However, it currently verifies the fs_info::super_copy::metadata_uuid instead. Fix this using the correct metadata_uuid in the superblock argument. CC: [email protected] # 5.4+ Reviewed-by: Johannes Thumshirn <[email protected]> Tested-by: Guilherme G. Piccoli <[email protected]> Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent d167aa7 commit 6bfe395

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

fs/btrfs/disk-io.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,13 +2391,11 @@ int btrfs_validate_super(struct btrfs_fs_info *fs_info,
23912391
ret = -EINVAL;
23922392
}
23932393

2394-
if (btrfs_fs_incompat(fs_info, METADATA_UUID) &&
2395-
memcmp(fs_info->fs_devices->metadata_uuid,
2396-
fs_info->super_copy->metadata_uuid, BTRFS_FSID_SIZE)) {
2394+
if (memcmp(fs_info->fs_devices->metadata_uuid, btrfs_sb_fsid_ptr(sb),
2395+
BTRFS_FSID_SIZE) != 0) {
23972396
btrfs_err(fs_info,
23982397
"superblock metadata_uuid doesn't match metadata uuid of fs_devices: %pU != %pU",
2399-
fs_info->super_copy->metadata_uuid,
2400-
fs_info->fs_devices->metadata_uuid);
2398+
btrfs_sb_fsid_ptr(sb), fs_info->fs_devices->metadata_uuid);
24012399
ret = -EINVAL;
24022400
}
24032401

0 commit comments

Comments
 (0)