[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH v4 3/4] raw-posix: Add full image preallocat
From: |
Hu Tao |
Subject: |
Re: [Qemu-devel] [RFC PATCH v4 3/4] raw-posix: Add full image preallocation option |
Date: |
Mon, 20 Jan 2014 10:27:34 +0800 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Fri, Jan 17, 2014 at 04:56:42PM +0800, Stefan Hajnoczi wrote:
> 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.
Fine. I'll drop this.