btrfs: simplify memcpy either of metadata_uuid or fsid
authorAnand Jain <anand.jain@oracle.com>
Mon, 31 Jul 2023 11:16:33 +0000 (19:16 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Aug 2023 12:54:48 +0000 (14:54 +0200)
There is a helper which provides either metadata_uuid or fsid as per
METADATA_UUID flag. So use it.

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

index 2669206..7338421 100644 (file)
@@ -841,15 +841,8 @@ static noinline struct btrfs_device *device_list_add(const char *path,
                    found_transid > fs_devices->latest_generation) {
                        memcpy(fs_devices->fsid, disk_super->fsid,
                                        BTRFS_FSID_SIZE);
-
-                       if (has_metadata_uuid)
-                               memcpy(fs_devices->metadata_uuid,
-                                      disk_super->metadata_uuid,
-                                      BTRFS_FSID_SIZE);
-                       else
-                               memcpy(fs_devices->metadata_uuid,
-                                      disk_super->fsid, BTRFS_FSID_SIZE);
-
+                       memcpy(fs_devices->metadata_uuid,
+                              btrfs_sb_fsid_ptr(disk_super), BTRFS_FSID_SIZE);
                        fs_devices->fsid_change = false;
                }
        }