qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rjones@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [Qemu-devel] [PATCH] Detect zero writes (for discussion only, not to be applied)
Date: Thu, 26 Jul 2012 16:59:48 +0100	[thread overview]
Message-ID: <1343318389-28877-1-git-send-email-rjones@redhat.com> (raw)

[Applies against qemu 1.1.0, not HEAD, because qemu from git seems to
be broken at the moment.  But the patch is easy to rebase.]

This patch adds a -drive detect_zero=on|off flag (defaults to "off").

Setting this on causes the write path to detect all zero byte writes
and, for block device drivers which support this, turn the request
into the more space-efficient bdrv_co_do_write_zeroes call.

The use case is for virt-sparsify.  We want to create an intermediate
qcow2 overlay file which we know will mostly contain zeroes, and we
want qcow2 to handle this without creating a huge empty file.  In my
testing, the size of the intermediate file is reduced considerably
(down to about 1/4 of the original size), making sparsification of
large mostly-empty guests possible for the first time.

The implementation is very simple-minded.  It tests if the entire
request is all zero bytes or not.  A better implementation would
almost certainly be even more space-efficient, but at the cost of
splitting some write requests (if that's a problem).

Testing: I booted and tested an F16 guest with this patch and the
setting "on", without problems.  I also modified libguestfs to add
this flag, then ran the whole libguestfs test suite with no reported
problems.

Rich.

             reply	other threads:[~2012-07-26 15:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-26 15:59 Richard W.M. Jones [this message]
2012-07-26 15:59 ` [Qemu-devel] [PATCH] block: Add -drive detect_zero=on|off option to detect all zero writes Richard W.M. Jones
2012-07-27 13:58   ` Anthony Liguori
2012-07-27 19:01     ` Paolo Bonzini
2012-07-30 13:51       ` Richard W.M. Jones
2012-07-30 13:57         ` Paolo Bonzini
2012-07-30 14:03           ` Eric Blake
2012-07-30 14:09             ` Paolo Bonzini
2012-07-30 14:38               ` Kevin Wolf
2012-07-30 15:52                 ` Richard W.M. Jones
2012-07-27 13:55 ` [Qemu-devel] [PATCH] Detect zero writes (for discussion only, not to be applied) Anthony Liguori
2012-07-27 15:14   ` Richard W.M. Jones

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=1343318389-28877-1-git-send-email-rjones@redhat.com \
    --to=rjones@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).