@@ -136,20 +136,15 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset,
if (prev_ret) {
orig_prev = prev;
- while (prev && offset >= extent_map_end(prev_entry)) {
- prev = rb_next(prev);
- prev_entry = rb_entry(prev, struct extent_map, rb_node);
- }
+ if (prev && offset < prev_entry->start)
+ prev = rb_prev(prev);
*prev_ret = prev;
prev = orig_prev;
}
if (next_ret) {
- prev_entry = rb_entry(prev, struct extent_map, rb_node);
- while (prev && offset < prev_entry->start) {
- prev = rb_prev(prev);
- prev_entry = rb_entry(prev, struct extent_map, rb_node);
- }
+ if (prev && offset >= extent_map_end(prev_entry))
+ prev = rb_next(prev);
*next_ret = prev;
}
return NULL;