]> git.baikalelectronics.ru Git - kernel.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Sep 2023 09:11:08 +0000 (11:11 +0200)
[ Upstream commit 4844c3664a72d36cc79752cb651c78860b14c240 ]

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>
Stable-dep-of: 6bfe3959b0e7 ("btrfs: compare the correct fsid/metadata_uuid in btrfs_validate_super")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/volumes.c
fs/btrfs/volumes.h

index 567c5c010f931b54c0fb113372bafc74fc2fe213..a40ebd2321d01757b368323a57633396d5e78e22 100644 (file)
@@ -663,6 +663,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 099def5613b875a3cdae1997f4cc34faef898919..ec2260177038e2b17249d3b899884c15979e5175 100644 (file)
@@ -757,5 +757,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