From e88ae2264d93f98e4b656fa76555c745abe57684 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 6 May 2014 15:25:36 +0200 Subject: block: Fix bdrv_is_allocated() for short backing files bdrv_is_allocated() shouldn't return true for sectors that are unallocated, but after the end of a short backing file, even though such sectors are (correctly) marked as containing zeros. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- include/block/block.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/block/block.h b/include/block/block.h index 1b119aac24..59be83f3c2 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -120,6 +120,8 @@ typedef enum { /* BDRV_BLOCK_DATA: data is read from bs->file or another file * BDRV_BLOCK_ZERO: sectors read as zero * BDRV_BLOCK_OFFSET_VALID: sector stored in bs->file as raw data + * BDRV_BLOCK_ALLOCATED: the content of the block is determined by this + * layer (as opposed to the backing file) * BDRV_BLOCK_RAW: used internally to indicate that the request * was answered by the raw driver and that one * should look in bs->file directly. @@ -141,10 +143,11 @@ typedef enum { * f t f not allocated or unknown offset, read as zero * f f f not allocated or unknown offset, read from backing_hd */ -#define BDRV_BLOCK_DATA 1 -#define BDRV_BLOCK_ZERO 2 -#define BDRV_BLOCK_OFFSET_VALID 4 -#define BDRV_BLOCK_RAW 8 +#define BDRV_BLOCK_DATA 0x01 +#define BDRV_BLOCK_ZERO 0x02 +#define BDRV_BLOCK_OFFSET_VALID 0x04 +#define BDRV_BLOCK_RAW 0x08 +#define BDRV_BLOCK_ALLOCATED 0x10 #define BDRV_BLOCK_OFFSET_MASK BDRV_SECTOR_MASK typedef enum { -- cgit v1.2.3 From 9c5268127722087eec88c4c41f3363855bb1234b Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Thu, 8 May 2014 20:12:39 +0200 Subject: qdict: Add qdict_join() This function joins two QDicts by absorbing one into the other. Signed-off-by: Max Reitz Reviewed-by: Benoit Canet Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- include/qapi/qmp/qdict.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 1ddf97b1c3..d68f4eb4d5 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -16,6 +16,7 @@ #include "qapi/qmp/qobject.h" #include "qapi/qmp/qlist.h" #include "qemu/queue.h" +#include #include #define QDICT_BUCKET_MAX 512 @@ -70,4 +71,6 @@ void qdict_flatten(QDict *qdict); void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start); void qdict_array_split(QDict *src, QList **dst); +void qdict_join(QDict *dest, QDict *src, bool overwrite); + #endif /* QDICT_H */ -- cgit v1.2.3 From 43f35cb5e0cff62e1d3fb1c116fbb8e028f2a5c8 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Sun, 18 May 2014 00:58:17 +0200 Subject: util: add qemu_iovec_is_zero Signed-off-by: Peter Lieven Signed-off-by: Kevin Wolf --- include/qemu-common.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/qemu-common.h b/include/qemu-common.h index 3f3fd60f5b..66ceceb2ad 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -318,6 +318,7 @@ void qemu_iovec_concat(QEMUIOVector *dst, void qemu_iovec_concat_iov(QEMUIOVector *dst, struct iovec *src_iov, unsigned int src_cnt, size_t soffset, size_t sbytes); +bool qemu_iovec_is_zero(QEMUIOVector *qiov); void qemu_iovec_destroy(QEMUIOVector *qiov); void qemu_iovec_reset(QEMUIOVector *qiov); size_t qemu_iovec_to_buf(QEMUIOVector *qiov, size_t offset, -- cgit v1.2.3 From 465bee1da82e43f18d10c43cc7566d0284ad13a9 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Sun, 18 May 2014 00:58:19 +0200 Subject: block: optimize zero writes with bdrv_write_zeroes this patch tries to optimize zero write requests by automatically using bdrv_write_zeroes if it is supported by the format. This significantly speeds up file system initialization and should speed zero write test used to test backend storage performance. I ran the following 2 tests on my internal SSD with a 50G QCOW2 container and on an attached iSCSI storage. a) mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/vdX QCOW2 [off] [on] [unmap] ----- runtime: 14secs 1.1secs 1.1secs filesize: 937M 18M 18M iSCSI [off] [on] [unmap] ---- runtime: 9.3s 0.9s 0.9s b) dd if=/dev/zero of=/dev/vdX bs=1M oflag=direct QCOW2 [off] [on] [unmap] ----- runtime: 246secs 18secs 18secs filesize: 51G 192K 192K throughput: 203M/s 2.3G/s 2.3G/s iSCSI* [off] [on] [unmap] ---- runtime: 8mins 45secs 33secs throughput: 106M/s 1.2G/s 1.6G/s allocated: 100% 100% 0% * The storage was connected via an 1Gbit interface. It seems to internally handle writing zeroes via WRITESAME16 very fast. Signed-off-by: Peter Lieven Signed-off-by: Kevin Wolf --- include/block/block_int.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/block/block_int.h b/include/block/block_int.h index 9ffcb698d0..b8cc926bfe 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -364,6 +364,7 @@ struct BlockDriverState { BlockJob *job; QDict *options; + BlockdevDetectZeroesOptions detect_zeroes; }; int get_tmp_filename(char *filename, int size); -- cgit v1.2.3