Skip to content

Commit 4844c36

Browse files
asjkdave
authored andcommitted
btrfs: add a helper to read the superblock metadata_uuid
In some cases, we need to read the FSID from the superblock when the metadata_uuid is not set, and otherwise, read the metadata_uuid. So, add a helper. 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 182741d commit 4844c36

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

fs/btrfs/volumes.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,14 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
681681
return -EINVAL;
682682
}
683683

684+
u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb)
685+
{
686+
bool has_metadata_uuid = (btrfs_super_incompat_flags(sb) &
687+
BTRFS_FEATURE_INCOMPAT_METADATA_UUID);
688+
689+
return has_metadata_uuid ? sb->metadata_uuid : sb->fsid;
690+
}
691+
684692
/*
685693
* Handle scanned device having its CHANGING_FSID_V2 flag set and the fs_devices
686694
* being created with a disk that has already completed its fsid change. Such

fs/btrfs/volumes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,5 +747,6 @@ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info);
747747
bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical);
748748

749749
bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr);
750+
u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb);
750751

751752
#endif

0 commit comments

Comments
 (0)