From: Andrew Martin <amartin@xes-inc.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Using cache=writeback safely on qemu 1.4.0 and later
Date: Tue, 19 Aug 2014 18:20:38 -0500 (CDT) [thread overview]
Message-ID: <838926932.102908.1408490438455.JavaMail.zimbra@xes-inc.com> (raw)
In-Reply-To: <20140819145925.GB13680@stefanha-thinkpad.redhat.com>
----- Original Message -----
> From: "Stefan Hajnoczi" <stefanha@gmail.com>
> To: "Andrew Martin" <amartin@xes-inc.com>
> Cc: qemu-devel@nongnu.org
> Sent: Tuesday, August 19, 2014 9:59:25 AM
> Subject: Re: [Qemu-devel] Using cache=writeback safely on qemu 1.4.0 and later
>
> If you strace -f the QEMU process on the host, you will see fdatasync(2)
> system calls when the guest flushes the disk.
>
> You can find the file descriptor number by checking ls -l
> /proc/$PID_OF_QEMU/fd and looking for the disk image file.
When the disk is set to cache=writethrough on one of the same VMs, I see frequent
fdatasync(2) calls (every few seconds). However, when I change the disk over to
cache=writeback, since boot I have not yet seen a single fdatasync(2) call, even
after writing data 2x the amount of RAM:
# time strace -ft -p4113 2>&1 | grep fdatasync
^C
real 15m39.245s
user 0m7.940s
sys 0m18.280s
Note that the disk is defined as follows:
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='writeback'/>
<source file='/var/lib/libvirt/images/vm.img'/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
> > I recently experienced UPS failure on several hosts which caused a hard
> > shutdown. After restarting, 3 of the guests had corruption on their disks
> > and
> > required a fairly long fsck to fix. Afterwards, data that had been written
> > to
> > the disks several hours before the crash was corrupted, which makes me
> > think
> > that it was never fsync()-ed to the non-volatile storage.
>
> What exactly was the "corruption" you encountered? Which application,
> error message, etc.
Two of the servers are web servers with apache2. In one case, a python daemon
copies JPGs onto the server - the last 100 copied onto the server were corrupted.
In another case, some files had been uploaded several days prior to the www-root,
but after the hard reset said files were no longer present in the filesystem.
> > Is it safe in this setup to use cache=writeback? Or, should I use
> > cache=writethrough instead?
>
> Ubuntu 12.04 is recent and sends write cache flushes.
>
> Are you sure the file system and/or application workload are flushing
> the disk cache? Please check the mount options and application-specific
> configuration.
The mount options for the ext4 filesystem in the VM in both cases are:
rw,relatime,errors=remount-ro,data=ordered
Similarly, the host's ext4 filesystem holding the images is mounted with:
rw,relatime,data=ordered
I did not see any errors in the kernel log in the guest, probably because the
root filesystem was read-only until the fsck had completed.
Thanks,
Andrew
next prev parent reply other threads:[~2014-08-19 23:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1009168463.49610.1408133034828.JavaMail.zimbra@xes-inc.com>
2014-08-15 20:18 ` [Qemu-devel] Using cache=writeback safely on qemu 1.4.0 and later Andrew Martin
2014-08-19 14:59 ` Stefan Hajnoczi
2014-08-19 23:20 ` Andrew Martin [this message]
2014-08-21 12:59 ` Stefan Hajnoczi
2014-08-25 18:13 ` Andrew Martin
2014-08-26 7:03 ` Paolo Bonzini
2014-08-27 14:23 ` Andrew Martin
2014-08-27 14:34 ` Paolo Bonzini
2014-08-27 18:46 ` Andrew Martin
2014-08-27 20:47 ` Paolo Bonzini
2014-08-28 10:22 ` 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=838926932.102908.1408490438455.JavaMail.zimbra@xes-inc.com \
--to=amartin@xes-inc.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@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 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).