Skip to content

Commit d167aa7

Browse files
asjkdave
authored andcommitted
btrfs: use the correct superblock to compare fsid in btrfs_validate_super
The function btrfs_validate_super() should verify the fsid in the provided superblock argument. Because, all its callers expect it to do that. Such as in the following stack: 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::fsid instead, which is not correct. Fix this using the correct fsid 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 319baaf commit d167aa7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/btrfs/disk-io.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,11 +2384,10 @@ int btrfs_validate_super(struct btrfs_fs_info *fs_info,
23842384
ret = -EINVAL;
23852385
}
23862386

2387-
if (memcmp(fs_info->fs_devices->fsid, fs_info->super_copy->fsid,
2388-
BTRFS_FSID_SIZE)) {
2387+
if (memcmp(fs_info->fs_devices->fsid, sb->fsid, BTRFS_FSID_SIZE) != 0) {
23892388
btrfs_err(fs_info,
23902389
"superblock fsid doesn't match fsid of fs_devices: %pU != %pU",
2391-
fs_info->super_copy->fsid, fs_info->fs_devices->fsid);
2390+
sb->fsid, fs_info->fs_devices->fsid);
23922391
ret = -EINVAL;
23932392
}
23942393

0 commit comments

Comments
 (0)