All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: Eric Blake <eblake@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 1/6] cutils: extract buffer_is_zero() from qemu-img.c
Date: Thu, 22 Dec 2011 07:47:17 +0000	[thread overview]
Message-ID: <20111222074717.GA8758@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <4EF20CCB.4060306@redhat.com>

On Wed, Dec 21, 2011 at 09:43:55AM -0700, Eric Blake wrote:
> On 12/21/2011 09:00 AM, Stefan Hajnoczi wrote:
> > The qemu-img.c:is_not_zero() function checks if a buffer contains all
> > zeroes.  This function will come in handy for zero-detection in the
> > block layer, so clean it up and move it to cutils.c.
> > 
> > Note that the function now returns true if the buffer is all zeroes.
> > This avoids the double-negatives (i.e. !is_not_zero()) that the old
> > function can cause in callers.
> 
> Are there plans to improve the efficiency of buffer_is_zero to take
> advantage of metadata about sparseness?
> 
> That is, there are cases where we can use metadata to prove a region of
> a file is sparse, without having to read every byte within that region.
>  Now that this series is giving QED special metadata that marks a zero
> cluster, it is faster to query if that metadata exists denoting a zero
> cluster than it is to read the entire cluster and check for non-zero.
> Likewise, with regular files, the kernel provides lseek(SEEK_HOLE) (or
> the older, lower-level, ioctl(FS_IOC_FIEMAP)); which at least GNU
> coreutils is using for efficient sparse detection in source files.

Yes, there are ways to optimize this for specific storage backends.  But
we need a code path that supports all storage systems first.  For
example, raw files over NFS or an image file over HTTP (curl).

In the case of qcow2 or QED backing files we already don't read zeroes
today.  Instead we memset the read buffer to zero and the waste CPU
cycles doing buffer_is_zero() detection.  At least this means that file
I/O (and network I/O, if using NFS) is already optimal if your backing
file is qcow2 or QED - it's just the CPU cycles that we can optimize
away.

Stefan

  reply	other threads:[~2011-12-22  9:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21 16:00 [Qemu-devel] [PATCH v3 0/6] block: zero writes Stefan Hajnoczi
2011-12-21 16:00 ` [Qemu-devel] [PATCH v3 1/6] cutils: extract buffer_is_zero() from qemu-img.c Stefan Hajnoczi
2011-12-21 16:43   ` Eric Blake
2011-12-22  7:47     ` Stefan Hajnoczi [this message]
2011-12-21 16:00 ` [Qemu-devel] [PATCH v3 2/6] block: add .bdrv_co_write_zeroes() interface Stefan Hajnoczi
2011-12-21 16:50   ` Christoph Hellwig
2011-12-22  7:54     ` Stefan Hajnoczi
2011-12-21 16:00 ` [Qemu-devel] [PATCH v3 3/6] block: perform zero-detection during copy-on-read Stefan Hajnoczi
2011-12-21 16:00 ` [Qemu-devel] [PATCH v3 4/6] qed: replace is_write with flags field Stefan Hajnoczi
2011-12-21 16:00 ` [Qemu-devel] [PATCH v3 5/6] qed: add .bdrv_co_write_zeroes() support Stefan Hajnoczi
2011-12-21 16:00 ` [Qemu-devel] [PATCH v3 6/6] qemu-io: add write -z option for bdrv_co_write_zeroes Stefan Hajnoczi
2011-12-21 16:03 ` [Qemu-devel] [PATCH v3 0/6] block: zero writes 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=20111222074717.GA8758@stefanha-thinkpad.localdomain \
    --to=stefanha@linux.vnet.ibm.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mtosatti@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 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.