diff options
author | Chris Mason <chris.mason@oracle.com> | 2009-08-04 16:56:34 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2009-09-11 13:30:56 -0400 |
commit | 9042846bc7ae69cc3288d85af6bad16208d93a95 (patch) | |
tree | d46077d217d31ce5600ef870c92fcdf330922b41 /fs/btrfs/disk-io.c | |
parent | ceab36edd3d3ad3ffd01d41d6d1e05ac1ff8357e (diff) |
Btrfs: Allow worker threads to exit when idle
The Btrfs worker threads don't currently die off after they have
been idle for a while, leading to a lot of threads sitting around
doing nothing for each mount.
Also, they are unable to start atomically (from end_io hanlders).
This commit reworks the worker threads so they can be started
from end_io handlers (just setting a flag that asks for a thread
to be added at a later date) and so they can exit if they
have been idle for a long time.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 3cf4cfa575c8..20cefc6f22c4 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1682,7 +1682,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1682 | err = -EINVAL; | 1682 | err = -EINVAL; |
1683 | goto fail_iput; | 1683 | goto fail_iput; |
1684 | } | 1684 | } |
1685 | 1685 | printk("thread pool is %d\n", fs_info->thread_pool_size); | |
1686 | /* | 1686 | /* |
1687 | * we need to start all the end_io workers up front because the | 1687 | * we need to start all the end_io workers up front because the |
1688 | * queue work function gets called at interrupt time, and so it | 1688 | * queue work function gets called at interrupt time, and so it |
@@ -1727,20 +1727,22 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1727 | fs_info->endio_workers.idle_thresh = 4; | 1727 | fs_info->endio_workers.idle_thresh = 4; |
1728 | fs_info->endio_meta_workers.idle_thresh = 4; | 1728 | fs_info->endio_meta_workers.idle_thresh = 4; |
1729 | 1729 | ||
1730 | fs_info->endio_write_workers.idle_thresh = 64; | 1730 | fs_info->endio_write_workers.idle_thresh = 2; |
1731 | fs_info->endio_meta_write_workers.idle_thresh = 64; | 1731 | fs_info->endio_meta_write_workers.idle_thresh = 2; |
1732 | |||
1733 | fs_info->endio_workers.atomic_worker_start = 1; | ||
1734 | fs_info->endio_meta_workers.atomic_worker_start = 1; | ||
1735 | fs_info->endio_write_workers.atomic_worker_start = 1; | ||
1736 | fs_info->endio_meta_write_workers.atomic_worker_start = 1; | ||
1732 | 1737 | ||
1733 | btrfs_start_workers(&fs_info->workers, 1); | 1738 | btrfs_start_workers(&fs_info->workers, 1); |
1734 | btrfs_start_workers(&fs_info->submit_workers, 1); | 1739 | btrfs_start_workers(&fs_info->submit_workers, 1); |
1735 | btrfs_start_workers(&fs_info->delalloc_workers, 1); | 1740 | btrfs_start_workers(&fs_info->delalloc_workers, 1); |
1736 | btrfs_start_workers(&fs_info->fixup_workers, 1); | 1741 | btrfs_start_workers(&fs_info->fixup_workers, 1); |
1737 | btrfs_start_workers(&fs_info->endio_workers, fs_info->thread_pool_size); | 1742 | btrfs_start_workers(&fs_info->endio_workers, 1); |
1738 | btrfs_start_workers(&fs_info->endio_meta_workers, | 1743 | btrfs_start_workers(&fs_info->endio_meta_workers, 1); |
1739 | fs_info->thread_pool_size); | 1744 | btrfs_start_workers(&fs_info->endio_meta_write_workers, 1); |
1740 | btrfs_start_workers(&fs_info->endio_meta_write_workers, | 1745 | btrfs_start_workers(&fs_info->endio_write_workers, 1); |
1741 | fs_info->thread_pool_size); | ||
1742 | btrfs_start_workers(&fs_info->endio_write_workers, | ||
1743 | fs_info->thread_pool_size); | ||
1744 | 1746 | ||
1745 | fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); | 1747 | fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); |
1746 | fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, | 1748 | fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, |