qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: famz@redhat.com, qemu-block@nongnu.org, armbru@redhat.com,
	qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com,
	den@openvz.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v15 09/25] qcow2: add .bdrv_load_autoloading_dirty_bitmaps
Date: Fri, 17 Feb 2017 14:04:55 +0100	[thread overview]
Message-ID: <20170217130455.GG5338@noname.redhat.com> (raw)
In-Reply-To: <4109eae4-2871-00c5-4e1e-ffbaeff659c4@virtuozzo.com>

Am 17.02.2017 um 13:55 hat Vladimir Sementsov-Ogievskiy geschrieben:
> 17.02.2017 15:21, Kevin Wolf wrote:
> 
>     Am 17.02.2017 um 13:07 hat Vladimir Sementsov-Ogievskiy geschrieben:
> 
>         16.02.2017 15:47, Kevin Wolf wrote:
> 
>             Sorry, this was sent too early. Next attempt...
> 
>             Am 16.02.2017 um 12:45 hat Kevin Wolf geschrieben:
> 
>                 Am 15.02.2017 um 11:10 hat Vladimir Sementsov-Ogievskiy geschrieben:
> 
>                     Auto loading bitmaps are bitmaps in Qcow2, with the AUTO flag set. They
>                     are loaded when the image is opened and become BdrvDirtyBitmaps for the
>                     corresponding drive.
> 
>                     Extra data in bitmaps is not supported for now.
> 
>         [...]
> 
> 
>                     hdx.o vhdx-endian.o vhdx-log.o
>                     diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
>                     new file mode 100644
>                     index 0000000..e08e46e
>                     --- /dev/null
>                     +++ b/block/qcow2-bitmap.c
> 
>         [...]
> 
> 
>                     +
>                     +static int update_header_sync(BlockDriverState *bs)
>                     +{
>                     +    int ret;
>                     +
>                     +    ret = qcow2_update_header(bs);
>                     +    if (ret < 0) {
>                     +        return ret;
>                     +    }
>                     +
>                     +    /* We don't return bdrv_flush error code. Even if it fails, write was
>                     +     * successful and it is more logical to consider that header is in the new
>                     +     * state than in the old.
>                     +     */
>                     +    ret = bdrv_flush(bs);
>                     +    if (ret < 0) {
>                     +        fprintf(stderr, "Failed to flush qcow2 header");
>                     +    }
> 
>             I don't think I can agree with this one. If you don't care whether the
>             new header is actually on disk, don't call bdrv_flush(). But if you do
>             care, then bdrv_flush() failure means that most likely the new header
>             has not made it to the disk, but is just sitting in some volatile cache.
> 
>         And what should be done on bdrv_flush fail? Current solution was
>         proposed by Max.
> 
>     Pass an error up and let the calling operation fail, because we can't
>     promise that it actually executed correctly.
> 
> 
> It was my first option. The problem is that resulting state is absolutely
> inconsistent - it is not guaranteed  to be the old one or new.. However with
> current approach it may be inconsistent too, but without an error..
> 
> So, error message should contain information that all dirty bitmaps may be
> inconsistent even if in the image all flags says that bitmaps are OK.

After a failing flush, we're always in a state that is hard to predict
and where we can make little guarantees about what the image actually
contains on disk and what not. The only thing we can really do is to
make sure the user sees an error and can respond to it, rather than
being silent about a potential corruption.

>                     +    return 0;
>                     +}
>                     +
> 
>         [...]
> 
> 
>                     +
>                     +/* This function returns the number of disk sectors covered by a single cluster
>                     + * of bitmap data. */
>                     +static uint64_t disk_sectors_in_bitmap_cluster(const BDRVQcow2State *s,
>                     +                                               const BdrvDirtyBitmap *bitmap)
>                     +{
>                     +    uint32_t sector_granularity =
>                     +            bdrv_dirty_bitmap_granularity(bitmap) >> BDRV_SECTOR_BITS;
>                     +
>                     +    return (uint64_t)sector_granularity * (s->cluster_size << 3);
>                     +}
> 
>             This has nothing to do with disk sectors, neither of the guest disk nor
>             of the host disk. It's just using a funny 512 bytes unit. Is there a
>             good reason for introducing this funny unit in new code?
> 
>             I'm also not sure what this function calculates, but it's not what the
>             comment says. The unit of the result is something like sectors * bytes,
>             and even when normalising it to a single base unit, I've never seen a
>             use for square bytes so far.
> 
>         sector granularity is number of disk sectors, corresponding to one
>         bit of the dirty bitmap, (disk-sectors/bitmap-bit)
> 
>     Please don't use the word "disk sectors", it's misleading because it's
>     not a sector size of any specific disk. It's best to say just "sectors",
>     which is a fixed qemu block layer unit of 512 bytes.
> 
> 
>         cluster_size << 3 is a number of bits in one cluster, (bitmap-bit)
> 
>         so, we have
>         sector_granularity (disk-sector/bitmap-bit) * <cluster size in bits>
>         (bitmapbit)  = some disk sectors, corresponding to one cluster of
>         bitmap data.
> 
>     Aha! I completely misunderstood what a bitmap cluster is supposed to
>     be. I expected it to be a chunk of bitmap data whose size corresponds to
>     the bitmap granularity, whereas it's really about qcow2 clusters.
> 
>     I wonder if we can rephrase the comment to make this more obvious. Maybe
>     "...covered by a single qcow2 cluster containing bitmap data"? And the
>     function could be called sectors_covered_by_bitmap_cluster() or
>     something.
> 
> 
> No problem with that, I'm always for better wording)
> 
> s/containing/of/ looks better for me, as it should be covered by bitmap data,
> not by cluster.

That works for me, too.

Kevin

  reply	other threads:[~2017-02-17 13:05 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15 10:10 [Qemu-devel] [PATCH v15 00/25] qcow2: persistent dirty bitmaps Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 01/25] specs/qcow2: fix bitmap granularity qemu-specific note Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 02/25] specs/qcow2: do not use wording 'bitmap header' Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 03/25] hbitmap: improve dirty iter Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 04/25] tests: add hbitmap iter test Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 05/25] block: fix bdrv_dirty_bitmap_granularity signature Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 06/25] block/dirty-bitmap: add deserialize_ones func Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 07/25] qcow2: add bitmaps extension Vladimir Sementsov-Ogievskiy
2017-02-16 11:14   ` Kevin Wolf
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 08/25] block: introduce auto-loading bitmaps Vladimir Sementsov-Ogievskiy
2017-02-16 11:25   ` Kevin Wolf
2017-02-16 11:49     ` Kevin Wolf
2017-02-17 11:46       ` Vladimir Sementsov-Ogievskiy
2017-02-17 12:09         ` Kevin Wolf
2017-02-17 12:40           ` Vladimir Sementsov-Ogievskiy
2017-02-17 12:48             ` Kevin Wolf
2017-02-17 13:22               ` Denis V. Lunev
2017-02-17 13:34                 ` Kevin Wolf
2017-02-17 13:48                   ` Denis V. Lunev
2017-02-17 14:24                     ` Kevin Wolf
2017-02-17 14:54                       ` Vladimir Sementsov-Ogievskiy
2017-02-18 10:54                         ` Denis V. Lunev
2017-02-20 11:15                           ` Kevin Wolf
2017-02-20 11:21                             ` Denis V. Lunev
2017-02-20 12:06                               ` Vladimir Sementsov-Ogievskiy
2017-02-20 12:23                               ` Kevin Wolf
2017-02-20 10:09                       ` Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 09/25] qcow2: add .bdrv_load_autoloading_dirty_bitmaps Vladimir Sementsov-Ogievskiy
2017-02-16 11:45   ` Kevin Wolf
2017-02-16 12:47     ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2017-02-16 20:40       ` John Snow
2017-02-17 12:07       ` Vladimir Sementsov-Ogievskiy
2017-02-17 12:21         ` Kevin Wolf
2017-02-17 12:55           ` Vladimir Sementsov-Ogievskiy
2017-02-17 13:04             ` Kevin Wolf [this message]
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 10/25] block/dirty-bitmap: add autoload field to BdrvDirtyBitmap Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 11/25] block: introduce persistent dirty bitmaps Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 12/25] block/dirty-bitmap: add bdrv_dirty_bitmap_next() Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 13/25] qcow2: add .bdrv_store_persistent_dirty_bitmaps() Vladimir Sementsov-Ogievskiy
2017-02-16 14:08   ` Kevin Wolf
2017-02-17 12:24     ` Vladimir Sementsov-Ogievskiy
2017-02-17 13:00       ` Kevin Wolf
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 14/25] block: add bdrv_can_store_new_dirty_bitmap Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 15/25] qcow2: add .bdrv_can_store_new_dirty_bitmap Vladimir Sementsov-Ogievskiy
2017-02-15 23:19   ` John Snow
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 16/25] qmp: add persistent flag to block-dirty-bitmap-add Vladimir Sementsov-Ogievskiy
2017-02-15 23:20   ` John Snow
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 17/25] qmp: add autoload parameter " Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 18/25] qmp: add x-debug-block-dirty-bitmap-sha256 Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 19/25] iotests: test qcow2 persistent dirty bitmap Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 20/25] qcow2-refcount: rename inc_refcounts() and make it public Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 21/25] qcow2-bitmap: refcounts Vladimir Sementsov-Ogievskiy
2017-02-16 14:27   ` Kevin Wolf
2017-02-25 16:10     ` Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 22/25] block/dirty-bitmap: add bdrv_remove_persistent_dirty_bitmap Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 23/25] qcow2: add .bdrv_remove_persistent_dirty_bitmap Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 24/25] qmp: block-dirty-bitmap-remove: remove persistent Vladimir Sementsov-Ogievskiy
2017-02-15 10:10 ` [Qemu-devel] [PATCH v15 25/25] qcow2-bitmap: improve check_constraints_on_bitmap Vladimir Sementsov-Ogievskiy
2017-02-15 23:40   ` John Snow
2017-02-16 14:21   ` Kevin Wolf
2017-02-17 10:18     ` Vladimir Sementsov-Ogievskiy
2017-02-17 15:48       ` Eric Blake
2017-02-20 10:20         ` Vladimir Sementsov-Ogievskiy

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=20170217130455.GG5338@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=famz@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@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).