For some asynchronous threads, such as submit worker and cache worker, we
limit their thread pool size when mounting.

So we also need to do such things when remounting.

Signed-off-by: Liu Bo <bo.li....@oracle.com>
---
 fs/btrfs/super.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 83d6f9f..a58e834 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1158,17 +1158,20 @@ static void btrfs_resize_thread_pool(struct 
btrfs_fs_info *fs_info,
        printk(KERN_INFO "btrfs: resize thread pool %d -> %d\n",
               old_pool_size, new_pool_size);
 
-       btrfs_set_max_workers(&fs_info->generic_worker, new_pool_size);
+       btrfs_set_max_workers(&fs_info->generic_worker, min(1, new_pool_size));
        btrfs_set_max_workers(&fs_info->workers, new_pool_size);
        btrfs_set_max_workers(&fs_info->delalloc_workers, new_pool_size);
-       btrfs_set_max_workers(&fs_info->submit_workers, new_pool_size);
-       btrfs_set_max_workers(&fs_info->caching_workers, new_pool_size);
-       btrfs_set_max_workers(&fs_info->fixup_workers, new_pool_size);
+       btrfs_set_max_workers(&fs_info->submit_workers,
+                             min_t(u64, fs_info->fs_devices->num_devices,
+                             new_pool_size));
+       btrfs_set_max_workers(&fs_info->caching_workers, min(2, new_pool_size));
+       btrfs_set_max_workers(&fs_info->fixup_workers, min(1, new_pool_size));
        btrfs_set_max_workers(&fs_info->endio_workers, new_pool_size);
        btrfs_set_max_workers(&fs_info->endio_meta_workers, new_pool_size);
        btrfs_set_max_workers(&fs_info->endio_meta_write_workers, 
new_pool_size);
        btrfs_set_max_workers(&fs_info->endio_write_workers, new_pool_size);
-       btrfs_set_max_workers(&fs_info->endio_freespace_worker, new_pool_size);
+       btrfs_set_max_workers(&fs_info->endio_freespace_worker,
+                             min(1, new_pool_size));
        btrfs_set_max_workers(&fs_info->delayed_workers, new_pool_size);
        btrfs_set_max_workers(&fs_info->readahead_workers, new_pool_size);
        btrfs_set_max_workers(&fs_info->scrub_workers, new_pool_size);
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to