]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
btrfs: add a helper to read the superblock metadata_uuid
authorAnand Jain <anand.jain@oracle.com>
Mon, 31 Jul 2023 11:16:32 +0000 (19:16 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Aug 2023 12:54:48 +0000 (14:54 +0200)
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 <johannes.thumshirn@wdc.com>
Tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c
fs/btrfs/volumes.h

index bfdfecee1afe22c3011fa033f29c023d196d3f01..2669206e6f15b1784d495e09d02d857663f33796 100644 (file)
@@ -681,6 +681,14 @@ error_free_page:
        return -EINVAL;
 }
 
+u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb)
+{
+       bool has_metadata_uuid = (btrfs_super_incompat_flags(sb) &
+                                 BTRFS_FEATURE_INCOMPAT_METADATA_UUID);
+
+       return has_metadata_uuid ? sb->metadata_uuid : sb->fsid;
+}
+
 /*
  * Handle scanned device having its CHANGING_FSID_V2 flag set and the fs_devices
  * being created with a disk that has already completed its fsid change. Such
index a59898d51e9e434f0f05712f136a15f6a43375f9..2128a032c3b74d5baa3784fefaf4f1bea6806496 100644 (file)
@@ -747,5 +747,6 @@ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info);
 bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical);
 
 bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr);
+u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb);
 
 #endif