]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.30/dm-btree-fix-for-dm_btree_find_lowest_key.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 4.9.30 / dm-btree-fix-for-dm_btree_find_lowest_key.patch
CommitLineData
208fc782
GKH
1From 7d1fedb6e96a960aa91e4ff70714c3fb09195a5a Mon Sep 17 00:00:00 2001
2From: Vinothkumar Raja <vinraja@cs.stonybrook.edu>
3Date: Thu, 6 Apr 2017 22:09:38 -0400
4Subject: dm btree: fix for dm_btree_find_lowest_key()
5
6From: Vinothkumar Raja <vinraja@cs.stonybrook.edu>
7
8commit 7d1fedb6e96a960aa91e4ff70714c3fb09195a5a upstream.
9
10dm_btree_find_lowest_key() is giving incorrect results. find_key()
11traverses the btree correctly for finding the highest key, but there is
12an error in the way it traverses the btree for retrieving the lowest
13key. dm_btree_find_lowest_key() fetches the first key of the rightmost
14block of the btree instead of fetching the first key from the leftmost
15block.
16
17Fix this by conditionally passing the correct parameter to value64()
18based on the @find_highest flag.
19
20Signed-off-by: Erez Zadok <ezk@fsl.cs.sunysb.edu>
21Signed-off-by: Vinothkumar Raja <vinraja@cs.stonybrook.edu>
22Signed-off-by: Nidhi Panpalia <npanpalia@cs.stonybrook.edu>
23Signed-off-by: Mike Snitzer <snitzer@redhat.com>
24Signed-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