Commit dc0ab488 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: factor out reada loop in __reada_start_machine

This is in preparation for moving fs_devices to proper lists.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 1028d1c4
...@@ -767,15 +767,13 @@ static void reada_start_machine_worker(struct btrfs_work *work) ...@@ -767,15 +767,13 @@ static void reada_start_machine_worker(struct btrfs_work *work)
kfree(rmw); kfree(rmw);
} }
static void __reada_start_machine(struct btrfs_fs_info *fs_info) /* Try to start up to 10k READA requests for a group of devices */
static int reada_start_for_fsdevs(struct btrfs_fs_devices *fs_devices)
{ {
struct btrfs_device *device;
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
u64 enqueued; u64 enqueued;
u64 total = 0; u64 total = 0;
int i; struct btrfs_device *device;
again:
do { do {
enqueued = 0; enqueued = 0;
mutex_lock(&fs_devices->device_list_mutex); mutex_lock(&fs_devices->device_list_mutex);
...@@ -787,6 +785,18 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info) ...@@ -787,6 +785,18 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info)
mutex_unlock(&fs_devices->device_list_mutex); mutex_unlock(&fs_devices->device_list_mutex);
total += enqueued; total += enqueued;
} while (enqueued && total < 10000); } while (enqueued && total < 10000);
return total;
}
static void __reada_start_machine(struct btrfs_fs_info *fs_info)
{
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
int i;
u64 enqueued = 0;
again:
enqueued += reada_start_for_fsdevs(fs_devices);
if (fs_devices->seed) { if (fs_devices->seed) {
fs_devices = fs_devices->seed; fs_devices = fs_devices->seed;
goto again; goto again;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment