Commit 026fd317 authored by Josef Bacik's avatar Josef Bacik

Btrfs: don't always do readahead

Our readahead is sort of sloppy, and really isn't always needed.  For example if
ls is doing a stating ls (which is the default) it's going to stat in non-disk
order, so if say you have a directory with a stupid amount of files, readahead
is going to do nothing but waste time in the case of doing the stat.  Taking the
unconditional readahead out made my test go from 57 minutes to 36 minutes.  This
means that everywhere we do loop through the tree we want to make sure we do set
path->reada properly, so I went through and found all of the places where we
loop through the path and set reada to 1.  Thanks,
Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
parent 589d8ade
...@@ -48,8 +48,6 @@ struct btrfs_path *btrfs_alloc_path(void) ...@@ -48,8 +48,6 @@ struct btrfs_path *btrfs_alloc_path(void)
{ {
struct btrfs_path *path; struct btrfs_path *path;
path = kmem_cache_zalloc(btrfs_path_cachep, GFP_NOFS); path = kmem_cache_zalloc(btrfs_path_cachep, GFP_NOFS);
if (path)
path->reada = 1;
return path; return path;
} }
......
...@@ -347,7 +347,7 @@ static int caching_kthread(void *data) ...@@ -347,7 +347,7 @@ static int caching_kthread(void *data)
*/ */
path->skip_locking = 1; path->skip_locking = 1;
path->search_commit_root = 1; path->search_commit_root = 1;
path->reada = 2; path->reada = 1;
key.objectid = last; key.objectid = last;
key.offset = 0; key.offset = 0;
...@@ -8556,6 +8556,7 @@ int btrfs_read_block_groups(struct btrfs_root *root) ...@@ -8556,6 +8556,7 @@ int btrfs_read_block_groups(struct btrfs_root *root)
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
path->reada = 1;
cache_gen = btrfs_super_cache_generation(&root->fs_info->super_copy); cache_gen = btrfs_super_cache_generation(&root->fs_info->super_copy);
if (cache_gen != 0 && if (cache_gen != 0 &&
......
...@@ -4242,7 +4242,9 @@ static int btrfs_real_readdir(struct file *filp, void *dirent, ...@@ -4242,7 +4242,9 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
filp->f_pos = 2; filp->f_pos = 2;
} }
path = btrfs_alloc_path(); path = btrfs_alloc_path();
path->reada = 2; if (!path)
return -ENOMEM;
path->reada = 1;
btrfs_set_key_type(&key, key_type); btrfs_set_key_type(&key, key_type);
key.offset = filp->f_pos; key.offset = filp->f_pos;
...@@ -5043,7 +5045,15 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page, ...@@ -5043,7 +5045,15 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
if (!path) { if (!path) {
path = btrfs_alloc_path(); path = btrfs_alloc_path();
BUG_ON(!path); if (!path) {
err = -ENOMEM;
goto out;
}
/*
* Chances are we'll be called again, so go ahead and do
* readahead
*/
path->reada = 1;
} }
ret = btrfs_lookup_file_extent(trans, root, path, ret = btrfs_lookup_file_extent(trans, root, path,
......
...@@ -676,6 +676,8 @@ struct backref_node *build_backref_tree(struct reloc_control *rc, ...@@ -676,6 +676,8 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
path1->reada = 1;
path2->reada = 2;
node = alloc_backref_node(cache); node = alloc_backref_node(cache);
if (!node) { if (!node) {
...@@ -1996,6 +1998,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc, ...@@ -1996,6 +1998,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
path->reada = 1;
reloc_root = root->reloc_root; reloc_root = root->reloc_root;
root_item = &reloc_root->root_item; root_item = &reloc_root->root_item;
...@@ -3297,6 +3300,7 @@ static int find_data_references(struct reloc_control *rc, ...@@ -3297,6 +3300,7 @@ static int find_data_references(struct reloc_control *rc,
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
path->reada = 1;
root = read_fs_root(rc->extent_root->fs_info, ref_root); root = read_fs_root(rc->extent_root->fs_info, ref_root);
if (IS_ERR(root)) { if (IS_ERR(root)) {
...@@ -3665,6 +3669,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) ...@@ -3665,6 +3669,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
path->reada = 1;
ret = prepare_to_relocate(rc); ret = prepare_to_relocate(rc);
if (ret) { if (ret) {
...@@ -4090,6 +4095,7 @@ int btrfs_recover_relocation(struct btrfs_root *root) ...@@ -4090,6 +4095,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
path->reada = -1;
key.objectid = BTRFS_TREE_RELOC_OBJECTID; key.objectid = BTRFS_TREE_RELOC_OBJECTID;
key.type = BTRFS_ROOT_ITEM_KEY; key.type = BTRFS_ROOT_ITEM_KEY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment