[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v3 2/6] block: add BlockDriver.bdrv_preallocate.
From: |
Hu Tao |
Subject: |
[Qemu-devel] [RFC PATCH v3 2/6] block: add BlockDriver.bdrv_preallocate. |
Date: |
Thu, 19 Dec 2013 10:27:37 +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 64e7d22..b901587 100644
--- a/block.c
+++ b/block.c
@@ -3216,6 +3216,19 @@ bool bdrv_can_write_zeroes_with_unmap(BlockDriverState
*bs)
return false;
}
+int bdrv_preallocate(BlockDriverState *bs, int64_t offset, int64_t length)
+{
+ if (bs->backing_hd) {
+ return -ENOTSUP;
+ }
+
+ if (bs->drv->bdrv_preallocate) {
+ return bs->drv->bdrv_preallocate(bs, offset, length);
+ }
+
+ return -ENOTSUP;
+}
+
typedef struct BdrvCoGetBlockStatusData {
BlockDriverState *bs;
BlockDriverState *base;
diff --git a/include/block/block.h b/include/block/block.h
index 3732f25..bc1f277 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -349,6 +349,7 @@ 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_has_zero_init(BlockDriverState *bs);
+int bdrv_preallocate(BlockDriverState *bs, int64_t offset, int64_t length);
bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs);
bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs);
int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num,
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 8b132d7..5bb1005 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -232,6 +232,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.7.11.7
- [Qemu-devel] [RFC PATCH v3 0/6] qemu-img: add preallocation=full, Hu Tao, 2013/12/18
- [Qemu-devel] [RFC PATCH v3 1/6] block: introduce prealloc_mode, Hu Tao, 2013/12/18
- [Qemu-devel] [RFC PATCH v3 4/6] raw-posix: Add full image preallocation option, Hu Tao, 2013/12/18
- [Qemu-devel] [RFC PATCH v3 2/6] block: add BlockDriver.bdrv_preallocate.,
Hu Tao <=
- [Qemu-devel] [RFC PATCH v3 5/6] qcow2: implement bdrv_preallocate, Hu Tao, 2013/12/18
- [Qemu-devel] [RFC PATCH v3 3/6] block/raw-posix: implement bdrv_preallocate, Hu Tao, 2013/12/18
- [Qemu-devel] [RFC PATCH v3 6/6] qcow2: Add full image preallocation option, Hu Tao, 2013/12/18
- Re: [Qemu-devel] [RFC PATCH v3 0/6] qemu-img: add preallocation=full, Stefan Hajnoczi, 2013/12/20