Skip to contentSkip to conversation

persistent-data: fix bug about btree of updating internal node's minima key in btree_split_beneath.

PATCH New monty 1 participant 1 message Dec 18, 2017 Device mapper

lore
Share & tools
lore

monty

author
#0 lore raw

PATCH 1/1 persistent-data: fix bug about btree of updating internal node's minima key in btree_split_beneath.

---
 drivers/md/persistent-data/dm-btree.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/md/persistent-data/dm-btree.c +2 -0
index f21ce6a..25ce5ec 100644
@@ -694,6 +694,8 @@ static int btree_split_beneath(struct shadow_spine *s, uint64_t key)
 	if (key < le64_to_cpu(rn->keys[0])) {
 		unlock_block(s->info, right);
 		s->nodes[1] = left;
+		if (key < le64_to_cpu(ln->keys[0]))
+			ln->keys[0] = cpu_to_le64(key);
 	} else {
 		unlock_block(s->info, left);
 		s->nodes[1] = right;
Signature · 1 line
1.7.1

From 5c926190bdeb71a9b1918cca1ccb5e62251f533c Mon Sep 17 00:00:00 2001
From: monty <[email protected]>
Date: Mon, 18 Dec 2017 15:52:31 -0500
Subject: [PATCH] persistent-data: fix bug about btree of updating internal node's minima
key in btree_split_beneath.

fix bug about btree_split_beneath func, this bug may cause a key had been inserted to btree, but dm_btree_lookup can not find the key in btree later.

---
 drivers/md/persistent-data/dm-btree.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/md/persistent-data/dm-btree.c +2 -0
index f21ce6a..25ce5ec 100644
@@ -694,6 +694,8 @@ static int btree_split_beneath(struct shadow_spine *s, uint64_t key)
 	if (key < le64_to_cpu(rn->keys[0])) {
 		unlock_block(s->info, right);
 		s->nodes[1] = left;
+		if (key < le64_to_cpu(ln->keys[0]))
+			ln->keys[0] = cpu_to_le64(key);
 	} else {
 		unlock_block(s->info, left);
 		s->nodes[1] = right;
Signature · 1 line
1.7.1