From: Kevin Wolf <kwolf@redhat.com>
To: Zhi Yong Wu <zwu.kernel@gmail.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 2/3] block: Introduce bdrv_co_flush_to_os
Date: Fri, 11 Nov 2011 10:10:52 +0100 [thread overview]
Message-ID: <4EBCE69C.7060804@redhat.com> (raw)
In-Reply-To: <CAEH94LheXN=zbMEzON2tabQkv12KEkxGKKXy9tRfo8ZWBf0FHw@mail.gmail.com>
Am 11.11.2011 05:06, schrieb Zhi Yong Wu:
> On Fri, Nov 11, 2011 at 1:32 AM, Kevin Wolf <kwolf@redhat.com> wrote:
>> qcow2 has a writeback metadata cache, so flushing a qcow2 image actually
>> consists of writing back that cache to the protocol and only then flushes the
>> protocol in order to get everything stable on disk.
>>
>> This introduces a separate bdrv_co_flush_to_os to reflect the split.
>>
>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>> ---
>> block.c | 13 ++++++++++++-
>> block/qcow2.c | 10 ++++++++--
>> block_int.h | 7 +++++++
>> 3 files changed, 27 insertions(+), 3 deletions(-)
>>
>> diff --git a/block.c b/block.c
>> index d3042da..f81dd9f 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -2782,11 +2782,22 @@ static void coroutine_fn bdrv_flush_co_entry(void *opaque)
>>
>> int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
>> {
>> + int ret;
>> +
>> if (bs->open_flags & BDRV_O_NO_FLUSH) {
>> return 0;
>> } else if (!bs->drv) {
>> return 0;
>> - } else if (bs->drv->bdrv_co_flush_to_disk) {
>> + }
>> +
>> + if (bs->drv->bdrv_co_flush_to_os) {
>> + ret = bs->drv->bdrv_co_flush_to_os(bs);
>> + if (ret < 0) {
>> + return ret;
>> + }
>> + }
>> +
>> + if (bs->drv->bdrv_co_flush_to_disk) {
>> return bs->drv->bdrv_co_flush_to_disk(bs);
>> } else if (bs->drv->bdrv_aio_flush) {
>> BlockDriverAIOCB *acb;
>> diff --git a/block/qcow2.c b/block/qcow2.c
>> index f7f73fe..5c784ee 100644
>> --- a/block/qcow2.c
>> +++ b/block/qcow2.c
>> @@ -1105,7 +1105,7 @@ fail:
>> return ret;
>> }
>>
>> -static int qcow2_co_flush(BlockDriverState *bs)
>> +static int qcow2_co_flush_to_os(BlockDriverState *bs)
>> {
>> BDRVQcowState *s = bs->opaque;
>> int ret;
>> @@ -1124,6 +1124,11 @@ static int qcow2_co_flush(BlockDriverState *bs)
>> }
>> qemu_co_mutex_unlock(&s->lock);
>>
>> + return 0;
>> +}
>> +
>> +static int qcow2_co_flush_to_disk(BlockDriverState *bs)
>> +{
>> return bdrv_co_flush(bs->file);
>> }
>>
>> @@ -1245,7 +1250,8 @@ static BlockDriver bdrv_qcow2 = {
>>
>> .bdrv_co_readv = qcow2_co_readv,
>> .bdrv_co_writev = qcow2_co_writev,
>> - .bdrv_co_flush_to_disk = qcow2_co_flush,
>> + .bdrv_co_flush_to_os = qcow2_co_flush_to_os,
>> + .bdrv_co_flush_to_disk = qcow2_co_flush_to_disk,
>>
>> .bdrv_co_discard = qcow2_co_discard,
>> .bdrv_truncate = qcow2_truncate,
>> diff --git a/block_int.h b/block_int.h
>> index 5aadc1f..1ec4921 100644
>> --- a/block_int.h
>> +++ b/block_int.h
>> @@ -93,6 +93,13 @@ struct BlockDriver {
>> */
>> int coroutine_fn (*bdrv_co_flush_to_disk)(BlockDriverState *bs);
>>
>> + /*
>> + * Flushes all internal caches to the OS. The data may still sit in a
>> + * writeback cache of the host OS, but it will survive a crash of the qemu
> Sorry, How to use the data in cache of host OS to survive acrash of the qemu?
Just use the image file. Start a new qemu instance or whatever and
you'll get the right data.
Kevin
next prev parent reply other threads:[~2011-11-11 9:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-10 17:32 [Qemu-devel] [PATCH v2 0/3] block: Write out internal caches even with cache=unsafe Kevin Wolf
2011-11-10 17:32 ` [Qemu-devel] [PATCH v2 1/3] block: Rename bdrv_co_flush to bdrv_co_flush_to_disk Kevin Wolf
2011-11-10 17:32 ` [Qemu-devel] [PATCH v2 2/3] block: Introduce bdrv_co_flush_to_os Kevin Wolf
2011-11-11 4:06 ` Zhi Yong Wu
2011-11-11 9:10 ` Kevin Wolf [this message]
2011-11-13 2:59 ` Zhi Yong Wu
2011-11-10 17:32 ` [Qemu-devel] [PATCH v2 3/3] block: Make cache=unsafe flush to the OS Kevin Wolf
2011-11-10 19:17 ` [Qemu-devel] [PATCH v2 0/3] block: Write out internal caches even with cache=unsafe Paolo Bonzini
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=4EBCE69C.7060804@redhat.com \
--to=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zwu.kernel@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.