aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-06-30 14:42:28 -0400
committerChris Mason <chris.mason@oracle.com>2011-07-27 12:46:25 -0400
commitbab39bf998133510f2dad08158006197ec0dabea (patch)
tree0ea50b2b07a9f75988829de6c42b6936e2355545 /fs/btrfs/disk-io.c
parentdf98b6e2c52f65665eaf0fc23e647fb64335b289 (diff)
Btrfs: use a worker thread to do caching
A user reported a deadlock when copying a bunch of files. This is because they were low on memory and kthreadd got hung up trying to migrate pages for an allocation when starting the caching kthread. The page was locked by the person starting the caching kthread. To fix this we just need to use the async thread stuff so that the threads are already created and we don't have to worry about deadlocks. Thanks, Reported-by: Roman Mamedov <rm@romanrm.ru> Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1ac8db5dc0a3..234a08404fc2 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1807,6 +1807,9 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1807 fs_info->thread_pool_size), 1807 fs_info->thread_pool_size),
1808 &fs_info->generic_worker); 1808 &fs_info->generic_worker);
1809 1809
1810 btrfs_init_workers(&fs_info->caching_workers, "cache",
1811 2, &fs_info->generic_worker);
1812
1810 /* a higher idle thresh on the submit workers makes it much more 1813 /* a higher idle thresh on the submit workers makes it much more
1811 * likely that bios will be send down in a sane order to the 1814 * likely that bios will be send down in a sane order to the
1812 * devices 1815 * devices
@@ -1860,6 +1863,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1860 btrfs_start_workers(&fs_info->endio_write_workers, 1); 1863 btrfs_start_workers(&fs_info->endio_write_workers, 1);
1861 btrfs_start_workers(&fs_info->endio_freespace_worker, 1); 1864 btrfs_start_workers(&fs_info->endio_freespace_worker, 1);
1862 btrfs_start_workers(&fs_info->delayed_workers, 1); 1865 btrfs_start_workers(&fs_info->delayed_workers, 1);
1866 btrfs_start_workers(&fs_info->caching_workers, 1);
1863 1867
1864 fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); 1868 fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super);
1865 fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, 1869 fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages,
@@ -2117,6 +2121,7 @@ fail_sb_buffer:
2117 btrfs_stop_workers(&fs_info->endio_freespace_worker); 2121 btrfs_stop_workers(&fs_info->endio_freespace_worker);
2118 btrfs_stop_workers(&fs_info->submit_workers); 2122 btrfs_stop_workers(&fs_info->submit_workers);
2119 btrfs_stop_workers(&fs_info->delayed_workers); 2123 btrfs_stop_workers(&fs_info->delayed_workers);
2124 btrfs_stop_workers(&fs_info->caching_workers);
2120fail_alloc: 2125fail_alloc:
2121 kfree(fs_info->delayed_root); 2126 kfree(fs_info->delayed_root);
2122fail_iput: 2127fail_iput:
@@ -2584,6 +2589,7 @@ int close_ctree(struct btrfs_root *root)
2584 btrfs_stop_workers(&fs_info->endio_freespace_worker); 2589 btrfs_stop_workers(&fs_info->endio_freespace_worker);
2585 btrfs_stop_workers(&fs_info->submit_workers); 2590 btrfs_stop_workers(&fs_info->submit_workers);
2586 btrfs_stop_workers(&fs_info->delayed_workers); 2591 btrfs_stop_workers(&fs_info->delayed_workers);
2592 btrfs_stop_workers(&fs_info->caching_workers);
2587 2593
2588 btrfs_close_devices(fs_info->fs_devices); 2594 btrfs_close_devices(fs_info->fs_devices);
2589 btrfs_mapping_tree_free(&fs_info->mapping_tree); 2595 btrfs_mapping_tree_free(&fs_info->mapping_tree);