Skip to content

Commit 67bc5ad

Browse files
asjkdave
authored andcommitted
btrfs: drop redundant check to use fs_devices::metadata_uuid
fs_devices::metadata_uuid value is already updated based on the super_block::METADATA_UUID flag for either fsid or metadata_uuid as appropriate. So, fs_devices::metadata_uuid can be used directly. 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 6bfe395 commit 67bc5ad

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

fs/btrfs/disk-io.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,21 +313,16 @@ static bool check_tree_block_fsid(struct extent_buffer *eb)
313313
struct btrfs_fs_info *fs_info = eb->fs_info;
314314
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices, *seed_devs;
315315
u8 fsid[BTRFS_FSID_SIZE];
316-
u8 *metadata_uuid;
317316

318317
read_extent_buffer(eb, fsid, offsetof(struct btrfs_header, fsid),
319318
BTRFS_FSID_SIZE);
319+
320320
/*
321-
* Checking the incompat flag is only valid for the current fs. For
322-
* seed devices it's forbidden to have their uuid changed so reading
323-
* ->fsid in this case is fine
321+
* alloc_fs_devices() copies the fsid into metadata_uuid if the
322+
* metadata_uuid is unset in the superblock, including for a seed device.
323+
* So, we can use fs_devices->metadata_uuid.
324324
*/
325-
if (btrfs_fs_incompat(fs_info, METADATA_UUID))
326-
metadata_uuid = fs_devices->metadata_uuid;
327-
else
328-
metadata_uuid = fs_devices->fsid;
329-
330-
if (!memcmp(fsid, metadata_uuid, BTRFS_FSID_SIZE))
325+
if (memcmp(fsid, fs_info->fs_devices->metadata_uuid, BTRFS_FSID_SIZE) == 0)
331326
return false;
332327

333328
list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list)

0 commit comments

Comments
 (0)