Commit cc9ea63e authored by Dennis Yang's avatar Dennis Yang Committed by Jiri Slaby

dm btree remove: fix bug in redistribute3

commit 4c7e3093 upstream.

redistribute3() shares entries out across 3 nodes.  Some entries were
being moved the wrong way, breaking the ordering.  This manifested as a
BUG() in dm-btree-remove.c:shift() when entries were removed from the
btree.

For additional context see:
https://www.redhat.com/archives/dm-devel/2015-May/msg00113.htmlSigned-off-by: default avatarDennis Yang <shinrairis@gmail.com>
Signed-off-by: default avatarJoe Thornber <ejt@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent 76a51cc5
...@@ -309,8 +309,8 @@ static void redistribute3(struct dm_btree_info *info, struct btree_node *parent, ...@@ -309,8 +309,8 @@ static void redistribute3(struct dm_btree_info *info, struct btree_node *parent,
if (s < 0 && nr_center < -s) { if (s < 0 && nr_center < -s) {
/* not enough in central node */ /* not enough in central node */
shift(left, center, nr_center); shift(left, center, -nr_center);
s = nr_center - target; s += nr_center;
shift(left, right, s); shift(left, right, s);
nr_right += s; nr_right += s;
} else } else
...@@ -323,7 +323,7 @@ static void redistribute3(struct dm_btree_info *info, struct btree_node *parent, ...@@ -323,7 +323,7 @@ static void redistribute3(struct dm_btree_info *info, struct btree_node *parent,
if (s > 0 && nr_center < s) { if (s > 0 && nr_center < s) {
/* not enough in central node */ /* not enough in central node */
shift(center, right, nr_center); shift(center, right, nr_center);
s = target - nr_center; s -= nr_center;
shift(left, right, s); shift(left, right, s);
nr_left -= s; nr_left -= s;
} else } else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment