]>
Commit | Line | Data |
---|---|---|
208fc782 GKH |
1 | From 7d1fedb6e96a960aa91e4ff70714c3fb09195a5a Mon Sep 17 00:00:00 2001 |
2 | From: Vinothkumar Raja <vinraja@cs.stonybrook.edu> | |
3 | Date: Thu, 6 Apr 2017 22:09:38 -0400 | |
4 | Subject: dm btree: fix for dm_btree_find_lowest_key() | |
5 | ||
6 | From: Vinothkumar Raja <vinraja@cs.stonybrook.edu> | |
7 | ||
8 | commit 7d1fedb6e96a960aa91e4ff70714c3fb09195a5a upstream. | |
9 | ||
10 | dm_btree_find_lowest_key() is giving incorrect results. find_key() | |
11 | traverses the btree correctly for finding the highest key, but there is | |
12 | an error in the way it traverses the btree for retrieving the lowest | |
13 | key. dm_btree_find_lowest_key() fetches the first key of the rightmost | |
14 | block of the btree instead of fetching the first key from the leftmost | |
15 | block. | |
16 | ||
17 | Fix this by conditionally passing the correct parameter to value64() | |
18 | based on the @find_highest flag. | |
19 | ||
20 | Signed-off-by: Erez Zadok <ezk@fsl.cs.sunysb.edu> | |
21 | Signed-off-by: Vinothkumar Raja <vinraja@cs.stonybrook.edu> | |
22 | Signed-off-by: Nidhi Panpalia <npanpalia@cs.stonybrook.edu> | |
23 | Signed-off-by: Mike Snitzer <snitzer@redhat.com> | |
24 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
25 | ||
26 | --- | |
27 | drivers/md/persistent-data/dm-btree.c | 8 ++++++-- | |
28 | 1 file changed, 6 insertions(+), 2 deletions(-) | |
29 | ||
30 | --- a/drivers/md/persistent-data/dm-btree.c | |
31 | +++ b/drivers/md/persistent-data/dm-btree.c | |
32 | @@ -897,8 +897,12 @@ static int find_key(struct ro_spine *s, | |
33 | else | |
34 | *result_key = le64_to_cpu(ro_node(s)->keys[0]); | |
35 | ||
36 | - if (next_block || flags & INTERNAL_NODE) | |
37 | - block = value64(ro_node(s), i); | |
38 | + if (next_block || flags & INTERNAL_NODE) { | |
39 | + if (find_highest) | |
40 | + block = value64(ro_node(s), i); | |
41 | + else | |
42 | + block = value64(ro_node(s), 0); | |
43 | + } | |
44 | ||
45 | } while (flags & INTERNAL_NODE); | |
46 |