aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2014-02-27 21:46:07 -0500
committerJosef Bacik <jbacik@fb.com>2014-03-10 15:17:06 -0400
commitafe3d24267926eb78ba863016bdd65cfe718aef5 (patch)
tree75a73b173492845b3dd289cd5f9fbb2f52610bde
parent5cdc7ad337fb08f630ac3538fb10e4a75de2572d (diff)
btrfs: Replace fs_info->delalloc_workers with btrfs_workqueue
Much like the fs_info->workers, replace the fs_info->delalloc_workers use the same btrfs_workqueue. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Tested-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fb.com>
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/disk-io.c12
-rw-r--r--fs/btrfs/inode.c18
-rw-r--r--fs/btrfs/super.c2
4 files changed, 14 insertions, 20 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index bd7cb8ca4d6c..3b2c30d870e1 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1506,7 +1506,7 @@ struct btrfs_fs_info {
1506 */ 1506 */
1507 struct btrfs_workers generic_worker; 1507 struct btrfs_workers generic_worker;
1508 struct btrfs_workqueue_struct *workers; 1508 struct btrfs_workqueue_struct *workers;
1509 struct btrfs_workers delalloc_workers; 1509 struct btrfs_workqueue_struct *delalloc_workers;
1510 struct btrfs_workers flush_workers; 1510 struct btrfs_workers flush_workers;
1511 struct btrfs_workers endio_workers; 1511 struct btrfs_workers endio_workers;
1512 struct btrfs_workers endio_meta_workers; 1512 struct btrfs_workers endio_meta_workers;
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index faafa5153fbd..7eeb45f649bf 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1997,7 +1997,7 @@ static void btrfs_stop_all_workers(struct btrfs_fs_info *fs_info)
1997{ 1997{
1998 btrfs_stop_workers(&fs_info->generic_worker); 1998 btrfs_stop_workers(&fs_info->generic_worker);
1999 btrfs_stop_workers(&fs_info->fixup_workers); 1999 btrfs_stop_workers(&fs_info->fixup_workers);
2000 btrfs_stop_workers(&fs_info->delalloc_workers); 2000 btrfs_destroy_workqueue(fs_info->delalloc_workers);
2001 btrfs_destroy_workqueue(fs_info->workers); 2001 btrfs_destroy_workqueue(fs_info->workers);
2002 btrfs_stop_workers(&fs_info->endio_workers); 2002 btrfs_stop_workers(&fs_info->endio_workers);
2003 btrfs_stop_workers(&fs_info->endio_meta_workers); 2003 btrfs_stop_workers(&fs_info->endio_meta_workers);
@@ -2480,8 +2480,8 @@ int open_ctree(struct super_block *sb,
2480 btrfs_alloc_workqueue("worker", flags | WQ_HIGHPRI, 2480 btrfs_alloc_workqueue("worker", flags | WQ_HIGHPRI,
2481 max_active, 16); 2481 max_active, 16);
2482 2482
2483 btrfs_init_workers(&fs_info->delalloc_workers, "delalloc", 2483 fs_info->delalloc_workers =
2484 fs_info->thread_pool_size, NULL); 2484 btrfs_alloc_workqueue("delalloc", flags, max_active, 2);
2485 2485
2486 btrfs_init_workers(&fs_info->flush_workers, "flush_delalloc", 2486 btrfs_init_workers(&fs_info->flush_workers, "flush_delalloc",
2487 fs_info->thread_pool_size, NULL); 2487 fs_info->thread_pool_size, NULL);
@@ -2499,9 +2499,6 @@ int open_ctree(struct super_block *sb,
2499 */ 2499 */
2500 fs_info->submit_workers.idle_thresh = 64; 2500 fs_info->submit_workers.idle_thresh = 64;
2501 2501
2502 fs_info->delalloc_workers.idle_thresh = 2;
2503 fs_info->delalloc_workers.ordered = 1;
2504
2505 btrfs_init_workers(&fs_info->fixup_workers, "fixup", 1, 2502 btrfs_init_workers(&fs_info->fixup_workers, "fixup", 1,
2506 &fs_info->generic_worker); 2503 &fs_info->generic_worker);
2507 btrfs_init_workers(&fs_info->endio_workers, "endio", 2504 btrfs_init_workers(&fs_info->endio_workers, "endio",
@@ -2552,7 +2549,6 @@ int open_ctree(struct super_block *sb,
2552 */ 2549 */
2553 ret = btrfs_start_workers(&fs_info->generic_worker); 2550 ret = btrfs_start_workers(&fs_info->generic_worker);
2554 ret |= btrfs_start_workers(&fs_info->submit_workers); 2551 ret |= btrfs_start_workers(&fs_info->submit_workers);
2555 ret |= btrfs_start_workers(&fs_info->delalloc_workers);
2556 ret |= btrfs_start_workers(&fs_info->fixup_workers); 2552 ret |= btrfs_start_workers(&fs_info->fixup_workers);
2557 ret |= btrfs_start_workers(&fs_info->endio_workers); 2553 ret |= btrfs_start_workers(&fs_info->endio_workers);
2558 ret |= btrfs_start_workers(&fs_info->endio_meta_workers); 2554 ret |= btrfs_start_workers(&fs_info->endio_meta_workers);
@@ -2570,7 +2566,7 @@ int open_ctree(struct super_block *sb,
2570 err = -ENOMEM; 2566 err = -ENOMEM;
2571 goto fail_sb_buffer; 2567 goto fail_sb_buffer;
2572 } 2568 }
2573 if (!(fs_info->workers)) { 2569 if (!(fs_info->workers && fs_info->delalloc_workers)) {
2574 err = -ENOMEM; 2570 err = -ENOMEM;
2575 goto fail_sb_buffer; 2571 goto fail_sb_buffer;
2576 } 2572 }
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0182f081d499..a41a5a7aa3cb 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -324,7 +324,7 @@ struct async_cow {
324 u64 start; 324 u64 start;
325 u64 end; 325 u64 end;
326 struct list_head extents; 326 struct list_head extents;
327 struct btrfs_work work; 327 struct btrfs_work_struct work;
328}; 328};
329 329
330static noinline int add_async_extent(struct async_cow *cow, 330static noinline int add_async_extent(struct async_cow *cow,
@@ -1000,7 +1000,7 @@ out_unlock:
1000/* 1000/*
1001 * work queue call back to started compression on a file and pages 1001 * work queue call back to started compression on a file and pages
1002 */ 1002 */
1003static noinline void async_cow_start(struct btrfs_work *work) 1003static noinline void async_cow_start(struct btrfs_work_struct *work)
1004{ 1004{
1005 struct async_cow *async_cow; 1005 struct async_cow *async_cow;
1006 int num_added = 0; 1006 int num_added = 0;
@@ -1018,7 +1018,7 @@ static noinline void async_cow_start(struct btrfs_work *work)
1018/* 1018/*
1019 * work queue call back to submit previously compressed pages 1019 * work queue call back to submit previously compressed pages
1020 */ 1020 */
1021static noinline void async_cow_submit(struct btrfs_work *work) 1021static noinline void async_cow_submit(struct btrfs_work_struct *work)
1022{ 1022{
1023 struct async_cow *async_cow; 1023 struct async_cow *async_cow;
1024 struct btrfs_root *root; 1024 struct btrfs_root *root;
@@ -1039,7 +1039,7 @@ static noinline void async_cow_submit(struct btrfs_work *work)
1039 submit_compressed_extents(async_cow->inode, async_cow); 1039 submit_compressed_extents(async_cow->inode, async_cow);
1040} 1040}
1041 1041
1042static noinline void async_cow_free(struct btrfs_work *work) 1042static noinline void async_cow_free(struct btrfs_work_struct *work)
1043{ 1043{
1044 struct async_cow *async_cow; 1044 struct async_cow *async_cow;
1045 async_cow = container_of(work, struct async_cow, work); 1045 async_cow = container_of(work, struct async_cow, work);
@@ -1076,17 +1076,15 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
1076 async_cow->end = cur_end; 1076 async_cow->end = cur_end;
1077 INIT_LIST_HEAD(&async_cow->extents); 1077 INIT_LIST_HEAD(&async_cow->extents);
1078 1078
1079 async_cow->work.func = async_cow_start; 1079 btrfs_init_work(&async_cow->work, async_cow_start,
1080 async_cow->work.ordered_func = async_cow_submit; 1080 async_cow_submit, async_cow_free);
1081 async_cow->work.ordered_free = async_cow_free;
1082 async_cow->work.flags = 0;
1083 1081
1084 nr_pages = (cur_end - start + PAGE_CACHE_SIZE) >> 1082 nr_pages = (cur_end - start + PAGE_CACHE_SIZE) >>
1085 PAGE_CACHE_SHIFT; 1083 PAGE_CACHE_SHIFT;
1086 atomic_add(nr_pages, &root->fs_info->async_delalloc_pages); 1084 atomic_add(nr_pages, &root->fs_info->async_delalloc_pages);
1087 1085
1088 btrfs_queue_worker(&root->fs_info->delalloc_workers, 1086 btrfs_queue_work(root->fs_info->delalloc_workers,
1089 &async_cow->work); 1087 &async_cow->work);
1090 1088
1091 if (atomic_read(&root->fs_info->async_delalloc_pages) > limit) { 1089 if (atomic_read(&root->fs_info->async_delalloc_pages) > limit) {
1092 wait_event(root->fs_info->async_submit_wait, 1090 wait_event(root->fs_info->async_submit_wait,
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 6f66d8a2ef38..be0019903264 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1325,7 +1325,7 @@ static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info,
1325 1325
1326 btrfs_set_max_workers(&fs_info->generic_worker, new_pool_size); 1326 btrfs_set_max_workers(&fs_info->generic_worker, new_pool_size);
1327 btrfs_workqueue_set_max(fs_info->workers, new_pool_size); 1327 btrfs_workqueue_set_max(fs_info->workers, new_pool_size);
1328 btrfs_set_max_workers(&fs_info->delalloc_workers, new_pool_size); 1328 btrfs_workqueue_set_max(fs_info->delalloc_workers, new_pool_size);
1329 btrfs_set_max_workers(&fs_info->submit_workers, new_pool_size); 1329 btrfs_set_max_workers(&fs_info->submit_workers, new_pool_size);
1330 btrfs_set_max_workers(&fs_info->caching_workers, new_pool_size); 1330 btrfs_set_max_workers(&fs_info->caching_workers, new_pool_size);
1331 btrfs_set_max_workers(&fs_info->fixup_workers, new_pool_size); 1331 btrfs_set_max_workers(&fs_info->fixup_workers, new_pool_size);