summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinothkumar Raja <vinraja@cs.stonybrook.edu>2017-04-06 22:09:38 -0400
committerSasha Levin <alexander.levin@verizon.com>2017-05-17 15:08:23 -0400
commit6a887571cad2bbc08bb6a1a6fcd8d1f0576c6cd2 (patch)
tree030e900f2001e025d5e1f0a751b0bebee0d3d456
parent2ad7696baa06de950c27cc8dc2654001b6e921de (diff)
downloadlinux-stable-6a887571cad2bbc08bb6a1a6fcd8d1f0576c6cd2.tar.gz
linux-stable-6a887571cad2bbc08bb6a1a6fcd8d1f0576c6cd2.tar.bz2
linux-stable-6a887571cad2bbc08bb6a1a6fcd8d1f0576c6cd2.zip
dm btree: fix for dm_btree_find_lowest_key()
[ Upstream commit 7d1fedb6e96a960aa91e4ff70714c3fb09195a5a ] dm_btree_find_lowest_key() is giving incorrect results. find_key() traverses the btree correctly for finding the highest key, but there is an error in the way it traverses the btree for retrieving the lowest key. dm_btree_find_lowest_key() fetches the first key of the rightmost block of the btree instead of fetching the first key from the leftmost block. Fix this by conditionally passing the correct parameter to value64() based on the @find_highest flag. Cc: stable@vger.kernel.org Signed-off-by: Erez Zadok <ezk@fsl.cs.sunysb.edu> Signed-off-by: Vinothkumar Raja <vinraja@cs.stonybrook.edu> Signed-off-by: Nidhi Panpalia <npanpalia@cs.stonybrook.edu> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
-rw-r--r--drivers/md/persistent-data/dm-btree.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/md/persistent-data/dm-btree.c b/drivers/md/persistent-data/dm-btree.c
index d6e47033b5e0..360c22d44647 100644
--- a/drivers/md/persistent-data/dm-btree.c
+++ b/drivers/md/persistent-data/dm-btree.c
@@ -788,8 +788,12 @@ static int find_key(struct ro_spine *s, dm_block_t block, bool find_highest,
else
*result_key = le64_to_cpu(ro_node(s)->keys[0]);
- if (next_block || flags & INTERNAL_NODE)
- block = value64(ro_node(s), i);
+ if (next_block || flags & INTERNAL_NODE) {
+ if (find_highest)
+ block = value64(ro_node(s), i);
+ else
+ block = value64(ro_node(s), 0);
+ }
} while (flags & INTERNAL_NODE);