[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 2/9] parallels: Fix data_end field value in parallels_co_check
From: |
Alexander Ivanov |
Subject: |
[PATCH v5 2/9] parallels: Fix data_end field value in parallels_co_check() |
Date: |
Mon, 22 Aug 2022 11:05:10 +0200 |
Make data_end pointing to the end of the last cluster if a leak was fixed.
Otherwise set the file size to data_end.
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
block/parallels.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/block/parallels.c b/block/parallels.c
index c245ca35cd..2be56871bc 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -513,7 +513,15 @@ static int coroutine_fn
parallels_co_check(BlockDriverState *bs,
res->leaks_fixed += count;
}
}
-
+ /*
+ * If res->image_end_offset less than the file size,
+ * a leak was fixed and we should set the new offset to s->data_end.
+ * Otherwise set the file size to s->data_end.
+ */
+ if (res->image_end_offset < size && fix & BDRV_FIX_LEAKS) {
+ size = res->image_end_offset;
+ }
+ s->data_end = size >> BDRV_SECTOR_BITS;
out:
qemu_co_mutex_unlock(&s->lock);
return ret;
--
2.34.1
- Re: [PATCH v5 1/9] parallels: Out of image offset in BAT leads to image inflation, (continued)
- [PATCH v5 4/9] parallels: Use generic infrastructure for BAT writing in parallels_co_check(), Alexander Ivanov, 2022/08/22
- [PATCH v5 3/9] parallels: create parallels_set_bat_entry_helper() to assign BAT value, Alexander Ivanov, 2022/08/22
- [PATCH v5 5/9] parallels: Move check of unclean image to a separate function, Alexander Ivanov, 2022/08/22
- [PATCH v5 9/9] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD, Alexander Ivanov, 2022/08/22
- [PATCH v5 6/9] parallels: Move check of cluster outside image to a separate function, Alexander Ivanov, 2022/08/22
- [PATCH v5 7/9] parallels: Move check of leaks to a separate function, Alexander Ivanov, 2022/08/22
- [PATCH v5 2/9] parallels: Fix data_end field value in parallels_co_check(),
Alexander Ivanov <=
- [PATCH v5 8/9] parallels: Move statistic collection to a separate function, Alexander Ivanov, 2022/08/22