aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-01-02 10:01:11 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:58 -0400
commit8f662a76c6af8eb367fa519e9bb9766040d9cea8 (patch)
tree3072a4d35c49e2c884f41d044dec4950bf95c3b3
parente52ec0eb62e76ea584c8438ef92933e9b815db80 (diff)
Btrfs: Add readahead to the online shrinker, and a mount -o alloc_start= for testing
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/ctree.c9
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/extent-tree.c9
-rw-r--r--fs/btrfs/inode.c2
-rw-r--r--fs/btrfs/super.c16
5 files changed, 28 insertions, 9 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 2b3ffa707eae..8fa92a2d9819 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2654,9 +2654,9 @@ int btrfs_del_item(struct btrfs_trans_handle *trans, struct btrfs_root *root,
2654 */ 2654 */
2655int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path) 2655int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path)
2656{ 2656{
2657 u64 bytenr;
2657 int slot; 2658 int slot;
2658 int level = 1; 2659 int level = 1;
2659 u64 bytenr;
2660 struct extent_buffer *c; 2660 struct extent_buffer *c;
2661 struct extent_buffer *next = NULL; 2661 struct extent_buffer *next = NULL;
2662 2662
@@ -2687,11 +2687,14 @@ int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path)
2687 level--; 2687 level--;
2688 c = path->nodes[level]; 2688 c = path->nodes[level];
2689 free_extent_buffer(c); 2689 free_extent_buffer(c);
2690 slot = btrfs_header_nritems(next);
2691 if (slot != 0)
2692 slot--;
2690 path->nodes[level] = next; 2693 path->nodes[level] = next;
2691 path->slots[level] = 0; 2694 path->slots[level] = slot;
2692 if (!level) 2695 if (!level)
2693 break; 2696 break;
2694 next = read_tree_block(root, btrfs_node_blockptr(next, 0), 2697 next = read_tree_block(root, btrfs_node_blockptr(next, slot),
2695 btrfs_level_size(root, level - 1)); 2698 btrfs_level_size(root, level - 1));
2696 } 2699 }
2697 return 0; 2700 return 0;
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b83a1bec346f..d6e5c19969b0 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -324,6 +324,7 @@ struct btrfs_fs_info {
324 u64 last_trans_committed; 324 u64 last_trans_committed;
325 unsigned long mount_opt; 325 unsigned long mount_opt;
326 u64 max_extent; 326 u64 max_extent;
327 u64 alloc_start;
327 struct btrfs_transaction *running_transaction; 328 struct btrfs_transaction *running_transaction;
328 struct btrfs_super_block super_copy; 329 struct btrfs_super_block super_copy;
329 struct extent_buffer *sb_buffer; 330 struct extent_buffer *sb_buffer;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index a421069e998b..d6243c2afc73 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1630,11 +1630,11 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
1630 struct btrfs_path *path; 1630 struct btrfs_path *path;
1631 1631
1632 btrfs_set_stack_extent_refs(&extent_item, 1); 1632 btrfs_set_stack_extent_refs(&extent_item, 1);
1633#if 0 1633
1634 new_hint = max(hint_byte, 16ULL * 1024 * 1024 * 1024); 1634 new_hint = max(hint_byte, root->fs_info->alloc_start);
1635 if (new_hint < btrfs_super_total_bytes(&info->super_copy)) 1635 if (new_hint < btrfs_super_total_bytes(&info->super_copy))
1636 hint_byte = new_hint; 1636 hint_byte = new_hint;
1637#endif 1637
1638 WARN_ON(num_bytes < root->sectorsize); 1638 WARN_ON(num_bytes < root->sectorsize);
1639 ret = find_free_extent(trans, root, num_bytes, empty_size, 1639 ret = find_free_extent(trans, root, num_bytes, empty_size,
1640 search_start, search_end, hint_byte, ins, 1640 search_start, search_end, hint_byte, ins,
@@ -2239,7 +2239,7 @@ static int relocate_one_reference(struct btrfs_root *extent_root,
2239 free_extent_buffer(eb); 2239 free_extent_buffer(eb);
2240 2240
2241 path->lowest_level = level; 2241 path->lowest_level = level;
2242 path->reada = 0; 2242 path->reada = 2;
2243 ret = btrfs_search_slot(trans, found_root, &found_key, path, 2243 ret = btrfs_search_slot(trans, found_root, &found_key, path,
2244 0, 1); 2244 0, 1);
2245 path->lowest_level = 0; 2245 path->lowest_level = 0;
@@ -2372,6 +2372,7 @@ int btrfs_shrink_extent_tree(struct btrfs_root *root, u64 new_size)
2372 block_group_cache = &info->block_group_cache; 2372 block_group_cache = &info->block_group_cache;
2373 path = btrfs_alloc_path(); 2373 path = btrfs_alloc_path();
2374 root = root->fs_info->extent_root; 2374 root = root->fs_info->extent_root;
2375 path->reada = 2;
2375 2376
2376again: 2377again:
2377 total_found = 0; 2378 total_found = 0;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3c7bf3bddcad..d6de46961887 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2058,7 +2058,7 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct page *page)
2058 2058
2059 mutex_lock(&root->fs_info->fs_mutex); 2059 mutex_lock(&root->fs_info->fs_mutex);
2060 ret = btrfs_check_free_space(root, PAGE_CACHE_SIZE, 0); 2060 ret = btrfs_check_free_space(root, PAGE_CACHE_SIZE, 0);
2061 mutex_lock(&root->fs_info->fs_mutex); 2061 mutex_unlock(&root->fs_info->fs_mutex);
2062 if (ret) 2062 if (ret)
2063 goto out; 2063 goto out;
2064 2064
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 3bbd7f665694..f1b56eb77b1d 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -63,7 +63,8 @@ static void btrfs_put_super (struct super_block * sb)
63} 63}
64 64
65enum { 65enum {
66 Opt_subvol, Opt_nodatasum, Opt_nodatacow, Opt_max_extent, Opt_err, 66 Opt_subvol, Opt_nodatasum, Opt_nodatacow, Opt_max_extent,
67 Opt_alloc_start, Opt_err,
67}; 68};
68 69
69static match_table_t tokens = { 70static match_table_t tokens = {
@@ -71,6 +72,7 @@ static match_table_t tokens = {
71 {Opt_nodatasum, "nodatasum"}, 72 {Opt_nodatasum, "nodatasum"},
72 {Opt_nodatacow, "nodatacow"}, 73 {Opt_nodatacow, "nodatacow"},
73 {Opt_max_extent, "max_extent=%s"}, 74 {Opt_max_extent, "max_extent=%s"},
75 {Opt_alloc_start, "alloc_start=%s"},
74 {Opt_err, NULL} 76 {Opt_err, NULL}
75}; 77};
76 78
@@ -162,6 +164,18 @@ static int parse_options (char * options,
162 } 164 }
163 } 165 }
164 break; 166 break;
167 case Opt_alloc_start:
168 if (info) {
169 char *num = match_strdup(&args[0]);
170 if (num) {
171 info->alloc_start =
172 btrfs_parse_size(num);
173 kfree(num);
174 printk("btrfs: allocations start at "
175 "%Lu\n", info->alloc_start);
176 }
177 }
178 break;
165 default: 179 default:
166 break; 180 break;
167 } 181 }