[RHEL7,COMMIT] ploop: Assign holes_bitmap before merge on merge-no-return point

Submitted by Konstantin Khorenko on Oct. 3, 2019, 3:57 p.m.

Details

Message ID 201910031556.x93Fuw5l011467@finist-ce7.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko Oct. 3, 2019, 3:57 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.27.2.vz7.107.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.27.2.vz7.107.13
------>
commit 3d24669181613fb559758f3c1f9d202dbde89d33
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Thu Oct 3 18:56:58 2019 +0300

    ploop: Assign holes_bitmap before merge on merge-no-return point
    
    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.
    
    https://jira.sw.ru/browse/PSBM-98313
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/fmt_ploop1.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

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