diff options
author | Anand Jain <anand.jain@oracle.com> | 2023-09-28 04:09:46 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2023-10-12 17:44:17 +0300 |
commit | 69d427f34ca0970c2280cccd64e24aa62ff7904a (patch) | |
tree | 0033bef6da3bf9caf1c78a20c033efcf71fc9a86 /fs | |
parent | 9ef17228e1096e7e75bdde752ae1f0e9a5bcc8ab (diff) | |
download | linux-69d427f34ca0970c2280cccd64e24aa62ff7904a.tar.xz |
btrfs: add helper function find_fsid_by_disk
In preparation for adding support to mount multiple single-disk
btrfs filesystems with the same FSID, wrap find_fsid() into
find_fsid_by_disk().
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/volumes.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 790368d4b866..44fd866772e2 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -553,6 +553,20 @@ static int btrfs_free_stale_devices(dev_t devt, struct btrfs_device *skip_device return ret; } +static struct btrfs_fs_devices *find_fsid_by_device( + struct btrfs_super_block *disk_super) +{ + struct btrfs_fs_devices *fsid_fs_devices; + const bool has_metadata_uuid = (btrfs_super_incompat_flags(disk_super) & + BTRFS_FEATURE_INCOMPAT_METADATA_UUID); + + /* Find the fs_device by the usual method, if found use it. */ + fsid_fs_devices = find_fsid(disk_super->fsid, + has_metadata_uuid ? disk_super->metadata_uuid : NULL); + + return fsid_fs_devices; +} + /* * This is only used on mount, and we are protected from competing things * messing with our fs_devices by the uuid_mutex, thus we do not need the @@ -673,10 +687,7 @@ static noinline struct btrfs_device *device_list_add(const char *path, return ERR_PTR(error); } - if (has_metadata_uuid) - fs_devices = find_fsid(disk_super->fsid, disk_super->metadata_uuid); - else - fs_devices = find_fsid(disk_super->fsid, NULL); + fs_devices = find_fsid_by_device(disk_super); if (!fs_devices) { fs_devices = alloc_fs_devices(disk_super->fsid); |