From: Kevin Wolf <kwolf@redhat.com>
To: Mike Day <ncmike@ncultra.org>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] qemu-img fails to delete last snapshot
Date: Wed, 14 May 2014 17:15:55 +0200 [thread overview]
Message-ID: <20140514151555.GO3610@noname.redhat.com> (raw)
In-Reply-To: <1399926438-32292-1-git-send-email-ncmike@ncultra.org>
Am 12.05.2014 um 22:27 hat Mike Day geschrieben:
> When deleting the last snapshot, copying the resulting snapshot table
> currently fails, causing the delete operation to also fail. Fix the
> failure by skipping the copy and just writing the snapshot header and
> freeing the extra clusters.
Do you have an easy reproducer? Because I can't see the bug.
> There are two specific problems in the current code. First is a lack of
> parenthesis in the calculation of the memmove size parameter:
>
> s->nb_snapshots - snapshot_index - 1
>
> When s->nb_snapshots is 0, snapshot_index is 1.
>
> 0 - 1 - 1 = 0xfffffffe
>
> it should be:
>
> 0 - (1 - 1) = 0x00
Not really. With s->nb_snapshots == 0, there is no snapshot to delete to
start with. Therefore find_snapshot_by_id_and_name() returns -1 and we
return immediately.
> The second problem is shifting the snapshot table to the left. After
> removing the last snapshot there are no existing snapshots to be
> shifted. All that needs to be done is to write the header and
> unallocate the blocks.
When removing the last snapshot, we have:
nb_snapshots = 1
snapshot_index = 0
memmove(..., (1 - 0 - 1) * sizeof(sn));
So we're not moving anything, which is what you correctly said needs to
happen.
Kevin
next prev parent reply other threads:[~2014-05-14 15:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-12 20:27 [Qemu-devel] [PATCH v2] qemu-img fails to delete last snapshot Mike Day
2014-05-14 15:15 ` Kevin Wolf [this message]
2014-05-15 13:07 ` Mike Day
2014-05-15 13:26 ` Kevin Wolf
2014-05-14 23:54 ` Max Reitz
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=20140514151555.GO3610@noname.redhat.com \
--to=kwolf@redhat.com \
--cc=ncmike@ncultra.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).