diff options
author | Arne Jansen <sensille@gmx.net> | 2011-05-23 08:30:00 -0400 |
---|---|---|
committer | Arne Jansen <sensille@gmx.net> | 2011-10-02 02:48:30 -0400 |
commit | 90519d66abbccc251d14719ac76f191f70826e40 (patch) | |
tree | 93cad519db9f4f0c97abd89d405ea1e0fec306a7 | |
parent | ab0fff03055d2d1b01a7581badeba18db9c4f55c (diff) |
btrfs: state information for readahead
Add state information for readahead to btrfs_fs_info and btrfs_device
Changes v2:
- don't wait in radix_trees
- add own set of workers for readahead
Reviewed-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Arne Jansen <sensille@gmx.net>
-rw-r--r-- | fs/btrfs/ctree.h | 5 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 10 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 8 | ||||
-rw-r--r-- | fs/btrfs/volumes.h | 8 |
4 files changed, 31 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 03912c5c6f49..f71fd24cc152 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1036,6 +1036,7 @@ struct btrfs_fs_info { | |||
1036 | struct btrfs_workers endio_freespace_worker; | 1036 | struct btrfs_workers endio_freespace_worker; |
1037 | struct btrfs_workers submit_workers; | 1037 | struct btrfs_workers submit_workers; |
1038 | struct btrfs_workers caching_workers; | 1038 | struct btrfs_workers caching_workers; |
1039 | struct btrfs_workers readahead_workers; | ||
1039 | 1040 | ||
1040 | /* | 1041 | /* |
1041 | * fixup workers take dirty pages that didn't properly go through | 1042 | * fixup workers take dirty pages that didn't properly go through |
@@ -1119,6 +1120,10 @@ struct btrfs_fs_info { | |||
1119 | u64 fs_state; | 1120 | u64 fs_state; |
1120 | 1121 | ||
1121 | struct btrfs_delayed_root *delayed_root; | 1122 | struct btrfs_delayed_root *delayed_root; |
1123 | |||
1124 | /* readahead tree */ | ||
1125 | spinlock_t reada_lock; | ||
1126 | struct radix_tree_root reada_tree; | ||
1122 | }; | 1127 | }; |
1123 | 1128 | ||
1124 | /* | 1129 | /* |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 1220d04072c8..fd28c40e9ec3 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1711,6 +1711,10 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1711 | fs_info->defrag_inodes = RB_ROOT; | 1711 | fs_info->defrag_inodes = RB_ROOT; |
1712 | fs_info->trans_no_join = 0; | 1712 | fs_info->trans_no_join = 0; |
1713 | 1713 | ||
1714 | /* readahead state */ | ||
1715 | INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS & ~__GFP_WAIT); | ||
1716 | spin_lock_init(&fs_info->reada_lock); | ||
1717 | |||
1714 | fs_info->thread_pool_size = min_t(unsigned long, | 1718 | fs_info->thread_pool_size = min_t(unsigned long, |
1715 | num_online_cpus() + 2, 8); | 1719 | num_online_cpus() + 2, 8); |
1716 | 1720 | ||
@@ -1903,6 +1907,9 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1903 | btrfs_init_workers(&fs_info->delayed_workers, "delayed-meta", | 1907 | btrfs_init_workers(&fs_info->delayed_workers, "delayed-meta", |
1904 | fs_info->thread_pool_size, | 1908 | fs_info->thread_pool_size, |
1905 | &fs_info->generic_worker); | 1909 | &fs_info->generic_worker); |
1910 | btrfs_init_workers(&fs_info->readahead_workers, "readahead", | ||
1911 | fs_info->thread_pool_size, | ||
1912 | &fs_info->generic_worker); | ||
1906 | 1913 | ||
1907 | /* | 1914 | /* |
1908 | * endios are largely parallel and should have a very | 1915 | * endios are largely parallel and should have a very |
@@ -1913,6 +1920,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1913 | 1920 | ||
1914 | fs_info->endio_write_workers.idle_thresh = 2; | 1921 | fs_info->endio_write_workers.idle_thresh = 2; |
1915 | fs_info->endio_meta_write_workers.idle_thresh = 2; | 1922 | fs_info->endio_meta_write_workers.idle_thresh = 2; |
1923 | fs_info->readahead_workers.idle_thresh = 2; | ||
1916 | 1924 | ||
1917 | btrfs_start_workers(&fs_info->workers, 1); | 1925 | btrfs_start_workers(&fs_info->workers, 1); |
1918 | btrfs_start_workers(&fs_info->generic_worker, 1); | 1926 | btrfs_start_workers(&fs_info->generic_worker, 1); |
@@ -1926,6 +1934,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1926 | btrfs_start_workers(&fs_info->endio_freespace_worker, 1); | 1934 | btrfs_start_workers(&fs_info->endio_freespace_worker, 1); |
1927 | btrfs_start_workers(&fs_info->delayed_workers, 1); | 1935 | btrfs_start_workers(&fs_info->delayed_workers, 1); |
1928 | btrfs_start_workers(&fs_info->caching_workers, 1); | 1936 | btrfs_start_workers(&fs_info->caching_workers, 1); |
1937 | btrfs_start_workers(&fs_info->readahead_workers, 1); | ||
1929 | 1938 | ||
1930 | fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); | 1939 | fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); |
1931 | fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, | 1940 | fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, |
@@ -2650,6 +2659,7 @@ int close_ctree(struct btrfs_root *root) | |||
2650 | btrfs_stop_workers(&fs_info->submit_workers); | 2659 | btrfs_stop_workers(&fs_info->submit_workers); |
2651 | btrfs_stop_workers(&fs_info->delayed_workers); | 2660 | btrfs_stop_workers(&fs_info->delayed_workers); |
2652 | btrfs_stop_workers(&fs_info->caching_workers); | 2661 | btrfs_stop_workers(&fs_info->caching_workers); |
2662 | btrfs_stop_workers(&fs_info->readahead_workers); | ||
2653 | 2663 | ||
2654 | btrfs_close_devices(fs_info->fs_devices); | 2664 | btrfs_close_devices(fs_info->fs_devices); |
2655 | btrfs_mapping_tree_free(&fs_info->mapping_tree); | 2665 | btrfs_mapping_tree_free(&fs_info->mapping_tree); |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index f2a4cc79da61..1dccce5bc93d 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -366,6 +366,14 @@ static noinline int device_list_add(const char *path, | |||
366 | } | 366 | } |
367 | INIT_LIST_HEAD(&device->dev_alloc_list); | 367 | INIT_LIST_HEAD(&device->dev_alloc_list); |
368 | 368 | ||
369 | /* init readahead state */ | ||
370 | spin_lock_init(&device->reada_lock); | ||
371 | device->reada_curr_zone = NULL; | ||
372 | atomic_set(&device->reada_in_flight, 0); | ||
373 | device->reada_next = 0; | ||
374 | INIT_RADIX_TREE(&device->reada_zones, GFP_NOFS & ~__GFP_WAIT); | ||
375 | INIT_RADIX_TREE(&device->reada_extents, GFP_NOFS & ~__GFP_WAIT); | ||
376 | |||
369 | mutex_lock(&fs_devices->device_list_mutex); | 377 | mutex_lock(&fs_devices->device_list_mutex); |
370 | list_add_rcu(&device->dev_list, &fs_devices->devices); | 378 | list_add_rcu(&device->dev_list, &fs_devices->devices); |
371 | mutex_unlock(&fs_devices->device_list_mutex); | 379 | mutex_unlock(&fs_devices->device_list_mutex); |
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 6d866db4e177..2a751246188a 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h | |||
@@ -92,6 +92,14 @@ struct btrfs_device { | |||
92 | struct btrfs_work work; | 92 | struct btrfs_work work; |
93 | struct rcu_head rcu; | 93 | struct rcu_head rcu; |
94 | struct work_struct rcu_work; | 94 | struct work_struct rcu_work; |
95 | |||
96 | /* readahead state */ | ||
97 | spinlock_t reada_lock; | ||
98 | atomic_t reada_in_flight; | ||
99 | u64 reada_next; | ||
100 | struct reada_zone *reada_curr_zone; | ||
101 | struct radix_tree_root reada_zones; | ||
102 | struct radix_tree_root reada_extents; | ||
95 | }; | 103 | }; |
96 | 104 | ||
97 | struct btrfs_fs_devices { | 105 | struct btrfs_fs_devices { |