From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlUz2-0007MI-0z for qemu-devel@nongnu.org; Tue, 26 Nov 2013 21:36:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlUyw-0000oX-Oo for qemu-devel@nongnu.org; Tue, 26 Nov 2013 21:36:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlUyw-0000oS-Fl for qemu-devel@nongnu.org; Tue, 26 Nov 2013 21:36:02 -0500 Message-ID: <52955A84.9020909@redhat.com> Date: Wed, 27 Nov 2013 10:35:48 +0800 From: Fam Zheng MIME-Version: 1.0 References: <20cb22a124616b01eb6d8e901fbe8f2bc37b6e08.1385518315.git.hutao@cn.fujitsu.com> In-Reply-To: <20cb22a124616b01eb6d8e901fbe8f2bc37b6e08.1385518315.git.hutao@cn.fujitsu.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH v2 2/6] block: add BlockDriver.bdrv_preallocate. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao , Kevin Wolf , "Daniel P. Berrange" , Peter Lieven Cc: qemu-devel@nongnu.org On 2013=E5=B9=B411=E6=9C=8827=E6=97=A5 10:15, Hu Tao wrote: > This field is used to preallocate disk space for block > device. > > Signed-off-by: Hu Tao > --- > block.c | 13 +++++++++++++ > include/block/block.h | 1 + > include/block/block_int.h | 3 +++ > 3 files changed, 17 insertions(+) > > diff --git a/block.c b/block.c > index 382ea71..3985133 100644 > --- a/block.c > +++ b/block.c > @@ -3102,6 +3102,19 @@ int bdrv_has_zero_init(BlockDriverState *bs) > return 0; > } > > +int bdrv_preallocate(BlockDriverState *bs, int64_t offset, int64_t len= gth) > +{ > + if (bs->backing_hd) { > + return -1; Better to use -ENOTSUP. > + } > + > + if (bs->drv->bdrv_preallocate) { > + return bs->drv->bdrv_preallocate(bs, offset, length); > + } > + > + return -1; -ENOTSUP Fam > +} > + > typedef struct BdrvCoGetBlockStatusData { > BlockDriverState *bs; > BlockDriverState *base; > diff --git a/include/block/block.h b/include/block/block.h > index 461eaa4..8d48c8a 100644 > --- a/include/block/block.h > +++ b/include/block/block.h > @@ -315,6 +315,7 @@ void bdrv_drain_all(void); > int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sec= tors); > int bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_= sectors); > int bdrv_has_zero_init_1(BlockDriverState *bs); > +int bdrv_preallocate(BlockDriverState *bs, int64_t offset, int64_t len= gth); > int bdrv_has_zero_init(BlockDriverState *bs); > int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_nu= m, > int nb_sectors, int *pnum); > diff --git a/include/block/block_int.h b/include/block/block_int.h > index 1666066..6ac3735 100644 > --- a/include/block/block_int.h > +++ b/include/block/block_int.h > @@ -227,6 +227,9 @@ struct BlockDriver { > */ > int (*bdrv_has_zero_init)(BlockDriverState *bs); > > + int (*bdrv_preallocate)(BlockDriverState *bs, int64_t offset, > + int64_t length); > + > QLIST_ENTRY(BlockDriver) list; > }; > >