Miao Xie
2009-Dec-15 06:54 UTC
[PATCH 1/4] btrfs: fix the bug that __tree_search() returns the wrong result in extent_map.c
__tree_search() returns the reverse result about the prev node and the next node. And we can get the prev node and the next node directly by rb_prev() and rb_next(), so it is unnecessary to use while loop to get them. This patch fixes this bug of the wrong result. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> --- fs/btrfs/extent_map.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c index 46bea0f..16744f4 100644 --- a/fs/btrfs/extent_map.c +++ b/fs/btrfs/extent_map.c @@ -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; -- 1.6.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Reasonably Related Threads
- [PATCH 7/8] Make fallocate(2) more ENOSPC friendly
- menu system behaviour with empty config file
- [PATCH] Btrfs: do not hold the write_lock on the extent tree while logging V2
- [PATCH] check return value in extent map allocation
- [PATCH] Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...)) - generated by Coccinelle