btrfs: Replace fs_info->rmw_workers workqueue with btrfs_workqueue.

Replace the fs_info->rmw_workers with the newly created
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>
This commit is contained in:
Qu Wenruo 2014-02-28 10:46:11 +08:00 committed by Josef Bacik
parent fccb5d86d8
commit d05a33ac26
3 changed files with 21 additions and 28 deletions

View File

@ -1511,7 +1511,7 @@ struct btrfs_fs_info {
struct btrfs_workqueue_struct *endio_workers; struct btrfs_workqueue_struct *endio_workers;
struct btrfs_workqueue_struct *endio_meta_workers; struct btrfs_workqueue_struct *endio_meta_workers;
struct btrfs_workqueue_struct *endio_raid56_workers; struct btrfs_workqueue_struct *endio_raid56_workers;
struct btrfs_workers rmw_workers; struct btrfs_workqueue_struct *rmw_workers;
struct btrfs_workqueue_struct *endio_meta_write_workers; struct btrfs_workqueue_struct *endio_meta_write_workers;
struct btrfs_workqueue_struct *endio_write_workers; struct btrfs_workqueue_struct *endio_write_workers;
struct btrfs_workqueue_struct *endio_freespace_worker; struct btrfs_workqueue_struct *endio_freespace_worker;

View File

@ -2001,7 +2001,7 @@ static void btrfs_stop_all_workers(struct btrfs_fs_info *fs_info)
btrfs_destroy_workqueue(fs_info->endio_workers); btrfs_destroy_workqueue(fs_info->endio_workers);
btrfs_destroy_workqueue(fs_info->endio_meta_workers); btrfs_destroy_workqueue(fs_info->endio_meta_workers);
btrfs_destroy_workqueue(fs_info->endio_raid56_workers); btrfs_destroy_workqueue(fs_info->endio_raid56_workers);
btrfs_stop_workers(&fs_info->rmw_workers); btrfs_destroy_workqueue(fs_info->rmw_workers);
btrfs_destroy_workqueue(fs_info->endio_meta_write_workers); btrfs_destroy_workqueue(fs_info->endio_meta_write_workers);
btrfs_destroy_workqueue(fs_info->endio_write_workers); btrfs_destroy_workqueue(fs_info->endio_write_workers);
btrfs_destroy_workqueue(fs_info->endio_freespace_worker); btrfs_destroy_workqueue(fs_info->endio_freespace_worker);
@ -2513,9 +2513,8 @@ int open_ctree(struct super_block *sb,
btrfs_alloc_workqueue("endio-meta-write", flags, max_active, 2); btrfs_alloc_workqueue("endio-meta-write", flags, max_active, 2);
fs_info->endio_raid56_workers = fs_info->endio_raid56_workers =
btrfs_alloc_workqueue("endio-raid56", flags, max_active, 4); btrfs_alloc_workqueue("endio-raid56", flags, max_active, 4);
btrfs_init_workers(&fs_info->rmw_workers, fs_info->rmw_workers =
"rmw", fs_info->thread_pool_size, btrfs_alloc_workqueue("rmw", flags, max_active, 2);
&fs_info->generic_worker);
fs_info->endio_write_workers = fs_info->endio_write_workers =
btrfs_alloc_workqueue("endio-write", flags, max_active, 2); btrfs_alloc_workqueue("endio-write", flags, max_active, 2);
fs_info->endio_freespace_worker = fs_info->endio_freespace_worker =
@ -2529,8 +2528,6 @@ 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);
fs_info->rmw_workers.idle_thresh = 2;
fs_info->readahead_workers.idle_thresh = 2; fs_info->readahead_workers.idle_thresh = 2;
/* /*
@ -2539,7 +2536,6 @@ 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->rmw_workers);
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);
@ -2553,7 +2549,7 @@ int open_ctree(struct super_block *sb,
fs_info->endio_workers && fs_info->endio_meta_workers && fs_info->endio_workers && fs_info->endio_meta_workers &&
fs_info->endio_meta_write_workers && fs_info->endio_meta_write_workers &&
fs_info->endio_write_workers && fs_info->endio_raid56_workers && fs_info->endio_write_workers && fs_info->endio_raid56_workers &&
fs_info->endio_freespace_worker)) { fs_info->endio_freespace_worker && fs_info->rmw_workers)) {
err = -ENOMEM; err = -ENOMEM;
goto fail_sb_buffer; goto fail_sb_buffer;
} }

View File

@ -87,7 +87,7 @@ struct btrfs_raid_bio {
/* /*
* for scheduling work in the helper threads * for scheduling work in the helper threads
*/ */
struct btrfs_work work; struct btrfs_work_struct work;
/* /*
* bio list and bio_list_lock are used * bio list and bio_list_lock are used
@ -166,8 +166,8 @@ struct btrfs_raid_bio {
static int __raid56_parity_recover(struct btrfs_raid_bio *rbio); static int __raid56_parity_recover(struct btrfs_raid_bio *rbio);
static noinline void finish_rmw(struct btrfs_raid_bio *rbio); static noinline void finish_rmw(struct btrfs_raid_bio *rbio);
static void rmw_work(struct btrfs_work *work); static void rmw_work(struct btrfs_work_struct *work);
static void read_rebuild_work(struct btrfs_work *work); static void read_rebuild_work(struct btrfs_work_struct *work);
static void async_rmw_stripe(struct btrfs_raid_bio *rbio); static void async_rmw_stripe(struct btrfs_raid_bio *rbio);
static void async_read_rebuild(struct btrfs_raid_bio *rbio); static void async_read_rebuild(struct btrfs_raid_bio *rbio);
static int fail_bio_stripe(struct btrfs_raid_bio *rbio, struct bio *bio); static int fail_bio_stripe(struct btrfs_raid_bio *rbio, struct bio *bio);
@ -1416,20 +1416,18 @@ cleanup:
static void async_rmw_stripe(struct btrfs_raid_bio *rbio) static void async_rmw_stripe(struct btrfs_raid_bio *rbio)
{ {
rbio->work.flags = 0; btrfs_init_work(&rbio->work, rmw_work, NULL, NULL);
rbio->work.func = rmw_work;
btrfs_queue_worker(&rbio->fs_info->rmw_workers, btrfs_queue_work(rbio->fs_info->rmw_workers,
&rbio->work); &rbio->work);
} }
static void async_read_rebuild(struct btrfs_raid_bio *rbio) static void async_read_rebuild(struct btrfs_raid_bio *rbio)
{ {
rbio->work.flags = 0; btrfs_init_work(&rbio->work, read_rebuild_work, NULL, NULL);
rbio->work.func = read_rebuild_work;
btrfs_queue_worker(&rbio->fs_info->rmw_workers, btrfs_queue_work(rbio->fs_info->rmw_workers,
&rbio->work); &rbio->work);
} }
/* /*
@ -1590,7 +1588,7 @@ struct btrfs_plug_cb {
struct blk_plug_cb cb; struct blk_plug_cb cb;
struct btrfs_fs_info *info; struct btrfs_fs_info *info;
struct list_head rbio_list; struct list_head rbio_list;
struct btrfs_work work; struct btrfs_work_struct work;
}; };
/* /*
@ -1654,7 +1652,7 @@ static void run_plug(struct btrfs_plug_cb *plug)
* if the unplug comes from schedule, we have to push the * if the unplug comes from schedule, we have to push the
* work off to a helper thread * work off to a helper thread
*/ */
static void unplug_work(struct btrfs_work *work) static void unplug_work(struct btrfs_work_struct *work)
{ {
struct btrfs_plug_cb *plug; struct btrfs_plug_cb *plug;
plug = container_of(work, struct btrfs_plug_cb, work); plug = container_of(work, struct btrfs_plug_cb, work);
@ -1667,10 +1665,9 @@ static void btrfs_raid_unplug(struct blk_plug_cb *cb, bool from_schedule)
plug = container_of(cb, struct btrfs_plug_cb, cb); plug = container_of(cb, struct btrfs_plug_cb, cb);
if (from_schedule) { if (from_schedule) {
plug->work.flags = 0; btrfs_init_work(&plug->work, unplug_work, NULL, NULL);
plug->work.func = unplug_work; btrfs_queue_work(plug->info->rmw_workers,
btrfs_queue_worker(&plug->info->rmw_workers, &plug->work);
&plug->work);
return; return;
} }
run_plug(plug); run_plug(plug);
@ -2082,7 +2079,7 @@ int raid56_parity_recover(struct btrfs_root *root, struct bio *bio,
} }
static void rmw_work(struct btrfs_work *work) static void rmw_work(struct btrfs_work_struct *work)
{ {
struct btrfs_raid_bio *rbio; struct btrfs_raid_bio *rbio;
@ -2090,7 +2087,7 @@ static void rmw_work(struct btrfs_work *work)
raid56_rmw_stripe(rbio); raid56_rmw_stripe(rbio);
} }
static void read_rebuild_work(struct btrfs_work *work) static void read_rebuild_work(struct btrfs_work_struct *work)
{ {
struct btrfs_raid_bio *rbio; struct btrfs_raid_bio *rbio;