From: Liam R. Howlett <Liam.Howlett@oracle.com>
Date: Thu, 27 Feb 2025 18:57:47 +0000 (-0500)
Subject: fix rewind for ma_part
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=1e208136ff7dc43f4cb4cfb3fe4c6d1f8ceeba26;p=users%2Fjedix%2Flinux-maple.git

fix rewind for ma_part

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index fe5947a66b26..2b9a3f376fa6 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -3971,7 +3971,8 @@ static int mt_wr_split_data(struct ma_node_info *src,
 
 		if (offset >= insert && offset < insert_end) {
 			copied = min(ma_part->size - part_off, size);
-			printk("B:Insert at %u/%u size %u\n", offset, total_data, copied);
+			printk("B: Insert at %u/%u size %u (out of %u)\n", offset, total_data, copied,
+			       ma_part->size);
 			state[i].part = ma_part;
 			mns_mni_init(&state[i], to, part_off, copied);
 			state[i].use_part = true;
@@ -4006,16 +4007,19 @@ static int mt_wr_split_data(struct ma_node_info *src,
 			if (mns_ends_in_null(&state[i])) {
 				printk("null split, adjust - 1\n");
 				if (!state[i].use_part && offset != insert) {
+					printk("\tuse_part\n");
 					state[i].size++;
 					split++;
 					offset++;
 					size--;
 					node_off++;
 				} else {
+					printk("\tregular\n");
 					state[i].size--;
 					split--;
 					offset--;
 					size++;
+					part_off--;
 					if (!state[i].use_part)
 						node_off--;
 				}
@@ -4112,15 +4116,15 @@ try_right:
 
 	/* The rebalance operation will succeed. */
 	printk("\t\t%s\n", __func__);
-	mt_dump(mas->tree, mt_dump_hex);
+	mt_dump(mas->tree, mt_dump_dec);
 
 	i = 0;
 	offset = 0;
 	total_data = src2.end + new_end + 1;
 	if (left_store)  {
-		printk("left store\n");
 		/* Left pushes data right. */
 		insert = mas->offset;
+		printk("left store at %u\n", insert);
 		size = split;
 	} else {
 		printk("right store\n");
@@ -4523,7 +4527,7 @@ static void mas_wr_split(struct ma_wr_state *wr_mas)
 	trace_ma_op(__func__, mas);
 
 	printk("\t\t%s\n", __func__);
-	mt_dump(mas->tree, mt_dump_hex);
+	mt_dump(mas->tree, mt_dump_dec);
 	printk ("Store %lu - %lu => %p\n", mas->index, mas->last, wr_mas->entry);
 	height = mas_mt_height(mas);
 	mas->depth = height;
@@ -4549,7 +4553,7 @@ static void mas_wr_split(struct ma_wr_state *wr_mas)
 	left.min = mas->min;
 	right.max = mas->max;
 
-	mt_dump(wr_mas->mas->tree, mt_dump_hex);
+	mt_dump(wr_mas->mas->tree, mt_dump_dec);
 	i = mt_wr_split_data(&src_info, &left, &right, &ma_part, split,
 			     mas->offset, split, 0, wr_mas->offset_end,
 			     total, state, 0);
@@ -4774,7 +4778,7 @@ converged:
 rebalanced:
 	mas_wmb_replace(mas, src_info.enode);
 	mtree_range_walk(mas);
-	mt_dump(wr_mas->mas->tree, mt_dump_hex);
+	mt_dump(wr_mas->mas->tree, mt_dump_dec);
 }
 
 /*