qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-block@nongnu.org
Cc: kwolf@redhat.com, jsnow@redhat.com, qemu-devel@nongnu.org,
	mreitz@redhat.com, stefanha@redhat.com
Subject: Re: [PATCH v2 3/6] block/parallels: BDRVParallelsState: add cluster_size field
Date: Wed, 24 Feb 2021 13:51:53 +0300	[thread overview]
Message-ID: <0f316f09-558e-db97-7bbb-9d9db33eb300@openvz.org> (raw)
In-Reply-To: <20210224104707.88430-4-vsementsov@virtuozzo.com>

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>


  reply	other threads:[~2021-02-24 10:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24 10:47 [PATCH v2 0/6] parallels: load bitmap extension Vladimir Sementsov-Ogievskiy
2021-02-24 10:47 ` [PATCH v2 1/6] qcow2-bitmap: make bytes_covered_by_bitmap_cluster() public Vladimir Sementsov-Ogievskiy
2021-02-24 10:47 ` [PATCH v2 2/6] parallels.txt: fix bitmap L1 table description Vladimir Sementsov-Ogievskiy
2021-02-24 10:50   ` Denis V. Lunev
2021-03-04 14:21   ` Kevin Wolf
2021-02-24 10:47 ` [PATCH v2 3/6] block/parallels: BDRVParallelsState: add cluster_size field Vladimir Sementsov-Ogievskiy
2021-02-24 10:51   ` Denis V. Lunev [this message]
2021-03-04 14:24   ` Kevin Wolf
2021-03-04 14:57     ` Denis V. Lunev
2021-03-04 15:11       ` Kevin Wolf
2021-02-24 10:47 ` [PATCH v2 4/6] parallels: support bitmap extension for read-only mode Vladimir Sementsov-Ogievskiy
2021-02-26  8:42   ` Denis V. Lunev
2021-02-24 10:47 ` [PATCH v2 5/6] iotests.py: add unarchive_sample_image() helper Vladimir Sementsov-Ogievskiy
2021-02-24 10:49   ` Denis V. Lunev
2021-02-24 10:47 ` [PATCH v2 6/6] iotests: add parallels-read-bitmap test Vladimir Sementsov-Ogievskiy
2021-02-26  8:39   ` Denis V. Lunev
2021-03-04  9:51 ` [PATCH v2 7/6] MAINTAINERS: update parallels block driver Vladimir Sementsov-Ogievskiy
2021-03-04  9:56   ` Denis V. Lunev
2021-03-04  9:58   ` Vladimir Sementsov-Ogievskiy
2021-03-04 10:20     ` Denis V. Lunev
2021-03-04 14:40 ` [PATCH v2 0/6] parallels: load bitmap extension Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0f316f09-558e-db97-7bbb-9d9db33eb300@openvz.org \
    --to=den@openvz.org \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).