diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-06-11 21:47:56 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:03 -0400 |
commit | 4543df7ecc8ae4928c1e51d6e7dc188d650abee4 (patch) | |
tree | c0e32d2bdaaf26f6819f5f034ed8f1679d23109f /fs/btrfs/disk-io.c | |
parent | 35d8ba66294ff2a53c17337a1aa1ff6739492f41 (diff) |
Btrfs: Add a mount option to control worker thread pool size
mount -o thread_pool_size changes the default, which is
min(num_cpus + 2, 8). Larger thread pools would make more sense on
very large disk arrays.
This mount option controls the max size of each thread pool. There
are multiple thread pools, so the total worker count will be larger
than the mount option.
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 | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 98ff4fbcb386..c6a710a668cb 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1117,6 +1117,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1117 | GFP_NOFS); | 1117 | GFP_NOFS); |
1118 | int ret; | 1118 | int ret; |
1119 | int err = -EINVAL; | 1119 | int err = -EINVAL; |
1120 | |||
1120 | struct btrfs_super_block *disk_super; | 1121 | struct btrfs_super_block *disk_super; |
1121 | 1122 | ||
1122 | if (!extent_root || !tree_root || !fs_info) { | 1123 | if (!extent_root || !tree_root || !fs_info) { |
@@ -1148,6 +1149,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1148 | fs_info->btree_inode = new_inode(sb); | 1149 | fs_info->btree_inode = new_inode(sb); |
1149 | fs_info->btree_inode->i_ino = 1; | 1150 | fs_info->btree_inode->i_ino = 1; |
1150 | fs_info->btree_inode->i_nlink = 1; | 1151 | fs_info->btree_inode->i_nlink = 1; |
1152 | fs_info->thread_pool_size = min(num_online_cpus() + 2, 8); | ||
1151 | 1153 | ||
1152 | sb->s_blocksize = 4096; | 1154 | sb->s_blocksize = 4096; |
1153 | sb->s_blocksize_bits = blksize_bits(4096); | 1155 | sb->s_blocksize_bits = blksize_bits(4096); |
@@ -1195,19 +1197,6 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1195 | mutex_init(&fs_info->trans_mutex); | 1197 | mutex_init(&fs_info->trans_mutex); |
1196 | mutex_init(&fs_info->fs_mutex); | 1198 | mutex_init(&fs_info->fs_mutex); |
1197 | 1199 | ||
1198 | /* we need to start all the end_io workers up front because the | ||
1199 | * queue work function gets called at interrupt time. The endio | ||
1200 | * workers don't normally start IO, so some number of them <= the | ||
1201 | * number of cpus is fine. They handle checksumming after a read. | ||
1202 | * | ||
1203 | * The other worker threads do start IO, so the max is larger than | ||
1204 | * the number of CPUs. FIXME, tune this for huge machines | ||
1205 | */ | ||
1206 | btrfs_init_workers(&fs_info->workers, num_online_cpus() * 2); | ||
1207 | btrfs_init_workers(&fs_info->endio_workers, num_online_cpus()); | ||
1208 | btrfs_start_workers(&fs_info->workers, 1); | ||
1209 | btrfs_start_workers(&fs_info->endio_workers, num_online_cpus()); | ||
1210 | |||
1211 | #if 0 | 1200 | #if 0 |
1212 | ret = add_hasher(fs_info, "crc32c"); | 1201 | ret = add_hasher(fs_info, "crc32c"); |
1213 | if (ret) { | 1202 | if (ret) { |
@@ -1238,6 +1227,17 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1238 | if (err) | 1227 | if (err) |
1239 | goto fail_sb_buffer; | 1228 | goto fail_sb_buffer; |
1240 | 1229 | ||
1230 | /* | ||
1231 | * we need to start all the end_io workers up front because the | ||
1232 | * queue work function gets called at interrupt time, and so it | ||
1233 | * cannot dynamically grow. | ||
1234 | */ | ||
1235 | btrfs_init_workers(&fs_info->workers, fs_info->thread_pool_size); | ||
1236 | btrfs_init_workers(&fs_info->endio_workers, fs_info->thread_pool_size); | ||
1237 | btrfs_start_workers(&fs_info->workers, 1); | ||
1238 | btrfs_start_workers(&fs_info->endio_workers, fs_info->thread_pool_size); | ||
1239 | |||
1240 | |||
1241 | err = -EINVAL; | 1241 | err = -EINVAL; |
1242 | if (btrfs_super_num_devices(disk_super) > fs_devices->open_devices) { | 1242 | if (btrfs_super_num_devices(disk_super) > fs_devices->open_devices) { |
1243 | printk("Btrfs: wanted %llu devices, but found %llu\n", | 1243 | printk("Btrfs: wanted %llu devices, but found %llu\n", |
@@ -1341,10 +1341,10 @@ fail_sys_array: | |||
1341 | mutex_unlock(&fs_info->fs_mutex); | 1341 | mutex_unlock(&fs_info->fs_mutex); |
1342 | fail_sb_buffer: | 1342 | fail_sb_buffer: |
1343 | extent_io_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->io_tree); | 1343 | extent_io_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->io_tree); |
1344 | fail_iput: | ||
1345 | iput(fs_info->btree_inode); | ||
1346 | btrfs_stop_workers(&fs_info->workers); | 1344 | btrfs_stop_workers(&fs_info->workers); |
1347 | btrfs_stop_workers(&fs_info->endio_workers); | 1345 | btrfs_stop_workers(&fs_info->endio_workers); |
1346 | fail_iput: | ||
1347 | iput(fs_info->btree_inode); | ||
1348 | fail: | 1348 | fail: |
1349 | btrfs_close_devices(fs_info->fs_devices); | 1349 | btrfs_close_devices(fs_info->fs_devices); |
1350 | btrfs_mapping_tree_free(&fs_info->mapping_tree); | 1350 | btrfs_mapping_tree_free(&fs_info->mapping_tree); |