All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
	qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com,
	kwolf@redhat.com, hreitz@redhat.com
Subject: Re: [PATCH v3 3/8] parallels: Use generic infrastructure for BAT writing in parallels_co_check()
Date: Thu, 18 Aug 2022 11:09:35 +0200	[thread overview]
Message-ID: <1a976701-c283-a590-b49e-4998f349be54@virtuozzo.com> (raw)
In-Reply-To: <d9416fb0-d227-aecd-0dcc-047067360291@yandex-team.ru>

On 17.08.2022 21:48, Vladimir Sementsov-Ogievskiy wrote:
> On 8/15/22 12:02, Alexander Ivanov wrote:
>> 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>
>> ---
>> v2: Patch order was changed so the replacement is done in 
>> parallels_co_check.
>>      Now we use a helper to set BAT entry and mark the block dirty.
>> v3: Fix commit message.
>>
>>   block/parallels.c | 19 +++++++------------
>>   1 file changed, 7 insertions(+), 12 deletions(-)
>>
>> diff --git a/block/parallels.c b/block/parallels.c
>> index 7f68f3cbc9..6879ea4597 100644
>> --- a/block/parallels.c
>> +++ b/block/parallels.c
>> @@ -428,7 +428,6 @@ static int coroutine_fn 
>> parallels_co_check(BlockDriverState *bs,
>>       int64_t size, prev_off, high_off;
>>       int ret;
>>       uint32_t i;
>> -    bool flush_bat = false;
>>         size = bdrv_getlength(bs->file->bs);
>>       if (size < 0) {
>> @@ -467,9 +466,8 @@ static int coroutine_fn 
>> parallels_co_check(BlockDriverState *bs,
>>               res->corruptions++;
>>               if (fix & BDRV_FIX_ERRORS) {
>>                   prev_off = 0;
>> -                s->bat_bitmap[i] = 0;
>> +                parallels_set_bat_entry(s, i, 0);
>>                   res->corruptions_fixed++;
>> -                flush_bat = true;
>>                   continue;
>>               }
>>           }
>> @@ -485,15 +483,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;
>> -        }
>> -    }
>> -
>>       res->image_end_offset = high_off + s->cluster_size;
>>       if (size > res->image_end_offset) {
>>           int64_t count;
>> @@ -522,6 +511,12 @@ static int coroutine_fn 
>> parallels_co_check(BlockDriverState *bs,
>>     out:
>>       qemu_co_mutex_unlock(&s->lock);
>> +
>> +    ret = bdrv_co_flush(bs);
>
> Oops that's wrong. Here we probably rewrite previous error of 
> bdrv_truncate stored in ret variable.

Good point!

As you said in 8/8, now it doesn't matter, but I'll fix it for the patch 
correctness.

>
>> +    if (ret < 0) {
>> +        res->check_errors++;
>> +    }
>> +
>>       return ret;
>>   }
>
>


  parent reply	other threads:[~2022-08-18  9:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15  9:02 [PATCH v3 0/8] parallels: Refactor the code of images checks and fix a bug Alexander Ivanov
2022-08-15  9:02 ` [PATCH v3 1/8] parallels: Out of image offset in BAT leads to image inflation Alexander Ivanov
2022-08-17 19:13   ` Vladimir Sementsov-Ogievskiy
2022-08-17 19:27     ` Denis V. Lunev
2022-08-17 19:43       ` Vladimir Sementsov-Ogievskiy
2022-08-17 19:51         ` Denis V. Lunev
2022-08-18  8:49         ` Alexander Ivanov
2022-08-18  9:32           ` Vladimir Sementsov-Ogievskiy
2022-08-15  9:02 ` [PATCH v3 2/8] parallels: create parallels_set_bat_entry_helper() to assign BAT value Alexander Ivanov
2022-08-17 19:21   ` Vladimir Sementsov-Ogievskiy
2022-08-18  7:31     ` Alexander Ivanov
2022-08-15  9:02 ` [PATCH v3 3/8] parallels: Use generic infrastructure for BAT writing in parallels_co_check() Alexander Ivanov
2022-08-17 19:48   ` Vladimir Sementsov-Ogievskiy
2022-08-17 20:01     ` Denis V. Lunev
2022-08-18  9:09     ` Alexander Ivanov [this message]
2022-08-15  9:02 ` [PATCH v3 4/8] parallels: Move check of unclean image to a separate function Alexander Ivanov
2022-08-17 20:32   ` Vladimir Sementsov-Ogievskiy
2022-08-15  9:02 ` [PATCH v3 5/8] parallels: Move check of cluster outside " Alexander Ivanov
2022-08-17 20:41   ` Vladimir Sementsov-Ogievskiy
2022-08-15  9:02 ` [PATCH v3 6/8] parallels: Move check of leaks " Alexander Ivanov
2022-08-17 21:00   ` Vladimir Sementsov-Ogievskiy
2022-08-18  9:10     ` Alexander Ivanov
2022-08-15  9:02 ` [PATCH v3 7/8] parallels: Move statistic collection " Alexander Ivanov
2022-08-17 21:04   ` Vladimir Sementsov-Ogievskiy
2022-08-15  9:02 ` [PATCH v3 8/8] parallels: Replace qemu_co_mutex_lock by WITH_QEMU_LOCK_GUARD Alexander Ivanov
2022-08-17 21:12   ` Vladimir Sementsov-Ogievskiy
2022-08-16 13:20 ` [PATCH v3 0/8] parallels: Refactor the code of images checks and fix a bug Denis V. Lunev

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=1a976701-c283-a590-b49e-4998f349be54@virtuozzo.com \
    --to=alexander.ivanov@virtuozzo.com \
    --cc=den@virtuozzo.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@yandex-team.ru \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.