* readahead one full node of leaves
*/
static void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
- int level, int slot)
+ int level, int slot, u64 objectid)
{
struct extent_buffer *node;
+ struct btrfs_disk_key disk_key;
u32 nritems;
u64 search;
u64 lowest_read;
if (nr >= nritems)
break;
}
+ if (path->reada < 0 && objectid) {
+ btrfs_node_key(node, &disk_key, nr);
+ if (btrfs_disk_key_objectid(&disk_key) != objectid)
+ break;
+ }
search = btrfs_node_blockptr(node, nr);
if ((search >= lowest_read && search <= highest_read) ||
(search < lowest_read && lowest_read - search <= 32768) ||
bytenr = btrfs_node_blockptr(b, slot);
ptr_gen = btrfs_node_ptr_generation(b, slot);
if (should_reada)
- reada_for_search(root, p, level, slot);
+ reada_for_search(root, p, level, slot,
+ key->objectid);
b = read_tree_block(root, bytenr,
btrfs_level_size(root, level - 1));
if (ptr_gen != btrfs_header_generation(b)) {
if (next)
free_extent_buffer(next);
- if (path->reada < 0)
- reada_for_search(root, path, level, slot);
-
next = read_tree_block(root, bytenr,
btrfs_level_size(root, level - 1));
break;
path->slots[level] = 0;
if (!level)
break;
- if (path->reada)
- reada_for_search(root, path, level, 0);
next = read_tree_block(root, btrfs_node_blockptr(next, 0),
btrfs_level_size(root, level - 1));
}
free_extent_buffer(next);
if (path->reada)
- reada_for_search(root, path, level, slot);
+ reada_for_search(root, path, level, slot, 0);
next = read_tree_block(root, bytenr,
btrfs_level_size(root, level -1));
if (!level)
break;
if (path->reada)
- reada_for_search(root, path, level, 0);
+ reada_for_search(root, path, level, 0, 0);
next = read_tree_block(root, btrfs_node_blockptr(next, 0),
btrfs_level_size(root, level - 1));
}