From: Mike Maslenkin <mike.maslenkin@gmail.com>
To: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, den@virtuozzo.com,
stefanha@redhat.com, vsementsov@yandex-team.ru,
kwolf@redhat.com, hreitz@redhat.com
Subject: Re: [PATCH v4 3/5] parallels: Add checking and repairing duplicate offsets in BAT
Date: Sat, 29 Apr 2023 01:15:38 +0300 [thread overview]
Message-ID: <CAL77WPCAWgD=69LdXgMZ+5a2sDHATWbvR53RfwVbWvmmXvA3pQ@mail.gmail.com> (raw)
In-Reply-To: <792ee284-473e-b659-2a33-3c15f8bae2b8@virtuozzo.com>
There is another issue with host_cluster_index() function.
After this patchset applied `qemu-img check -f parallels some_disk`
aborts for empty (just created) disk image.
The problem is that host_cluster_index() returns 0 and then
bitmap_new(0) rises an abort.
For default empty disk s->header->data_off=2048, and
res->image_end_offset = 1048576, so:
static uint32_t host_cluster_index(BDRVParallelsState *s, int64_t 1048576)
{
off = 1048576 - le32_to_cpu(2048) << 9;
return 0 / 1048576;
}
Could you check this case?
Regards,
Mike.
On Thu, Apr 27, 2023 at 3:29 PM Alexander Ivanov
<alexander.ivanov@virtuozzo.com> wrote:
>
> Good point. Thank you.
>
> Best regards,
> Alexander Ivanov
>
> On 4/26/23 23:56, Mike Maslenkin wrote:
> > On Mon, Apr 24, 2023 at 12:44 PM Alexander Ivanov
> > <alexander.ivanov@virtuozzo.com> wrote:
> >> Cluster offsets must be unique among all the BAT entries. Find duplicate
> >> offsets in the BAT and fix it by copying the content of the relevant
> >> cluster to a newly allocated cluster and set the new cluster offset to the
> >> duplicated entry.
> >>
> >> Add host_cluster_index() helper to deduplicate the code.
> >>
> >> Move parallels_fix_leak() call to parallels_co_check() to fix both types
> >> of leak: real corruption and a leak produced by allocate_clusters()
> >> during deduplication.
> >>
> >> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
> >> ---
> >> block/parallels.c | 134 ++++++++++++++++++++++++++++++++++++++++++++--
> >> 1 file changed, 129 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/block/parallels.c b/block/parallels.c
> >> index ec89ed894b..3b992e8173 100644
> >> --- a/block/parallels.c
> >> +++ b/block/parallels.c
> >> @@ -136,6 +136,12 @@ static int cluster_remainder(BDRVParallelsState *s, int64_t sector_num,
> >> return MIN(nb_sectors, ret);
> >> }
> >>
> >> +static uint32_t host_cluster_index(BDRVParallelsState *s, int64_t off)
> >> +{
> >> + off -= s->header->data_off << BDRV_SECTOR_BITS;
> >> + return off / s->cluster_size;
> >> +}
> >> +
> > I guess there should be:
> > off -= le32_to_cpu(s->header->data_off) << BDRV_SECTOR_BITS
> >
> > Regards,
> > Mike.
>
next prev parent reply other threads:[~2023-04-28 22:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 9:43 [PATCH v4 0/5] parallels: Add duplication check, repair at open, fix bugs Alexander Ivanov
2023-04-24 9:43 ` [PATCH v4 1/5] parallels: Incorrect data end calculation in parallels_open() Alexander Ivanov
2023-04-24 9:43 ` [PATCH v4 2/5] parallels: Split image leak handling to separate check and fix helpers Alexander Ivanov
2023-04-24 9:43 ` [PATCH v4 3/5] parallels: Add checking and repairing duplicate offsets in BAT Alexander Ivanov
2023-04-26 21:56 ` Mike Maslenkin
2023-04-27 12:29 ` Alexander Ivanov
2023-04-28 22:15 ` Mike Maslenkin [this message]
2023-05-04 12:47 ` Alexander Ivanov
2023-04-27 13:46 ` Mike Maslenkin
2023-04-28 11:48 ` Alexander Ivanov
2023-04-24 9:43 ` [PATCH v4 4/5] parallels: Replace fprintf by qemu_log in check Alexander Ivanov
2023-04-24 9:43 ` [PATCH v4 5/5] parallels: Image repairing in parallels_open() Alexander Ivanov
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='CAL77WPCAWgD=69LdXgMZ+5a2sDHATWbvR53RfwVbWvmmXvA3pQ@mail.gmail.com' \
--to=mike.maslenkin@gmail.com \
--cc=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 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).