Commit fccb5d86 authored by Qu Wenruo's avatar Qu Wenruo Committed by Josef Bacik

btrfs: Replace fs_info->endio_* workqueue with btrfs_workqueue.

Replace the fs_info->endio_* workqueues with the newly created
btrfs_workqueue.
Signed-off-by: default avatarQu Wenruo <quwenruo@cn.fujitsu.com>
Tested-by: default avatarDavid Sterba <dsterba@suse.cz>
Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
parent a44903ab
...@@ -1508,13 +1508,13 @@ struct btrfs_fs_info { ...@@ -1508,13 +1508,13 @@ struct btrfs_fs_info {
struct btrfs_workqueue_struct *workers; struct btrfs_workqueue_struct *workers;
struct btrfs_workqueue_struct *delalloc_workers; struct btrfs_workqueue_struct *delalloc_workers;
struct btrfs_workqueue_struct *flush_workers; struct btrfs_workqueue_struct *flush_workers;
struct btrfs_workers endio_workers; struct btrfs_workqueue_struct *endio_workers;
struct btrfs_workers endio_meta_workers; struct btrfs_workqueue_struct *endio_meta_workers;
struct btrfs_workers endio_raid56_workers; struct btrfs_workqueue_struct *endio_raid56_workers;
struct btrfs_workers rmw_workers; struct btrfs_workers rmw_workers;
struct btrfs_workers endio_meta_write_workers; struct btrfs_workqueue_struct *endio_meta_write_workers;
struct btrfs_workers endio_write_workers; struct btrfs_workqueue_struct *endio_write_workers;
struct btrfs_workers endio_freespace_worker; struct btrfs_workqueue_struct *endio_freespace_worker;
struct btrfs_workqueue_struct *submit_workers; struct btrfs_workqueue_struct *submit_workers;
struct btrfs_workers caching_workers; struct btrfs_workers caching_workers;
struct btrfs_workers readahead_workers; struct btrfs_workers readahead_workers;
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#endif #endif
static struct extent_io_ops btree_extent_io_ops; static struct extent_io_ops btree_extent_io_ops;
static void end_workqueue_fn(struct btrfs_work *work); static void end_workqueue_fn(struct btrfs_work_struct *work);
static void free_fs_root(struct btrfs_root *root); static void free_fs_root(struct btrfs_root *root);
static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info, static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
int read_only); int read_only);
...@@ -86,7 +86,7 @@ struct end_io_wq { ...@@ -86,7 +86,7 @@ struct end_io_wq {
int error; int error;
int metadata; int metadata;
struct list_head list; struct list_head list;
struct btrfs_work work; struct btrfs_work_struct work;
}; };
/* /*
...@@ -678,31 +678,30 @@ static void end_workqueue_bio(struct bio *bio, int err) ...@@ -678,31 +678,30 @@ static void end_workqueue_bio(struct bio *bio, int err)
fs_info = end_io_wq->info; fs_info = end_io_wq->info;
end_io_wq->error = err; end_io_wq->error = err;
end_io_wq->work.func = end_workqueue_fn; btrfs_init_work(&end_io_wq->work, end_workqueue_fn, NULL, NULL);
end_io_wq->work.flags = 0;
if (bio->bi_rw & REQ_WRITE) { if (bio->bi_rw & REQ_WRITE) {
if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA) if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA)
btrfs_queue_worker(&fs_info->endio_meta_write_workers, btrfs_queue_work(fs_info->endio_meta_write_workers,
&end_io_wq->work); &end_io_wq->work);
else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_FREE_SPACE) else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_FREE_SPACE)
btrfs_queue_worker(&fs_info->endio_freespace_worker, btrfs_queue_work(fs_info->endio_freespace_worker,
&end_io_wq->work); &end_io_wq->work);
else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56) else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56)
btrfs_queue_worker(&fs_info->endio_raid56_workers, btrfs_queue_work(fs_info->endio_raid56_workers,
&end_io_wq->work); &end_io_wq->work);
else else
btrfs_queue_worker(&fs_info->endio_write_workers, btrfs_queue_work(fs_info->endio_write_workers,
&end_io_wq->work); &end_io_wq->work);
} else { } else {
if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56) if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56)
btrfs_queue_worker(&fs_info->endio_raid56_workers, btrfs_queue_work(fs_info->endio_raid56_workers,
&end_io_wq->work); &end_io_wq->work);
else if (end_io_wq->metadata) else if (end_io_wq->metadata)
btrfs_queue_worker(&fs_info->endio_meta_workers, btrfs_queue_work(fs_info->endio_meta_workers,
&end_io_wq->work); &end_io_wq->work);
else else
btrfs_queue_worker(&fs_info->endio_workers, btrfs_queue_work(fs_info->endio_workers,
&end_io_wq->work); &end_io_wq->work);
} }
} }
...@@ -1669,7 +1668,7 @@ static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi) ...@@ -1669,7 +1668,7 @@ static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
* called by the kthread helper functions to finally call the bio end_io * called by the kthread helper functions to finally call the bio end_io
* functions. This is where read checksum verification actually happens * functions. This is where read checksum verification actually happens
*/ */
static void end_workqueue_fn(struct btrfs_work *work) static void end_workqueue_fn(struct btrfs_work_struct *work)
{ {
struct bio *bio; struct bio *bio;
struct end_io_wq *end_io_wq; struct end_io_wq *end_io_wq;
...@@ -1999,13 +1998,13 @@ static void btrfs_stop_all_workers(struct btrfs_fs_info *fs_info) ...@@ -1999,13 +1998,13 @@ static void btrfs_stop_all_workers(struct btrfs_fs_info *fs_info)
btrfs_stop_workers(&fs_info->fixup_workers); btrfs_stop_workers(&fs_info->fixup_workers);
btrfs_destroy_workqueue(fs_info->delalloc_workers); btrfs_destroy_workqueue(fs_info->delalloc_workers);
btrfs_destroy_workqueue(fs_info->workers); btrfs_destroy_workqueue(fs_info->workers);
btrfs_stop_workers(&fs_info->endio_workers); btrfs_destroy_workqueue(fs_info->endio_workers);
btrfs_stop_workers(&fs_info->endio_meta_workers); btrfs_destroy_workqueue(fs_info->endio_meta_workers);
btrfs_stop_workers(&fs_info->endio_raid56_workers); btrfs_destroy_workqueue(fs_info->endio_raid56_workers);
btrfs_stop_workers(&fs_info->rmw_workers); btrfs_stop_workers(&fs_info->rmw_workers);
btrfs_stop_workers(&fs_info->endio_meta_write_workers); btrfs_destroy_workqueue(fs_info->endio_meta_write_workers);
btrfs_stop_workers(&fs_info->endio_write_workers); btrfs_destroy_workqueue(fs_info->endio_write_workers);
btrfs_stop_workers(&fs_info->endio_freespace_worker); btrfs_destroy_workqueue(fs_info->endio_freespace_worker);
btrfs_destroy_workqueue(fs_info->submit_workers); btrfs_destroy_workqueue(fs_info->submit_workers);
btrfs_stop_workers(&fs_info->delayed_workers); btrfs_stop_workers(&fs_info->delayed_workers);
btrfs_stop_workers(&fs_info->caching_workers); btrfs_stop_workers(&fs_info->caching_workers);
...@@ -2501,26 +2500,26 @@ int open_ctree(struct super_block *sb, ...@@ -2501,26 +2500,26 @@ int open_ctree(struct super_block *sb,
btrfs_init_workers(&fs_info->fixup_workers, "fixup", 1, btrfs_init_workers(&fs_info->fixup_workers, "fixup", 1,
&fs_info->generic_worker); &fs_info->generic_worker);
btrfs_init_workers(&fs_info->endio_workers, "endio",
fs_info->thread_pool_size, /*
&fs_info->generic_worker); * endios are largely parallel and should have a very
btrfs_init_workers(&fs_info->endio_meta_workers, "endio-meta", * low idle thresh
fs_info->thread_pool_size, */
&fs_info->generic_worker); fs_info->endio_workers =
btrfs_init_workers(&fs_info->endio_meta_write_workers, btrfs_alloc_workqueue("endio", flags, max_active, 4);
"endio-meta-write", fs_info->thread_pool_size, fs_info->endio_meta_workers =
&fs_info->generic_worker); btrfs_alloc_workqueue("endio-meta", flags, max_active, 4);
btrfs_init_workers(&fs_info->endio_raid56_workers, fs_info->endio_meta_write_workers =
"endio-raid56", fs_info->thread_pool_size, btrfs_alloc_workqueue("endio-meta-write", flags, max_active, 2);
&fs_info->generic_worker); fs_info->endio_raid56_workers =
btrfs_alloc_workqueue("endio-raid56", flags, max_active, 4);
btrfs_init_workers(&fs_info->rmw_workers, btrfs_init_workers(&fs_info->rmw_workers,
"rmw", fs_info->thread_pool_size, "rmw", fs_info->thread_pool_size,
&fs_info->generic_worker); &fs_info->generic_worker);
btrfs_init_workers(&fs_info->endio_write_workers, "endio-write", fs_info->endio_write_workers =
fs_info->thread_pool_size, btrfs_alloc_workqueue("endio-write", flags, max_active, 2);
&fs_info->generic_worker); fs_info->endio_freespace_worker =
btrfs_init_workers(&fs_info->endio_freespace_worker, "freespace-write", btrfs_alloc_workqueue("freespace-write", flags, max_active, 0);
1, &fs_info->generic_worker);
btrfs_init_workers(&fs_info->delayed_workers, "delayed-meta", btrfs_init_workers(&fs_info->delayed_workers, "delayed-meta",
fs_info->thread_pool_size, fs_info->thread_pool_size,
&fs_info->generic_worker); &fs_info->generic_worker);
...@@ -2530,17 +2529,8 @@ int open_ctree(struct super_block *sb, ...@@ -2530,17 +2529,8 @@ int open_ctree(struct super_block *sb,
btrfs_init_workers(&fs_info->qgroup_rescan_workers, "qgroup-rescan", 1, btrfs_init_workers(&fs_info->qgroup_rescan_workers, "qgroup-rescan", 1,
&fs_info->generic_worker); &fs_info->generic_worker);
/*
* endios are largely parallel and should have a very
* low idle thresh
*/
fs_info->endio_workers.idle_thresh = 4;
fs_info->endio_meta_workers.idle_thresh = 4;
fs_info->endio_raid56_workers.idle_thresh = 4;
fs_info->rmw_workers.idle_thresh = 2; fs_info->rmw_workers.idle_thresh = 2;
fs_info->endio_write_workers.idle_thresh = 2;
fs_info->endio_meta_write_workers.idle_thresh = 2;
fs_info->readahead_workers.idle_thresh = 2; fs_info->readahead_workers.idle_thresh = 2;
/* /*
...@@ -2549,13 +2539,7 @@ int open_ctree(struct super_block *sb, ...@@ -2549,13 +2539,7 @@ int open_ctree(struct super_block *sb,
*/ */
ret = btrfs_start_workers(&fs_info->generic_worker); ret = btrfs_start_workers(&fs_info->generic_worker);
ret |= btrfs_start_workers(&fs_info->fixup_workers); ret |= btrfs_start_workers(&fs_info->fixup_workers);
ret |= btrfs_start_workers(&fs_info->endio_workers);
ret |= btrfs_start_workers(&fs_info->endio_meta_workers);
ret |= btrfs_start_workers(&fs_info->rmw_workers); ret |= btrfs_start_workers(&fs_info->rmw_workers);
ret |= btrfs_start_workers(&fs_info->endio_raid56_workers);
ret |= btrfs_start_workers(&fs_info->endio_meta_write_workers);
ret |= btrfs_start_workers(&fs_info->endio_write_workers);
ret |= btrfs_start_workers(&fs_info->endio_freespace_worker);
ret |= btrfs_start_workers(&fs_info->delayed_workers); ret |= btrfs_start_workers(&fs_info->delayed_workers);
ret |= btrfs_start_workers(&fs_info->caching_workers); ret |= btrfs_start_workers(&fs_info->caching_workers);
ret |= btrfs_start_workers(&fs_info->readahead_workers); ret |= btrfs_start_workers(&fs_info->readahead_workers);
...@@ -2565,7 +2549,11 @@ int open_ctree(struct super_block *sb, ...@@ -2565,7 +2549,11 @@ int open_ctree(struct super_block *sb,
goto fail_sb_buffer; goto fail_sb_buffer;
} }
if (!(fs_info->workers && fs_info->delalloc_workers && if (!(fs_info->workers && fs_info->delalloc_workers &&
fs_info->submit_workers && fs_info->flush_workers)) { fs_info->submit_workers && fs_info->flush_workers &&
fs_info->endio_workers && fs_info->endio_meta_workers &&
fs_info->endio_meta_write_workers &&
fs_info->endio_write_workers && fs_info->endio_raid56_workers &&
fs_info->endio_freespace_worker)) {
err = -ENOMEM; err = -ENOMEM;
goto fail_sb_buffer; goto fail_sb_buffer;
} }
......
...@@ -2750,7 +2750,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2750,7 +2750,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
return ret; return ret;
} }
static void finish_ordered_fn(struct btrfs_work *work) static void finish_ordered_fn(struct btrfs_work_struct *work)
{ {
struct btrfs_ordered_extent *ordered_extent; struct btrfs_ordered_extent *ordered_extent;
ordered_extent = container_of(work, struct btrfs_ordered_extent, work); ordered_extent = container_of(work, struct btrfs_ordered_extent, work);
...@@ -2763,7 +2763,7 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end, ...@@ -2763,7 +2763,7 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end,
struct inode *inode = page->mapping->host; struct inode *inode = page->mapping->host;
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_ordered_extent *ordered_extent = NULL; struct btrfs_ordered_extent *ordered_extent = NULL;
struct btrfs_workers *workers; struct btrfs_workqueue_struct *workers;
trace_btrfs_writepage_end_io_hook(page, start, end, uptodate); trace_btrfs_writepage_end_io_hook(page, start, end, uptodate);
...@@ -2772,14 +2772,13 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end, ...@@ -2772,14 +2772,13 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end,
end - start + 1, uptodate)) end - start + 1, uptodate))
return 0; return 0;
ordered_extent->work.func = finish_ordered_fn; btrfs_init_work(&ordered_extent->work, finish_ordered_fn, NULL, NULL);
ordered_extent->work.flags = 0;
if (btrfs_is_free_space_inode(inode)) if (btrfs_is_free_space_inode(inode))
workers = &root->fs_info->endio_freespace_worker; workers = root->fs_info->endio_freespace_worker;
else else
workers = &root->fs_info->endio_write_workers; workers = root->fs_info->endio_write_workers;
btrfs_queue_worker(workers, &ordered_extent->work); btrfs_queue_work(workers, &ordered_extent->work);
return 0; return 0;
} }
...@@ -7046,9 +7045,8 @@ static void btrfs_endio_direct_write(struct bio *bio, int err) ...@@ -7046,9 +7045,8 @@ static void btrfs_endio_direct_write(struct bio *bio, int err)
if (!ret) if (!ret)
goto out_test; goto out_test;
ordered->work.func = finish_ordered_fn; btrfs_init_work(&ordered->work, finish_ordered_fn, NULL, NULL);
ordered->work.flags = 0; btrfs_queue_work(root->fs_info->endio_write_workers,
btrfs_queue_worker(&root->fs_info->endio_write_workers,
&ordered->work); &ordered->work);
out_test: out_test:
/* /*
......
...@@ -130,7 +130,7 @@ struct btrfs_ordered_extent { ...@@ -130,7 +130,7 @@ struct btrfs_ordered_extent {
/* a per root list of all the pending ordered extents */ /* a per root list of all the pending ordered extents */
struct list_head root_extent_list; struct list_head root_extent_list;
struct btrfs_work work; struct btrfs_work_struct work;
struct completion completion; struct completion completion;
struct btrfs_work_struct flush_work; struct btrfs_work_struct flush_work;
......
...@@ -1329,11 +1329,12 @@ static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info, ...@@ -1329,11 +1329,12 @@ static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info,
btrfs_workqueue_set_max(fs_info->submit_workers, new_pool_size); btrfs_workqueue_set_max(fs_info->submit_workers, new_pool_size);
btrfs_set_max_workers(&fs_info->caching_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->fixup_workers, new_pool_size);
btrfs_set_max_workers(&fs_info->endio_workers, new_pool_size); btrfs_workqueue_set_max(fs_info->endio_workers, new_pool_size);
btrfs_set_max_workers(&fs_info->endio_meta_workers, new_pool_size); btrfs_workqueue_set_max(fs_info->endio_meta_workers, new_pool_size);
btrfs_set_max_workers(&fs_info->endio_meta_write_workers, new_pool_size); btrfs_workqueue_set_max(fs_info->endio_meta_write_workers,
btrfs_set_max_workers(&fs_info->endio_write_workers, new_pool_size); new_pool_size);
btrfs_set_max_workers(&fs_info->endio_freespace_worker, new_pool_size); btrfs_workqueue_set_max(fs_info->endio_write_workers, new_pool_size);
btrfs_workqueue_set_max(fs_info->endio_freespace_worker, new_pool_size);
btrfs_set_max_workers(&fs_info->delayed_workers, 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->readahead_workers, new_pool_size);
btrfs_set_max_workers(&fs_info->scrub_wr_completion_workers, btrfs_set_max_workers(&fs_info->scrub_wr_completion_workers,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment