[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 3/6] block/parallels: BDRVParallelsState: add cluster_size
From: |
Denis V. Lunev |
Subject: |
Re: [PATCH v2 3/6] block/parallels: BDRVParallelsState: add cluster_size field |
Date: |
Wed, 24 Feb 2021 13:51:53 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 |
On 2/24/21 1:47 PM, Vladimir Sementsov-Ogievskiy wrote:
> We are going to use it in more places, calculating
> "s->tracks << BDRV_SECTOR_BITS" doesn't look good.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> block/parallels.h | 1 +
> block/parallels.c | 8 ++++----
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/block/parallels.h b/block/parallels.h
> index 5aa101cfc8..9a9209e320 100644
> --- a/block/parallels.h
> +++ b/block/parallels.h
> @@ -79,6 +79,7 @@ typedef struct BDRVParallelsState {
> ParallelsPreallocMode prealloc_mode;
>
> unsigned int tracks;
> + unsigned int cluster_size;
>
> unsigned int off_multiplier;
> Error *migration_blocker;
> diff --git a/block/parallels.c b/block/parallels.c
> index 3c22dfdc9d..9594d84978 100644
> --- a/block/parallels.c
> +++ b/block/parallels.c
> @@ -421,7 +421,6 @@ static int coroutine_fn
> parallels_co_check(BlockDriverState *bs,
> int ret;
> uint32_t i;
> bool flush_bat = false;
> - int cluster_size = s->tracks << BDRV_SECTOR_BITS;
>
> size = bdrv_getlength(bs->file->bs);
> if (size < 0) {
> @@ -472,7 +471,7 @@ static int coroutine_fn
> parallels_co_check(BlockDriverState *bs,
> high_off = off;
> }
>
> - if (prev_off != 0 && (prev_off + cluster_size) != off) {
> + if (prev_off != 0 && (prev_off + s->cluster_size) != off) {
> res->bfi.fragmented_clusters++;
> }
> prev_off = off;
> @@ -487,10 +486,10 @@ static int coroutine_fn
> parallels_co_check(BlockDriverState *bs,
> }
> }
>
> - res->image_end_offset = high_off + cluster_size;
> + res->image_end_offset = high_off + s->cluster_size;
> if (size > res->image_end_offset) {
> int64_t count;
> - count = DIV_ROUND_UP(size - res->image_end_offset, cluster_size);
> + count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size);
> fprintf(stderr, "%s space leaked at the end of the image %" PRId64
> "\n",
> fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR",
> size - res->image_end_offset);
> @@ -771,6 +770,7 @@ static int parallels_open(BlockDriverState *bs, QDict
> *options, int flags,
> ret = -EFBIG;
> goto fail;
> }
> + s->cluster_size = s->tracks << BDRV_SECTOR_BITS;
>
> s->bat_size = le32_to_cpu(ph.bat_entries);
> if (s->bat_size > INT_MAX / sizeof(uint32_t)) {
Reviewed-by: Denis V. Lunev <den@openvz.org>
- [PATCH v2 0/6] parallels: load bitmap extension, Vladimir Sementsov-Ogievskiy, 2021/02/24
- [PATCH v2 1/6] qcow2-bitmap: make bytes_covered_by_bitmap_cluster() public, Vladimir Sementsov-Ogievskiy, 2021/02/24
- [PATCH v2 2/6] parallels.txt: fix bitmap L1 table description, Vladimir Sementsov-Ogievskiy, 2021/02/24
- [PATCH v2 3/6] block/parallels: BDRVParallelsState: add cluster_size field, Vladimir Sementsov-Ogievskiy, 2021/02/24
- Re: [PATCH v2 3/6] block/parallels: BDRVParallelsState: add cluster_size field,
Denis V. Lunev <=
- [PATCH v2 4/6] parallels: support bitmap extension for read-only mode, Vladimir Sementsov-Ogievskiy, 2021/02/24
- [PATCH v2 5/6] iotests.py: add unarchive_sample_image() helper, Vladimir Sementsov-Ogievskiy, 2021/02/24
- [PATCH v2 6/6] iotests: add parallels-read-bitmap test, Vladimir Sementsov-Ogievskiy, 2021/02/24