summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2015-02-16 10:29:26 -0500
committerDavid Sterba <dsterba@suse.cz>2015-02-16 12:48:46 -0500
commit2a4581983f90d829d9aeaa4cb881031950f54937 (patch)
tree550a3bc47b72f8fd1b0f85557b1f11060052f51f
parentf9e92e40b517bfe94d9e961ff484ab885348f322 (diff)
btrfs: factor btrfs_init_workqueues() out of open_ctree()
Signed-off-by: Eric Sandeen <sandeen@redhat.com> [renamed to btrfs_init_workqueues] Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--fs/btrfs/disk-io.c153
1 files changed, 83 insertions, 70 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1d8db0bb0d4f..9ecd19d98f89 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2223,6 +2223,86 @@ static void btrfs_init_qgroup(struct btrfs_fs_info *fs_info)
2223 mutex_init(&fs_info->qgroup_rescan_lock); 2223 mutex_init(&fs_info->qgroup_rescan_lock);
2224} 2224}
2225 2225
2226static int btrfs_init_workqueues(struct btrfs_fs_info *fs_info,
2227 struct btrfs_fs_devices *fs_devices)
2228{
2229 int max_active = fs_info->thread_pool_size;
2230 int flags = WQ_MEM_RECLAIM | WQ_FREEZABLE | WQ_UNBOUND;
2231
2232 fs_info->workers =
2233 btrfs_alloc_workqueue("worker", flags | WQ_HIGHPRI,
2234 max_active, 16);
2235
2236 fs_info->delalloc_workers =
2237 btrfs_alloc_workqueue("delalloc", flags, max_active, 2);
2238
2239 fs_info->flush_workers =
2240 btrfs_alloc_workqueue("flush_delalloc", flags, max_active, 0);
2241
2242 fs_info->caching_workers =
2243 btrfs_alloc_workqueue("cache", flags, max_active, 0);
2244
2245 /*
2246 * a higher idle thresh on the submit workers makes it much more
2247 * likely that bios will be send down in a sane order to the
2248 * devices
2249 */
2250 fs_info->submit_workers =
2251 btrfs_alloc_workqueue("submit", flags,
2252 min_t(u64, fs_devices->num_devices,
2253 max_active), 64);
2254
2255 fs_info->fixup_workers =
2256 btrfs_alloc_workqueue("fixup", flags, 1, 0);
2257
2258 /*
2259 * endios are largely parallel and should have a very
2260 * low idle thresh
2261 */
2262 fs_info->endio_workers =
2263 btrfs_alloc_workqueue("endio", flags, max_active, 4);
2264 fs_info->endio_meta_workers =
2265 btrfs_alloc_workqueue("endio-meta", flags, max_active, 4);
2266 fs_info->endio_meta_write_workers =
2267 btrfs_alloc_workqueue("endio-meta-write", flags, max_active, 2);
2268 fs_info->endio_raid56_workers =
2269 btrfs_alloc_workqueue("endio-raid56", flags, max_active, 4);
2270 fs_info->endio_repair_workers =
2271 btrfs_alloc_workqueue("endio-repair", flags, 1, 0);
2272 fs_info->rmw_workers =
2273 btrfs_alloc_workqueue("rmw", flags, max_active, 2);
2274 fs_info->endio_write_workers =
2275 btrfs_alloc_workqueue("endio-write", flags, max_active, 2);
2276 fs_info->endio_freespace_worker =
2277 btrfs_alloc_workqueue("freespace-write", flags, max_active, 0);
2278 fs_info->delayed_workers =
2279 btrfs_alloc_workqueue("delayed-meta", flags, max_active, 0);
2280 fs_info->readahead_workers =
2281 btrfs_alloc_workqueue("readahead", flags, max_active, 2);
2282 fs_info->qgroup_rescan_workers =
2283 btrfs_alloc_workqueue("qgroup-rescan", flags, 1, 0);
2284 fs_info->extent_workers =
2285 btrfs_alloc_workqueue("extent-refs", flags,
2286 min_t(u64, fs_devices->num_devices,
2287 max_active), 8);
2288
2289 if (!(fs_info->workers && fs_info->delalloc_workers &&
2290 fs_info->submit_workers && fs_info->flush_workers &&
2291 fs_info->endio_workers && fs_info->endio_meta_workers &&
2292 fs_info->endio_meta_write_workers &&
2293 fs_info->endio_repair_workers &&
2294 fs_info->endio_write_workers && fs_info->endio_raid56_workers &&
2295 fs_info->endio_freespace_worker && fs_info->rmw_workers &&
2296 fs_info->caching_workers && fs_info->readahead_workers &&
2297 fs_info->fixup_workers && fs_info->delayed_workers &&
2298 fs_info->extent_workers &&
2299 fs_info->qgroup_rescan_workers)) {
2300 return -ENOMEM;
2301 }
2302
2303 return 0;
2304}
2305
2226int open_ctree(struct super_block *sb, 2306int open_ctree(struct super_block *sb,
2227 struct btrfs_fs_devices *fs_devices, 2307 struct btrfs_fs_devices *fs_devices,
2228 char *options) 2308 char *options)
@@ -2249,7 +2329,6 @@ int open_ctree(struct super_block *sb,
2249 int num_backups_tried = 0; 2329 int num_backups_tried = 0;
2250 int backup_index = 0; 2330 int backup_index = 0;
2251 int max_active; 2331 int max_active;
2252 int flags = WQ_MEM_RECLAIM | WQ_FREEZABLE | WQ_UNBOUND;
2253 bool create_uuid_tree; 2332 bool create_uuid_tree;
2254 bool check_uuid_tree; 2333 bool check_uuid_tree;
2255 2334
@@ -2581,75 +2660,9 @@ int open_ctree(struct super_block *sb,
2581 2660
2582 max_active = fs_info->thread_pool_size; 2661 max_active = fs_info->thread_pool_size;
2583 2662
2584 fs_info->workers = 2663 ret = btrfs_init_workqueues(fs_info, fs_devices);
2585 btrfs_alloc_workqueue("worker", flags | WQ_HIGHPRI, 2664 if (ret) {
2586 max_active, 16); 2665 err = ret;
2587
2588 fs_info->delalloc_workers =
2589 btrfs_alloc_workqueue("delalloc", flags, max_active, 2);
2590
2591 fs_info->flush_workers =
2592 btrfs_alloc_workqueue("flush_delalloc", flags, max_active, 0);
2593
2594 fs_info->caching_workers =
2595 btrfs_alloc_workqueue("cache", flags, max_active, 0);
2596
2597 /*
2598 * a higher idle thresh on the submit workers makes it much more
2599 * likely that bios will be send down in a sane order to the
2600 * devices
2601 */
2602 fs_info->submit_workers =
2603 btrfs_alloc_workqueue("submit", flags,
2604 min_t(u64, fs_devices->num_devices,
2605 max_active), 64);
2606
2607 fs_info->fixup_workers =
2608 btrfs_alloc_workqueue("fixup", flags, 1, 0);
2609
2610 /*
2611 * endios are largely parallel and should have a very
2612 * low idle thresh
2613 */
2614 fs_info->endio_workers =
2615 btrfs_alloc_workqueue("endio", flags, max_active, 4);
2616 fs_info->endio_meta_workers =
2617 btrfs_alloc_workqueue("endio-meta", flags, max_active, 4);
2618 fs_info->endio_meta_write_workers =
2619 btrfs_alloc_workqueue("endio-meta-write", flags, max_active, 2);
2620 fs_info->endio_raid56_workers =
2621 btrfs_alloc_workqueue("endio-raid56", flags, max_active, 4);
2622 fs_info->endio_repair_workers =
2623 btrfs_alloc_workqueue("endio-repair", flags, 1, 0);
2624 fs_info->rmw_workers =
2625 btrfs_alloc_workqueue("rmw", flags, max_active, 2);
2626 fs_info->endio_write_workers =
2627 btrfs_alloc_workqueue("endio-write", flags, max_active, 2);
2628 fs_info->endio_freespace_worker =
2629 btrfs_alloc_workqueue("freespace-write", flags, max_active, 0);
2630 fs_info->delayed_workers =
2631 btrfs_alloc_workqueue("delayed-meta", flags, max_active, 0);
2632 fs_info->readahead_workers =
2633 btrfs_alloc_workqueue("readahead", flags, max_active, 2);
2634 fs_info->qgroup_rescan_workers =
2635 btrfs_alloc_workqueue("qgroup-rescan", flags, 1, 0);
2636 fs_info->extent_workers =
2637 btrfs_alloc_workqueue("extent-refs", flags,
2638 min_t(u64, fs_devices->num_devices,
2639 max_active), 8);
2640
2641 if (!(fs_info->workers && fs_info->delalloc_workers &&
2642 fs_info->submit_workers && fs_info->flush_workers &&
2643 fs_info->endio_workers && fs_info->endio_meta_workers &&
2644 fs_info->endio_meta_write_workers &&
2645 fs_info->endio_repair_workers &&
2646 fs_info->endio_write_workers && fs_info->endio_raid56_workers &&
2647 fs_info->endio_freespace_worker && fs_info->rmw_workers &&
2648 fs_info->caching_workers && fs_info->readahead_workers &&
2649 fs_info->fixup_workers && fs_info->delayed_workers &&
2650 fs_info->extent_workers &&
2651 fs_info->qgroup_rescan_workers)) {
2652 err = -ENOMEM;
2653 goto fail_sb_buffer; 2666 goto fail_sb_buffer;
2654 } 2667 }
2655 2668