Skip to content

Commit

Permalink
btrfs: reinitialize scrub workers
Browse files Browse the repository at this point in the history
Scrub starts the workers each time a scrub starts and stops them after it
finished. This patch adds an initialization for the workers before each
start, otherwise the workers behave strangely.

Signed-off-by: Arne Jansen <sensille@gmx.net>
  • Loading branch information
Arne Jansen committed Jun 10, 2011
1 parent 8c51032 commit 632dd77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 0 additions & 2 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1668,8 +1668,6 @@ struct btrfs_root *open_ctree(struct super_block *sb,
init_waitqueue_head(&fs_info->scrub_pause_wait);
init_rwsem(&fs_info->scrub_super_lock);
fs_info->scrub_workers_refcnt = 0;
btrfs_init_workers(&fs_info->scrub_workers, "scrub",
fs_info->thread_pool_size, &fs_info->generic_worker);

sb->s_blocksize = 4096;
sb->s_blocksize_bits = blksize_bits(4096);
Expand Down
6 changes: 5 additions & 1 deletion fs/btrfs/scrub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1166,8 +1166,12 @@ static noinline_for_stack int scrub_workers_get(struct btrfs_root *root)
struct btrfs_fs_info *fs_info = root->fs_info;

mutex_lock(&fs_info->scrub_lock);
if (fs_info->scrub_workers_refcnt == 0)
if (fs_info->scrub_workers_refcnt == 0) {
btrfs_init_workers(&fs_info->scrub_workers, "scrub",
fs_info->thread_pool_size, &fs_info->generic_worker);
fs_info->scrub_workers.idle_thresh = 4;
btrfs_start_workers(&fs_info->scrub_workers, 1);
}
++fs_info->scrub_workers_refcnt;
mutex_unlock(&fs_info->scrub_lock);

Expand Down

0 comments on commit 632dd77

Please sign in to comment.