public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] btrfs: fix the bug that __tree_search() returns the wrong result in extent_map.c
@ 2009-12-15  6:54 Miao Xie
  0 siblings, 0 replies; only message in thread
From: Miao Xie @ 2009-12-15  6:54 UTC (permalink / raw)
  To: Chris Mason; +Cc: Linux Btrfs

__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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-12-15  6:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-15  6:54 [PATCH 1/4] btrfs: fix the bug that __tree_search() returns the wrong result in extent_map.c Miao Xie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox