diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-12-21 16:24:26 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:03:58 -0400 |
commit | 01f466580502c57001bf80fff709479fdb9e87a5 (patch) | |
tree | 745beecd2717f312f62784f368f42f1affdc112c /fs | |
parent | 879c1cfc3104b632dea85d07490f1b55e54275a9 (diff) |
Btrfs: Less aggressive readahead on deletes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ctree.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 7f764455f26e..2b3ffa707eae 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -987,9 +987,10 @@ static int push_nodes_for_insert(struct btrfs_trans_handle *trans, | |||
987 | * readahead one full node of leaves | 987 | * readahead one full node of leaves |
988 | */ | 988 | */ |
989 | static void reada_for_search(struct btrfs_root *root, struct btrfs_path *path, | 989 | static void reada_for_search(struct btrfs_root *root, struct btrfs_path *path, |
990 | int level, int slot) | 990 | int level, int slot, u64 objectid) |
991 | { | 991 | { |
992 | struct extent_buffer *node; | 992 | struct extent_buffer *node; |
993 | struct btrfs_disk_key disk_key; | ||
993 | u32 nritems; | 994 | u32 nritems; |
994 | u64 search; | 995 | u64 search; |
995 | u64 lowest_read; | 996 | u64 lowest_read; |
@@ -1031,6 +1032,11 @@ static void reada_for_search(struct btrfs_root *root, struct btrfs_path *path, | |||
1031 | if (nr >= nritems) | 1032 | if (nr >= nritems) |
1032 | break; | 1033 | break; |
1033 | } | 1034 | } |
1035 | if (path->reada < 0 && objectid) { | ||
1036 | btrfs_node_key(node, &disk_key, nr); | ||
1037 | if (btrfs_disk_key_objectid(&disk_key) != objectid) | ||
1038 | break; | ||
1039 | } | ||
1034 | search = btrfs_node_blockptr(node, nr); | 1040 | search = btrfs_node_blockptr(node, nr); |
1035 | if ((search >= lowest_read && search <= highest_read) || | 1041 | if ((search >= lowest_read && search <= highest_read) || |
1036 | (search < lowest_read && lowest_read - search <= 32768) || | 1042 | (search < lowest_read && lowest_read - search <= 32768) || |
@@ -1136,7 +1142,8 @@ again: | |||
1136 | bytenr = btrfs_node_blockptr(b, slot); | 1142 | bytenr = btrfs_node_blockptr(b, slot); |
1137 | ptr_gen = btrfs_node_ptr_generation(b, slot); | 1143 | ptr_gen = btrfs_node_ptr_generation(b, slot); |
1138 | if (should_reada) | 1144 | if (should_reada) |
1139 | reada_for_search(root, p, level, slot); | 1145 | reada_for_search(root, p, level, slot, |
1146 | key->objectid); | ||
1140 | b = read_tree_block(root, bytenr, | 1147 | b = read_tree_block(root, bytenr, |
1141 | btrfs_level_size(root, level - 1)); | 1148 | btrfs_level_size(root, level - 1)); |
1142 | if (ptr_gen != btrfs_header_generation(b)) { | 1149 | if (ptr_gen != btrfs_header_generation(b)) { |
@@ -2671,9 +2678,6 @@ int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path) | |||
2671 | if (next) | 2678 | if (next) |
2672 | free_extent_buffer(next); | 2679 | free_extent_buffer(next); |
2673 | 2680 | ||
2674 | if (path->reada < 0) | ||
2675 | reada_for_search(root, path, level, slot); | ||
2676 | |||
2677 | next = read_tree_block(root, bytenr, | 2681 | next = read_tree_block(root, bytenr, |
2678 | btrfs_level_size(root, level - 1)); | 2682 | btrfs_level_size(root, level - 1)); |
2679 | break; | 2683 | break; |
@@ -2687,8 +2691,6 @@ int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path) | |||
2687 | path->slots[level] = 0; | 2691 | path->slots[level] = 0; |
2688 | if (!level) | 2692 | if (!level) |
2689 | break; | 2693 | break; |
2690 | if (path->reada) | ||
2691 | reada_for_search(root, path, level, 0); | ||
2692 | next = read_tree_block(root, btrfs_node_blockptr(next, 0), | 2694 | next = read_tree_block(root, btrfs_node_blockptr(next, 0), |
2693 | btrfs_level_size(root, level - 1)); | 2695 | btrfs_level_size(root, level - 1)); |
2694 | } | 2696 | } |
@@ -2726,7 +2728,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path) | |||
2726 | free_extent_buffer(next); | 2728 | free_extent_buffer(next); |
2727 | 2729 | ||
2728 | if (path->reada) | 2730 | if (path->reada) |
2729 | reada_for_search(root, path, level, slot); | 2731 | reada_for_search(root, path, level, slot, 0); |
2730 | 2732 | ||
2731 | next = read_tree_block(root, bytenr, | 2733 | next = read_tree_block(root, bytenr, |
2732 | btrfs_level_size(root, level -1)); | 2734 | btrfs_level_size(root, level -1)); |
@@ -2742,7 +2744,7 @@ int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path) | |||
2742 | if (!level) | 2744 | if (!level) |
2743 | break; | 2745 | break; |
2744 | if (path->reada) | 2746 | if (path->reada) |
2745 | reada_for_search(root, path, level, 0); | 2747 | reada_for_search(root, path, level, 0, 0); |
2746 | next = read_tree_block(root, btrfs_node_blockptr(next, 0), | 2748 | next = read_tree_block(root, btrfs_node_blockptr(next, 0), |
2747 | btrfs_level_size(root, level - 1)); | 2749 | btrfs_level_size(root, level - 1)); |
2748 | } | 2750 | } |