From: Stefan Hajnoczi <stefanha@redhat.com>
To: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@gmail.com>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH V18 5/6] add-cow file format core code.
Date: Thu, 9 May 2013 17:07:56 +0200 [thread overview]
Message-ID: <20130509150756.GA26728@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <CAGrFBsha0kQKTtEEwveOWFgMSs4D3Qhq7ifNNquuiVbDzjSd4Q@mail.gmail.com>
On Thu, May 09, 2013 at 02:24:20PM +0800, Dong Xu Wang wrote:
> On Thu, Apr 18, 2013 at 6:03 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> > On Wed, Apr 10, 2013 at 04:11:52PM +0800, Dong Xu Wang wrote:
> >> +static coroutine_fn int add_cow_co_flush(BlockDriverState *bs)
> >> +{
> >> + BDRVAddCowState *s = bs->opaque;
> >> + int ret;
> >> +
> >> + qemu_co_mutex_lock(&s->lock);
> >> + if (s->bitmap_cache) {
> >> + ret = block_cache_flush(bs, s->bitmap_cache);
> >> + if (ret < 0) {
> >> + return ret;
> >> + }
> >> + }
> >> + ret = bdrv_flush(s->image_hd);
> >
> > This is the wrong way around. We must flush image_hd first so that
> > valid data is on disk. Then we can flush bitmap_cache to mark the
> > clusters allocated.
> >
> > Beyond explicit flushes you also need to make sure that image_hd is
> > flushed *before* bitmap_cache tables are written out (e.g. cache
> > eviction when the cache becomes full). It seems this code is missing.
> >
> Hi Stefan, how can I make sure image_hd "flush" operation completed before
> I write bitmap_cache tables? Is there any functions I can use?
You could extend the block cache like this:
block_cache_add_dependency_func(BlockCache *c,
int (*dependency_fn)(BlockCache *c, void *opaque),
void *opaque);
Then add-cow would register a custom dependency function that flushes
image_hd.
A hackier way of achieving the same thing is to instantiate an
image_hd_cache and set a dependency from the bitmap_cache on the
image_hd_cache. The image_hd_cache actually has no cache entries, but
it uses image_hd and will flush it.
Stefan
next prev parent reply other threads:[~2013-05-09 15:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 8:11 [Qemu-devel] [PATCH V18 0/6] add-cow file format Dong Xu Wang
2013-04-10 8:11 ` [Qemu-devel] [PATCH V18 1/6] docs: document for " Dong Xu Wang
2013-04-18 8:30 ` Stefan Hajnoczi
2013-04-23 1:45 ` Dong Xu Wang
2013-04-26 22:45 ` Eric Blake
2013-05-02 5:44 ` Dong Xu Wang
2013-04-10 8:11 ` [Qemu-devel] [PATCH V18 2/6] make path_has_protocol non static Dong Xu Wang
2013-04-10 8:11 ` [Qemu-devel] [PATCH V18 3/6] qed_read_string to bdrv_read_string Dong Xu Wang
2013-04-10 8:11 ` [Qemu-devel] [PATCH V18 4/6] rename qcow2-cache.c to block-cache.c Dong Xu Wang
2013-04-18 8:54 ` Stefan Hajnoczi
2013-04-23 1:47 ` Dong Xu Wang
2013-04-10 8:11 ` [Qemu-devel] [PATCH V18 5/6] add-cow file format core code Dong Xu Wang
2013-04-18 10:03 ` Stefan Hajnoczi
2013-04-23 1:54 ` Dong Xu Wang
2013-05-09 6:24 ` Dong Xu Wang
2013-05-09 15:07 ` Stefan Hajnoczi [this message]
2013-05-13 15:07 ` Jeff Cody
2013-05-14 2:15 ` Dong Xu Wang
2013-04-10 8:11 ` [Qemu-devel] [PATCH V18 6/6] qemu-iotests: add add-cow iotests support Dong Xu Wang
2013-04-18 10:06 ` [Qemu-devel] [PATCH V18 0/6] add-cow file format 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=20130509150756.GA26728@stefanha-thinkpad.redhat.com \
--to=stefanha@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=wdongxu@linux.vnet.ibm.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).