diff options
-rw-r--r-- | fs/btrfs/ctree.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 9e46c0776816..2603ee539b7a 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -1210,8 +1210,7 @@ static noinline void reada_for_search(struct btrfs_root *root, | |||
1210 | struct btrfs_disk_key disk_key; | 1210 | struct btrfs_disk_key disk_key; |
1211 | u32 nritems; | 1211 | u32 nritems; |
1212 | u64 search; | 1212 | u64 search; |
1213 | u64 lowest_read; | 1213 | u64 target; |
1214 | u64 highest_read; | ||
1215 | u64 nread = 0; | 1214 | u64 nread = 0; |
1216 | int direction = path->reada; | 1215 | int direction = path->reada; |
1217 | struct extent_buffer *eb; | 1216 | struct extent_buffer *eb; |
@@ -1235,8 +1234,7 @@ static noinline void reada_for_search(struct btrfs_root *root, | |||
1235 | return; | 1234 | return; |
1236 | } | 1235 | } |
1237 | 1236 | ||
1238 | highest_read = search; | 1237 | target = search; |
1239 | lowest_read = search; | ||
1240 | 1238 | ||
1241 | nritems = btrfs_header_nritems(node); | 1239 | nritems = btrfs_header_nritems(node); |
1242 | nr = slot; | 1240 | nr = slot; |
@@ -1256,24 +1254,15 @@ static noinline void reada_for_search(struct btrfs_root *root, | |||
1256 | break; | 1254 | break; |
1257 | } | 1255 | } |
1258 | search = btrfs_node_blockptr(node, nr); | 1256 | search = btrfs_node_blockptr(node, nr); |
1259 | if ((search >= lowest_read && search <= highest_read) || | 1257 | if ((search <= target && target - search <= 65536) || |
1260 | (search < lowest_read && lowest_read - search <= 16384) || | 1258 | (search > target && search - target <= 65536)) { |
1261 | (search > highest_read && search - highest_read <= 16384)) { | ||
1262 | readahead_tree_block(root, search, blocksize, | 1259 | readahead_tree_block(root, search, blocksize, |
1263 | btrfs_node_ptr_generation(node, nr)); | 1260 | btrfs_node_ptr_generation(node, nr)); |
1264 | nread += blocksize; | 1261 | nread += blocksize; |
1265 | } | 1262 | } |
1266 | nscan++; | 1263 | nscan++; |
1267 | if (path->reada < 2 && (nread > (64 * 1024) || nscan > 32)) | 1264 | if ((nread > 65536 || nscan > 32)) |
1268 | break; | 1265 | break; |
1269 | |||
1270 | if (nread > (256 * 1024) || nscan > 128) | ||
1271 | break; | ||
1272 | |||
1273 | if (search < lowest_read) | ||
1274 | lowest_read = search; | ||
1275 | if (search > highest_read) | ||
1276 | highest_read = search; | ||
1277 | } | 1266 | } |
1278 | } | 1267 | } |
1279 | 1268 | ||