[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/8] parallels: Move BAT entry setting to a separate function
From: |
Alexander Ivanov |
Subject: |
[PATCH v2 2/8] parallels: Move BAT entry setting to a separate function |
Date: |
Thu, 11 Aug 2022 17:00:38 +0200 |
Will need to set BAT entry in multiple places.
Move the code of settings entries and marking relevant blocks dirty
to a separate helper parallels_set_bat_entry.
v2: A new patch - a part of a splitted patch.
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
block/parallels.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/block/parallels.c b/block/parallels.c
index a76cf9d993..7f68f3cbc9 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -165,6 +165,13 @@ static int64_t block_status(BDRVParallelsState *s, int64_t
sector_num,
return start_off;
}
+static void parallels_set_bat_entry(BDRVParallelsState *s,
+ uint32_t index, uint32_t offset)
+{
+ s->bat_bitmap[index] = offset;
+ bitmap_set(s->bat_dirty_bmap, bat_entry_off(index) / s->bat_dirty_block,
1);
+}
+
static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, int *pnum)
{
@@ -250,10 +257,9 @@ static int64_t allocate_clusters(BlockDriverState *bs,
int64_t sector_num,
}
for (i = 0; i < to_allocate; i++) {
- s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier);
+ parallels_set_bat_entry(s, idx + i,
+ cpu_to_le32(s->data_end / s->off_multiplier));
s->data_end += s->tracks;
- bitmap_set(s->bat_dirty_bmap,
- bat_entry_off(idx + i) / s->bat_dirty_block, 1);
}
return bat2sect(s, idx) + sector_num % s->tracks;
--
2.34.1
- [PATCH v2 4/8] parallels: Move check of unclean image to a separate function, (continued)
- [PATCH v2 4/8] parallels: Move check of unclean image to a separate function, Alexander Ivanov, 2022/08/11
- [PATCH v2 8/8] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD, Alexander Ivanov, 2022/08/11
- [PATCH v2 1/8] parallels: Out of image offset in BAT leads to image inflation, Alexander Ivanov, 2022/08/11
- [PATCH v2 5/8] parallels: Move check of cluster outside image to a separate function, Alexander Ivanov, 2022/08/11
- [PATCH v2 6/8] parallels: Move check of leaks to a separate function, Alexander Ivanov, 2022/08/11
- [PATCH v2 2/8] parallels: Move BAT entry setting to a separate function,
Alexander Ivanov <=
- Re: [PATCH v2 0/8] parallels: Refactor the code of images checks and fix a bug, Denis V. Lunev, 2022/08/12