btrfs: switch seed device to list api

While this patch touches a bunch of files the conversion is
straighforward. Instead of using the implicit linked list anchored at
btrfs_fs_devices::seed the code is switched to using
list_for_each_entry.

Previous patches in the series already factored out code that processed
both main and seed devices so in those cases the factored out functions
are called on the main fs_devices and then on every seed dev inside
list_for_each_entry.

Using list api also allows to simplify deletion from the seed dev list
performed in btrfs_rm_device and btrfs_rm_dev_replace_free_srcdev by
substituting a while() loop with a simple list_del_init.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Nikolay Borisov
2020-07-16 10:25:33 +03:00
committed by David Sterba
parent c4989c2fd0
commit 944d3f9fac
4 changed files with 71 additions and 84 deletions

View File

@@ -791,16 +791,13 @@ static int reada_start_for_fsdevs(struct btrfs_fs_devices *fs_devices)
static void __reada_start_machine(struct btrfs_fs_info *fs_info)
{
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices, *seed_devs;
int i;
u64 enqueued = 0;
again:
enqueued += reada_start_for_fsdevs(fs_devices);
if (fs_devices->seed) {
fs_devices = fs_devices->seed;
goto again;
}
list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list)
enqueued += reada_start_for_fsdevs(seed_devs);
if (enqueued == 0)
return;