From: Max Reitz <mreitz@redhat.com>
To: John Snow <jsnow@redhat.com>, qemu-block@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org,
armbru@redhat.com, vsementsov@parallels.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 14/17] block: Resize bitmaps on bdrv_truncate
Date: Tue, 03 Mar 2015 16:27:51 -0500 [thread overview]
Message-ID: <54F62757.6000207@redhat.com> (raw)
In-Reply-To: <54F62690.5010809@redhat.com>
On 2015-03-03 at 16:24, John Snow wrote:
>
>
> On 03/03/2015 11:02 AM, Max Reitz wrote:
>> On 2015-03-02 at 18:20, John Snow wrote:
>>> Signed-off-by: John Snow <jsnow@redhat.com>
>>> ---
>>> block.c | 22 ++++++++++++++++++++
>>> include/block/block.h | 1 +
>>> include/qemu/hbitmap.h | 10 +++++++++
>>> util/hbitmap.c | 55
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++
>>> 4 files changed, 88 insertions(+)
>>>
>>> diff --git a/block.c b/block.c
>>> index e6b2696..5eaa874 100644
>>> --- a/block.c
>>> +++ b/block.c
>>> @@ -3543,6 +3543,7 @@ int bdrv_truncate(BlockDriverState *bs, int64_t
>>> offset)
>>> ret = drv->bdrv_truncate(bs, offset);
>>> if (ret == 0) {
>>> ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);
>>> + bdrv_dirty_bitmap_truncate(bs);
>>> if (bs->blk) {
>>> blk_dev_resize_cb(bs->blk);
>>> }
>>> @@ -5562,6 +5563,27 @@ BdrvDirtyBitmap
>>> *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs,
>>> return parent;
>>> }
>>> +static void dirty_bitmap_truncate(BdrvDirtyBitmap *bitmap, uint64_t
>>> size)
>>> +{
>>> + /* Should only be frozen during a block backup job, which should
>>> have
>>> + * blocked any resize actions. */
>>> + assert(!bdrv_dirty_bitmap_frozen(bitmap));
>>> + hbitmap_truncate(bitmap->bitmap, size);
>>> +}
>>> +
>>> +void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)
>>> +{
>>> + BdrvDirtyBitmap *bitmap;
>>> + uint64_t size = bdrv_nb_sectors(bs);
>>> +
>>> + QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {
>>> + if (bdrv_dirty_bitmap_frozen(bitmap)) {
>>> + continue;
>>> + }
>>
>> Hm!
>>
>> The assert() above doesn't do anything because this condition will just
>> skip over frozen bitmaps. Maybe we should drop it?
>>
>> I guess my R-b stands since bdrv_dirty_bitmap_frozen(bitmap) will always
>> be false anyway (hence the assertion), but it would stand with this
>> block dropped, too.
>>
>> Max
>>
>
> It's there for parity with the other bdrv helpers that perform a
> similar check. I am guarding against, in the future, any potential
> users from deciding to call this function directly for whichever reason.
>
> Requesting an action on a drive that contains bitmaps that are not
> ready for the action is OK. Requesting an action on a bitmap that is
> not ready for the action should never happen, hence the 'documentation
> assert.'
>
> My default action will be to leave it in.
Technically that's fine (which is why I said my R-b stands), my only
problem with that is that if something really strange happens and we
actually end up with a frozen bitmap here, the action we're taking is
wrong. The bitmap will have the wrong size after the BDS was truncated,
and that's not right.
I'd find just calling dirty_bitmap_truncate() regardless of the frozen
state more correct, the idea being "We want to resize all bitmaps,
because all bitmaps attached to this BDS need to be resized", and then,
in dirty_bitmap_truncate(), we notice that we cannot resize a frozen
bitmap. But we need to. So the assertion fails.
Max
> --js
next prev parent reply other threads:[~2015-03-03 21:28 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-02 23:19 [Qemu-devel] [PATCH v2 00/17] block: transactionless incremental backup series John Snow
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 01/17] docs: incremental backup documentation John Snow
2015-03-03 15:28 ` Max Reitz
2015-03-11 13:43 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-03-11 14:19 ` John Snow
2015-03-11 14:43 ` Eric Blake
2015-03-11 14:45 ` John Snow
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 02/17] qapi: Add optional field "name" to block dirty bitmap John Snow
2015-03-11 15:34 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 03/17] qmp: Ensure consistent granularity type John Snow
2015-03-11 15:34 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 04/17] qmp: Add block-dirty-bitmap-add and block-dirty-bitmap-remove John Snow
2015-03-11 13:58 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-03-11 14:23 ` John Snow
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 05/17] block: Introduce bdrv_dirty_bitmap_granularity() John Snow
2015-03-11 15:34 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 06/17] hbitmap: add hbitmap_merge John Snow
2015-03-11 15:43 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 07/17] block: Add bitmap disabled status John Snow
2015-03-11 16:34 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 08/17] block: Add bitmap successors John Snow
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 09/17] qmp: Add support of "dirty-bitmap" sync mode for drive-backup John Snow
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 10/17] qmp: add block-dirty-bitmap-clear John Snow
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 11/17] qmp: Add dirty bitmap status fields in query-block John Snow
2015-03-11 16:54 ` Stefan Hajnoczi
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 12/17] block: add BdrvDirtyBitmap documentation John Snow
2015-03-02 23:19 ` [Qemu-devel] [PATCH v2 13/17] block: Ensure consistent bitmap function prototypes John Snow
2015-03-02 23:20 ` [Qemu-devel] [PATCH v2 14/17] block: Resize bitmaps on bdrv_truncate John Snow
2015-03-03 15:29 ` Max Reitz
2015-03-03 16:02 ` Max Reitz
2015-03-03 21:24 ` John Snow
2015-03-03 21:27 ` Max Reitz [this message]
2015-03-03 22:48 ` John Snow
2015-03-04 13:54 ` Max Reitz
2015-03-11 16:18 ` Stefan Hajnoczi
2015-03-11 17:04 ` John Snow
2015-03-02 23:20 ` [Qemu-devel] [PATCH v2 15/17] iotests: add invalid input incremental backup tests John Snow
2015-03-02 23:20 ` [Qemu-devel] [PATCH v2 16/17] iotests: add simple incremental backup case John Snow
2015-03-02 23:20 ` [Qemu-devel] [PATCH v2 17/17] iotests: add incremental backup failure recovery test John Snow
2015-03-03 15:26 ` [Qemu-devel] [PATCH v2 00/17] block: transactionless incremental backup series Max Reitz
2015-03-11 16:57 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
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=54F62757.6000207@redhat.com \
--to=mreitz@redhat.com \
--cc=armbru@redhat.com \
--cc=famz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@parallels.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).