[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v2 2/6] block: add BlockDriver.bdrv_preallocate.
From: |
Hu Tao |
Subject: |
[Qemu-devel] [RFC PATCH v2 2/6] block: add BlockDriver.bdrv_preallocate. |
Date: |
Wed, 27 Nov 2013 10:15:40 +0800 |
This field is used to preallocate disk space for block
device.
Signed-off-by: Hu Tao <address@hidden>
---
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 length)
+{
+ if (bs->backing_hd) {
+ return -1;
+ }
+
+ if (bs->drv->bdrv_preallocate) {
+ return bs->drv->bdrv_preallocate(bs, offset, length);
+ }
+
+ return -1;
+}
+
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_sectors);
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 length);
int bdrv_has_zero_init(BlockDriverState *bs);
int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num,
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;
};
--
1.8.3.1
- [Qemu-devel] [RFC PATCH v2 0/6] qemu-img: add preallocation=full, Hu Tao, 2013/11/26
- [Qemu-devel] [RFC PATCH v2 1/6] block: introduce prealloc_mode, Hu Tao, 2013/11/26
- [Qemu-devel] [RFC PATCH v2 2/6] block: add BlockDriver.bdrv_preallocate.,
Hu Tao <=
- [Qemu-devel] [RFC PATCH v2 3/6] block/raw-posix: implement bdrv_preallocate, Hu Tao, 2013/11/26
- [Qemu-devel] [RFC PATCH v2 5/6] qcow2: implement bdrv_preallocate, Hu Tao, 2013/11/26
- Re: [Qemu-devel] [RFC PATCH v2 5/6] qcow2: implement bdrv_preallocate, Fam Zheng, 2013/11/26
- Re: [Qemu-devel] [RFC PATCH v2 5/6] qcow2: implement bdrv_preallocate, Hu Tao, 2013/11/27
- Re: [Qemu-devel] [RFC PATCH v2 5/6] qcow2: implement bdrv_preallocate, Fam Zheng, 2013/11/27
- Re: [Qemu-devel] [RFC PATCH v2 5/6] qcow2: implement bdrv_preallocate, Peter Lieven, 2013/11/27
- Re: [Qemu-devel] [RFC PATCH v2 5/6] qcow2: implement bdrv_preallocate, Fam Zheng, 2013/11/27
- Re: [Qemu-devel] [RFC PATCH v2 5/6] qcow2: implement bdrv_preallocate, Peter Lieven, 2013/11/27