qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Hu Tao <hutao@cn.fujitsu.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <famz@redhat.com>,
	Peter Lieven <pl@kamp.de>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH v4 3/4] raw-posix: Add full image preallocation option
Date: Fri, 17 Jan 2014 16:56:42 +0800	[thread overview]
Message-ID: <20140117085642.GD31039@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <8ff0f6493e8ad300948cb1e2c8fd45f82e265ac4.1388112645.git.hutao@cn.fujitsu.com>

On Fri, Dec 27, 2013 at 11:05:53AM +0800, Hu Tao wrote:
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index 6f6b8c1..a722d27 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -1160,17 +1160,52 @@ static int64_t raw_get_allocated_file_size(BlockDriverState *bs)
>      return (int64_t)st.st_blocks * 512;
>  }
>  
> +#ifdef __linux__
> +static int raw_preallocate2(int fd, int64_t offset, int64_t length)
> +{
> +    int ret = -1;
> +
> +    ret = fallocate(fd, 0, offset, length);
> +    if (ret < 0) {
> +        ret = -errno;
> +    }
> +
> +    /* fallback to posix_fallocate() if fallocate() is not supported */
> +    if (ret == -ENOSYS || ret == -EOPNOTSUPP) {
> +        ret = posix_fallocate(fd, offset, length);
> +    }
> +
> +    return ret;
> +}

Why is this Linux-specific #ifdef necessary?  glibc will try to use the
fallocate(2) system call, if possible.

Stefan

  parent reply	other threads:[~2014-01-17  8:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-27  3:05 [Qemu-devel] [RFC PATCH v4 0/4] qemu-img: add preallocation=full Hu Tao
2013-12-27  3:05 ` [Qemu-devel] [RFC PATCH v4 1/4] qapi: introduce PreallocMode Hu Tao
2013-12-27  3:05 ` [Qemu-devel] [RFC PATCH v4 2/4] raw, qcow2: don't convert file size to sector size Hu Tao
2013-12-27  3:05 ` [Qemu-devel] [RFC PATCH v4 3/4] raw-posix: Add full image preallocation option Hu Tao
2014-01-17  8:25   ` Stefan Hajnoczi
2014-01-20  2:19     ` Hu Tao
2014-01-17  8:56   ` Stefan Hajnoczi [this message]
2014-01-20  2:27     ` Hu Tao
2013-12-27  3:05 ` [Qemu-devel] [RFC PATCH v4 4/4] qcow2: " Hu Tao
2014-01-17  8:48   ` Stefan Hajnoczi
2014-01-20  2:16     ` Hu Tao
2014-02-07  2:22       ` Hu Tao
2014-01-06  7:27 ` [Qemu-devel] [RFC PATCH v4 0/4] qemu-img: add preallocation=full Hu Tao
2014-01-13 10:26   ` Hu Tao
2014-01-17  9:05 ` 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=20140117085642.GD31039@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=famz@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=kwolf@redhat.com \
    --cc=pl@kamp.de \
    --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).