[Devel] [PATCH rh7 1/2] ploop: Assign holes_bitmap before merge on merge-no-return point

Kirill Tkhai ktkhai at virtuozzo.com
Thu Oct 3 14:21:03 MSK 2019


Since we merge clusters back into base image, we should take into
account holes into base image and reuse them firstly. Otherwise
base image may grow unexpected.

Thus, we move populate_holes_bitmap() into start_merge.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/block/ploop/fmt_ploop1.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/block/ploop/fmt_ploop1.c b/drivers/block/ploop/fmt_ploop1.c
index 232f34f0e45b..4e81416f9cbe 100644
--- a/drivers/block/ploop/fmt_ploop1.c
+++ b/drivers/block/ploop/fmt_ploop1.c
@@ -599,17 +599,26 @@ ploop1_start_merge(struct ploop_delta * delta, struct ploop_snapdata * sd)
 
 	ph->bd_size = get_SizeInSectors_from_le(vh, delta->plo->fmt_version);
 
-	return delta->io.ops->sync(&delta->io);
+	err = delta->io.ops->sync(&delta->io);
+	if (err)
+		return err;
+
+	/*
+	 * Do this as last of operations, which may fail. After this,
+	 * nothing can stop killing current top_delta. Otherwise,
+	 * in case of other operation fail, we will have two deltas
+	 * and holes_bitmap assigned.
+	 */
+	if (delta->level == 0)
+		err = populate_holes_bitmap(delta, ph);
+
+	return err;
 }
 
 static int
 ploop1_complete_merge(struct ploop_delta *delta)
 {
-	struct ploop1_private *ph = delta->priv;
-
-	if (delta->level != 0)
-		return 0;
-	return populate_holes_bitmap(delta, ph);
+	return 0;
 }
 
 static int



More information about the Devel mailing list