qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Alexander Graf <alex@csgraf.de>
Cc: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org, avi@redhat.com
Subject: Re: [Qemu-devel] [PATCH 0/2] block: Write out internal caches even with cache=unsafe
Date: Sun, 23 Oct 2011 16:33:27 +0200	[thread overview]
Message-ID: <4EA425B7.2030708@redhat.com> (raw)
In-Reply-To: <CDC49CE5-315D-4484-BB1F-842FF9EA7D42@csgraf.de>

On 10/22/2011 05:07 PM, Alexander Graf wrote:
>
> On 21.10.2011, at 11:44, Paolo Bonzini wrote:
>
>> On 10/21/2011 07:08 PM, Kevin Wolf wrote:
>>> Avi complained that not even writing out qcow2's cache on
>>> bdrv_flush() made cache=unsafe too unsafe to be useful. He's got
>>> a point.
>>
>> Why? cache=unsafe is explicitly allowing to s/data/manure/ on
>> crash.
>
> Exactly, but not on kill. By not flushing internal caches you're
> almost guaranteed to get an inconsistent qcow2 image.

This should be covered already by termsig_handler.  bdrv_close_all 
closes all block devices, and qcow2_close does flush the caches.

SIGKILL doesn't give any guarantee of course but it does not in general, 
even without cache=unsafe; you might get a SIGKILL "a moment before" a 
bdrv_flush even without cache=unsafe, and get unclean qcow2 metadata.

> By not flushing internal caches you're almost guaranteed to get an
> inconsistent qcow2 image.

Of course the inconsistencies with cache=unsafe will be massive if you 
don't have a clean exit, but that's expected.  If in some cases you want 
a clean exit, but right now you don't, the place to fix those cases 
doesn't seem to be the block layer, but the main loop.

Also,

1) why should cache=unsafe differentiate an OS that sends a flush from 
one that doesn't (e.g. MS-DOS), from the point of view of image metadata?

2) why should the guest actually send a flush if cache=unsafe?  Currently

     if (flags & BDRV_O_CACHE_WB)
         bs->enable_write_cache = 1;

covers cache=unsafe.  However, in the end write cache enable means "do I 
need to flush data", and the answer is "no" when cache=unsafe, because 
the flushes are useless and guests are free to reorder requests.

<shot-in-the-dark>Perhaps what you want is to make qcow2 caches 
writethrough in cache=unsafe mode, so that at least a try is made to 
write the metadata</shot-in-the-dark> (even though the underlying raw 
protocol won't flush it)?  I'm not sure that is particularly useful, but 
maybe it can help me understanding the benefit of this change.

Paolo

  reply	other threads:[~2011-10-23 14:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-21 17:08 [Qemu-devel] [PATCH 0/2] block: Write out internal caches even with cache=unsafe Kevin Wolf
2011-10-21 17:08 ` [Qemu-devel] [PATCH 1/2] raw-posix: Convert to bdrv_co_flush Kevin Wolf
2011-10-21 17:08 ` [Qemu-devel] [PATCH 2/2] block: Handle cache=unsafe only in raw-posix/win32 Kevin Wolf
2011-10-21 18:44 ` [Qemu-devel] [PATCH 0/2] block: Write out internal caches even with cache=unsafe Paolo Bonzini
2011-10-22 15:07   ` Alexander Graf
2011-10-23 14:33     ` Paolo Bonzini [this message]
2011-10-24  8:05       ` Kevin Wolf
2011-10-24  7:37   ` Kevin Wolf
2011-10-24  7:53     ` Paolo Bonzini
2011-10-24  8:17       ` Kevin Wolf
2011-10-24  8:47         ` Paolo Bonzini
2011-10-24  8:54           ` Kevin Wolf
2011-10-24  9:26             ` Paolo Bonzini
2011-10-24  9:36               ` Kevin Wolf
2011-10-24  9:40                 ` Paolo Bonzini
2011-10-24  9:53                   ` Kevin Wolf
2011-10-24 10:08                     ` Paolo Bonzini
2011-10-24  9:09         ` Peter Maydell

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=4EA425B7.2030708@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex@csgraf.de \
    --cc=avi@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).