[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v10 05/12] parallels: Use generic infrastructure for BAT writing
From: |
Alexander Ivanov |
Subject: |
[PATCH v10 05/12] parallels: Use generic infrastructure for BAT writing in parallels_co_check() |
Date: |
Fri, 3 Feb 2023 10:18:47 +0100 |
BAT is written in the context of conventional operations over the image
inside bdrv_co_flush() when it calls parallels_co_flush_to_os() callback.
Thus we should not modify BAT array directly, but call
parallels_set_bat_entry() helper and bdrv_co_flush() further on. After
that there is no need to manually write BAT and track its modification.
This makes code more generic and allows to split parallels_set_bat_entry()
for independent pieces.
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
---
block/parallels.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/block/parallels.c b/block/parallels.c
index b2e3f5f98f..63bfd7074c 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -425,9 +425,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState
*bs,
{
BDRVParallelsState *s = bs->opaque;
int64_t size, prev_off, high_off;
- int ret;
+ int ret = 0;
uint32_t i;
- bool flush_bat = false;
size = bdrv_getlength(bs->file->bs);
if (size < 0) {
@@ -465,9 +464,8 @@ static int coroutine_fn parallels_co_check(BlockDriverState
*bs,
fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i);
res->corruptions++;
if (fix & BDRV_FIX_ERRORS) {
- s->bat_bitmap[i] = 0;
+ parallels_set_bat_entry(s, i, 0);
res->corruptions_fixed++;
- flush_bat = true;
}
prev_off = 0;
continue;
@@ -484,15 +482,6 @@ static int coroutine_fn
parallels_co_check(BlockDriverState *bs,
prev_off = off;
}
- ret = 0;
- if (flush_bat) {
- ret = bdrv_co_pwrite_sync(bs->file, 0, s->header_size, s->header, 0);
- if (ret < 0) {
- res->check_errors++;
- goto out;
- }
- }
-
if (high_off == 0) {
res->image_end_offset = s->data_end << BDRV_SECTOR_BITS;
} else {
@@ -527,6 +516,14 @@ static int coroutine_fn
parallels_co_check(BlockDriverState *bs,
out:
qemu_co_mutex_unlock(&s->lock);
+
+ if (ret == 0) {
+ ret = bdrv_co_flush(bs);
+ if (ret < 0) {
+ res->check_errors++;
+ }
+ }
+
return ret;
}
--
2.34.1
- [PATCH v10 00/12] parallels: Refactor the code of images checks and fix a bug, Alexander Ivanov, 2023/02/03
- [PATCH v10 02/12] parallels: Fix high_off calculation in parallels_co_check(), Alexander Ivanov, 2023/02/03
- [PATCH v10 03/12] parallels: Fix image_end_offset and data_end after out-of-image check, Alexander Ivanov, 2023/02/03
- [PATCH v10 05/12] parallels: Use generic infrastructure for BAT writing in parallels_co_check(),
Alexander Ivanov <=
- [PATCH v10 04/12] parallels: create parallels_set_bat_entry_helper() to assign BAT value, Alexander Ivanov, 2023/02/03
- [PATCH v10 07/12] parallels: Move check of cluster outside image to a separate function, Alexander Ivanov, 2023/02/03
- [PATCH v10 06/12] parallels: Move check of unclean image to a separate function, Alexander Ivanov, 2023/02/03
- [PATCH v10 12/12] parallels: Incorrect condition in out-of-image check, Alexander Ivanov, 2023/02/03
- [PATCH v10 10/12] parallels: Move statistic collection to a separate function, Alexander Ivanov, 2023/02/03
- [PATCH v10 09/12] parallels: Move check of leaks to a separate function, Alexander Ivanov, 2023/02/03
- [PATCH v10 08/12] parallels: Fix statistics calculation, Alexander Ivanov, 2023/02/03
- [PATCH v10 11/12] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD, Alexander Ivanov, 2023/02/03