From 4367c87de14235fbdcd2d21a66508a6d48fdfc74 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Tue, 14 Feb 2023 00:50:31 -0600 Subject: [PATCH] Works? --- lib/cn/kvset_split.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/cn/kvset_split.c b/lib/cn/kvset_split.c index e78567a4b..d2e7a8357 100644 --- a/lib/cn/kvset_split.c +++ b/lib/cn/kvset_split.c @@ -409,7 +409,7 @@ struct vgroup_split_metadata { * * Return values: * v >= start and overlap = false: left: [start, v - 1], right [v, end] - * v >= start and overlap = true : left: [start, punched(v)], right [clone(v), end] + * v >= start and overlap = true : left: [start, punch(v)], right [clone(v), end] * * NOTES: * v = start and overlap = false: All vblocks go to the right @@ -653,7 +653,9 @@ vblocks_split( if (!move_left) { /* Add the vblocks in [boundary, end] to the right kvset */ - boundary = (overlapping_access || move_right) ? split : split + 1; + boundary = (overlapping_access || move_right || (split == start && !metadata->overlaps)) + ? split + : split + 1; for (uint16_t j = boundary; j <= end; j++) { uint32_t alen; uint64_t mbid; @@ -722,10 +724,13 @@ vblocks_split( } if (!move_right) { - /* Add vblocks in [start, boundary] to the left kvset */ + /* Add vblocks in [start, boundary) to the left kvset */ vbcnt = 0; /* reset vbcnt for the left kvset */ - boundary = min(split, end); - for (uint16_t j = start; j <= boundary; j++) { + boundary = + (overlapping_access || move_left || (metadata->overlaps && metadata->offset == -1)) + ? split + 1 + : split; + for (uint16_t j = start; j < boundary; j++) { uint32_t alen; uint64_t mbid; @@ -774,7 +779,8 @@ vblocks_split( if (vbcnt > 0) { vbidx_left += vbcnt; - err = vgmap_vbidx_set(vgmap_src, boundary, vgmap_left, vbidx_left - 1, vgidx_left); + err = vgmap_vbidx_set( + vgmap_src, boundary - 1, vgmap_left, vbidx_left - 1, vgidx_left); if (err) goto out;