Skip to content

Commit 7d1fedb

Browse files
vinothkumarrajasnitm
authored andcommitted
dm btree: fix for dm_btree_find_lowest_key()
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>
1 parent e36215d commit 7d1fedb

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎drivers/md/persistent-data/dm-btree.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,12 @@ static int find_key(struct ro_spine *s, dm_block_t block, bool find_highest,
902902
else
903903
*result_key = le64_to_cpu(ro_node(s)->keys[0]);
904904

905-
if (next_block || flags & INTERNAL_NODE)
906-
block = value64(ro_node(s), i);
905+
if (next_block || flags & INTERNAL_NODE) {
906+
if (find_highest)
907+
block = value64(ro_node(s), i);
908+
else
909+
block = value64(ro_node(s), 0);
910+
}
907911

908912
} while (flags & INTERNAL_NODE);
909913

0 commit comments

Comments
 (0)