[RHEL7,COMMIT] ploop: Fix huge grow of empty image

Submitted by Kirill Tkhai on Jan. 30, 2020, 12:31 p.m.


Message ID 202001301231.00UCVrjx238586@localhost.localdomain
State New
Series "ploop: Fix huge grow of empty image"
Headers show

Commit Message

Kirill Tkhai Jan. 30, 2020, 12:31 p.m.
The commit is pushed to "branch-rh7-3.10.0-1062.7.1.vz7.130.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.7.1.vz7.130.12
commit fdc51e97d79761e88a08cc07e8fb66f3292df70e
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Thu Jan 30 12:31:53 2020 +0000

    ploop: Fix huge grow of empty image
    The following scenario leads to problem:
    $ploop init -s 2G root.hds
    $ls -h root.hds
    -rw------- 1 root root  15M янв 30 13:20 root.hds
    Empty image. Grow BAT above current root.hds lenght
    $ploop grow -s 3932257M DiskDescriptor.xml
    (Requires 16M of BAT)
    grow_end is not new actual BAT new size. In case of
    image is empty (total size is less then new BAT size)
    it points to end of current BAT.
    We have to use grow_end + n_alloced, or, the same,
    n_needed - 1
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
 drivers/block/ploop/fmt_ploop1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/fmt_ploop1.c b/drivers/block/ploop/fmt_ploop1.c
index 280767f..6745d29 100644
--- a/drivers/block/ploop/fmt_ploop1.c
+++ b/drivers/block/ploop/fmt_ploop1.c
@@ -763,7 +763,7 @@  ploop1_prepare_grow(struct ploop_delta * delta, u64 *new_size, int *reloc)
 		/* Does not use rellocated data clusters during grow. */
 		if (delta->holes_bitmap) {
 			i = delta->io.plo->grow_start;
-			while (i <= delta->io.plo->grow_end)
+			while (i <= n_needed - 1)
 				ploop_clear_holes_bitmap_bit(i++, delta);