summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/reada.c
diff options
context:
space:
mode:
authorNikolay Borisov <nborisov@suse.com>2020-07-15 13:48:46 +0300
committerDavid Sterba <dsterba@suse.com>2020-10-07 12:06:57 +0200
commitdc0ab488d2cb514e08276cbbc846b2ebb6056c2a (patch)
treec310d59fb5fb1e090f01d5318d5d5bce4f53c1ce /fs/btrfs/reada.c
parent1028d1c48b95c37336bed24a1dc1594e70aa67c6 (diff)
btrfs: factor out reada loop in __reada_start_machine
This is in preparation for moving fs_devices to proper lists. 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>
Diffstat (limited to 'fs/btrfs/reada.c')
-rw-r--r--fs/btrfs/reada.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index 243a2e44526e..a6bfe7ec14cb 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -767,15 +767,13 @@ static void reada_start_machine_worker(struct btrfs_work *work)
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 total = 0;
- int i;
+ struct btrfs_device *device;
-again:
do {
enqueued = 0;
mutex_lock(&fs_devices->device_list_mutex);
@@ -787,6 +785,18 @@ again:
mutex_unlock(&fs_devices->device_list_mutex);
total += enqueued;
} 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) {
fs_devices = fs_devices->seed;
goto again;