From: Chris Mason <chris.mason@oracle.com>
Date: Fri, 15 Aug 2008 19:34:14 +0000 (-0400)
Subject: Btrfs: Limit the number of async bio submission kthreads to the number of devices
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b720d209524fccdd33a499351f2ca880b8c0ffb4;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git

Btrfs: Limit the number of async bio submission kthreads to the number of devices

Signed-off-by: Chris Mason <chris.mason@oracle.com>
---

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 56c54a41dbbb..99bd9f9b9eed 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1348,7 +1348,9 @@ struct btrfs_root *open_ctree(struct super_block *sb,
 	 * cannot dynamically grow.
 	 */
 	btrfs_init_workers(&fs_info->workers, fs_info->thread_pool_size);
-	btrfs_init_workers(&fs_info->submit_workers, fs_info->thread_pool_size);
+	btrfs_init_workers(&fs_info->submit_workers,
+			   min_t(u64, fs_devices->num_devices,
+			   fs_info->thread_pool_size));
 
 	/* a higher idle thresh on the submit workers makes it much more
 	 * likely that bios will be send down in a sane order to the