Block layer patches
[Qemu-devel] [PULL v2 01/12] qemu-img: allow compressed not-in-order writes
In reply to Kevin WolfFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
No reason to forbid them, and they are needed to improve performance with compress-threads in further patches.
--- qemu-img.c | 5 ----- 1 file changed, 5 deletions(-)
qemu-img.c +0 -5
@@ -2141,11 +2141,6 @@ static int img_convert(int argc, char **argv) goto fail_getopt; } -if (!s.wr_in_order && s.compressed) { -error_report ("Out of order write and compress are mutually exclusive" ); - goto fail_getopt; - } -if (tgt_image_opts && !skip_create) {error_report ("--target-image-opts requires use of -n flag" ); goto fail_getopt;
Signature · 1 line
2.13.6
[Qemu-devel] [PULL v2 02/12] qcow2: refactor data compression
In reply to Kevin WolfFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
Make a separate function for compression to be parallelized later.
- use .avail_out field instead of .next_out to calculate size of compressed data. It looks more natural and it allows to keep dest to be void pointer
- set avail_out to be at least one byte less than input, to be sure avoid inefficient compression earlier
--- block/qcow2.c | 78 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 27 deletions(-)
block/qcow2.c +51 -27
@@ -23,11 +23,14 @@*/ #include "qemu/osdep.h" + +#define ZLIB_CONST +#include <zlib.h> +#include "block/block_int.h" #include "block/qdict.h" #include "sysemu/block-backend.h" #include "qemu/module.h" -#include <zlib.h> #include "qcow2.h" #include "qemu/error-report.h" #include "qapi/error.h"
@@ -3650,6 +3653,48 @@ fail:return ret; } +/* +* qcow2_compress() +* +* @dest - destination buffer, at least of @size-1 bytes +* @src - source buffer, @size bytes +* +* Returns: compressed size on success +* -1 if compression is inefficient +* -2 on any other error +*/ +static ssize_t qcow2_compress (void *dest,const void *src,size_t size) +{ +ssize_t ret; +z_stream strm; + +/* best compression, small window, no zlib header */ +memset (&strm,0 ,sizeof (strm)); + ret =deflateInit2 (&strm,Z_DEFAULT_COMPRESSION ,Z_DEFLATED , +-12 ,9 ,Z_DEFAULT_STRATEGY ); +if (ret !=0 ) { +return -2 ; + } + +/* strm.next_in is not const in old zlib versions, such as those used on +* OpenBSD/NetBSD, so cast the const away */ + strm.avail_in = size; + strm.next_in = (void *) src; + strm.avail_out = size -1 ; + strm.next_out = dest; + + ret =deflate (&strm,Z_FINISH ); +if (ret ==Z_STREAM_END ) { + ret = size -1 - strm.avail_out; + }else { + ret = (ret ==Z_OK ?-1 :-2 ); + } + +deflateEnd (&strm); + +return ret; +} +/* XXX: put compressed sectors first, then all the cluster aligned tables to avoid losing bytes in alignment */ static coroutine_fn int
@@ -3659,8 +3704,8 @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset,BDRVQcow2State *s = bs->opaque;QEMUIOVector hd_qiov;struct iovec iov; -z_stream strm; -int ret, out_len; +int ret; +size_t out_len;uint8_t *buf, *out_buf;int64_t cluster_offset;
@@ -3694,32 +3739,11 @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, out_buf =g_malloc (s->cluster_size); -/* best compression, small window, no zlib header */ -memset (&strm,0 ,sizeof (strm)); - ret =deflateInit2 (&strm,Z_DEFAULT_COMPRESSION , -Z_DEFLATED ,-12 , -9 ,Z_DEFAULT_STRATEGY ); -if (ret !=0 ) { + out_len =qcow2_compress (out_buf, buf, s->cluster_size); +if (out_len ==-2 ) { ret = -EINVAL ; goto fail; - } - - strm.avail_in = s->cluster_size; - strm.next_in = (uint8_t *)buf; - strm.avail_out = s->cluster_size; - strm.next_out = out_buf; - - ret =deflate (&strm,Z_FINISH ); -if (ret !=Z_STREAM_END && ret !=Z_OK ) { -deflateEnd (&strm); - ret = -EINVAL ; - goto fail; - } - out_len = strm.next_out - out_buf; - -deflateEnd (&strm); - -if (ret !=Z_STREAM_END || out_len >= s->cluster_size) { + }else if (out_len ==-1 ) {/* could not compress: write normal cluster */ ret =qcow2_co_pwritev (bs, offset, bytes, qiov,0 );if (ret <0 ) {
Signature · 1 line
2.13.6
The following changes since commit fe8d2d5737ab20ed0118863f5eb888cae37122ab:
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-3.0-pull-request' into staging (2018-07-04 22:38:10 +0100)
are available in the git repository at:
git://repo.or.cz/qemu/kevin.git tags/for-upstream
for you to fetch changes up to 7c20c808a5cbf5d244735bc78fc3138c739c1946:
file-posix: Unlock FD after creation (2018-07-05 11:07:58 +0200)
----------------------------------------------------------------
Block layer patches:
- qcow2: Use worker threads for compression to improve performance of 'qemu-img convert -W' and compressed backup jobs
- blklogwrites: New filter driver to log write requests to an image in the dm-log-writes format
- file-posix: Fix image locking during image creation
- crypto: Fix memory leak in error path
- Error out instead of silently truncating node names
----------------------------------------------------------------
Aapo Vienamo (1):
block: Add blklogwrites
Ari Sundholm (4):
block: Move two block permission constants to the relevant enum block/blklogwrites: Change log_sector_size from int64_t to uint64_t block/blklogwrites: Add an option for appending to an old log block/blklogwrites: Add an option for the update interval of the log superblock
Kevin Wolf (2):
block: Don't silently truncate node names block/crypto: Fix memory leak in create error path
Max Reitz (2):
file-posix: Fix creation locking
file-posix: Unlock FD after creation
Vladimir Sementsov-Ogievskiy (3):
qemu-img: allow compressed not-in-order writes
qcow2: refactor data compression
qcow2: add compress threads
qapi/block-core.json | 38 ++- block/qcow2.h | 3 + include/block/block.h | 7 + block.c | 12 +- block/blklogwrites.c | 547 ++++++++++++++++++++++++++++++++++++++++++ block/crypto.c | 2 +- block/file-posix.c | 21 +- block/qcow2.c | 138 ++++++++--- qemu-img.c | 5 - MAINTAINERS | 6 + block/Makefile.objs | 1 + tests/qemu-iotests/051 | 15 ++ tests/qemu-iotests/051.out | 23 ++ tests/qemu-iotests/051.pc.out | 23 ++ 14 files changed, 791 insertions(+), 50 deletions(-) create mode 100644 block/blklogwrites.c
[Qemu-devel] [PULL v2 03/12] qcow2: add compress threads
From: Vladimir Sementsov-Ogievskiy <[email protected]>
Do data compression in separate threads. This significantly improve performance for qemu-img convert with -W (allow async writes) and -c (compressed) options.
--- block/qcow2.h | 3 +++ block/qcow2.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-)
block/qcow2.h +3 -0
@@ -326,6 +326,9 @@ typedef struct BDRVQcow2State {* override) */ char *image_backing_file;char *image_backing_format; + +CoQueue compress_wait_queue; +int nb_compress_threads; } BDRVQcow2State; typedef struct Qcow2COWRegion {
block/qcow2.c +61 -1
86 lines not on this page · raw message
Signature · 1 line
2.13.6
[Qemu-devel] [PULL v2 04/12] block: Move two block permission constants to the relevant enum
In reply to Kevin WolfFrom: Ari Sundholm <[email protected]>
This allows using the two constants outside of block.c, which will happen in a subsequent patch.
--- include/block/block.h | 7 +++++++ block.c | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-)
include/block/block.h +7 -0
@@ -225,6 +225,13 @@ enum {BLK_PERM_GRAPH_MOD =0x10 ,BLK_PERM_ALL =0x1f , + +DEFAULT_PERM_PASSTHROUGH =BLK_PERM_CONSISTENT_READ + |BLK_PERM_WRITE + |BLK_PERM_WRITE_UNCHANGED + |BLK_PERM_RESIZE , + + DEFAULT_PERM_UNCHANGED = BLK_PERM_ALL & ~DEFAULT_PERM_PASSTHROUGH, };char *bdrv_perm_names (uint64_t perm);
block.c +0 -6
@@ -1948,12 +1948,6 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared,return 0 ; } -#define DEFAULT_PERM_PASSTHROUGH (BLK_PERM_CONSISTENT_READ \ - | BLK_PERM_WRITE \ - | BLK_PERM_WRITE_UNCHANGED \ - | BLK_PERM_RESIZE) -#define DEFAULT_PERM_UNCHANGED (BLK_PERM_ALL & ~DEFAULT_PERM_PASSTHROUGH) - void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildRole *role, BlockReopenQueue *reopen_queue,
Signature · 1 line
2.13.6
[Qemu-devel] [PULL v2 06/12] block: Don't silently truncate node names
In reply to Kevin WolfIf the user passes a too long node name string, we silently truncate it to fit into BlockDriverState.node_name, i.e. to 31 characters. Apart from surprising the user when the node has a different name than requested, this also bypasses the check for duplicate names, so that the same name can be assigned to multiple nodes.
Fix this by just making too long node names an error.
--- block.c | 6 ++++++ tests/qemu-iotests/051 | 15 +++++++++++++++ tests/qemu-iotests/051.out | 23 +++++++++++++++++++++++ tests/qemu-iotests/051.pc.out | 23 +++++++++++++++++++++++ 4 files changed, 67 insertions(+)
block.c +6 -0
@@ -1156,6 +1156,12 @@ static void bdrv_assign_node_name(BlockDriverState *bs, goto out; } +/* Make sure that the node name isn't truncated */ +if (strlen (node_name) >=sizeof (bs->node_name)) { +error_setg (errp,"Node name too long" ); + goto out; + } +/* copy node name into the bs and insert it into the graph list */ pstrcpy (bs->node_name,sizeof (bs->node_name), node_name);QTAILQ_INSERT_TAIL (&graph_bdrv_states, bs, node_list);
tests/qemu-iotests/051 +15 -0
@@ -100,6 +100,21 @@ run_qemu -drive file="$TEST_IMG",driver=raw,format=qcow2 run_qemu -drive file="$TEST_IMG",driver=qcow2,format=qcow2 echo +echo === Node names === +echo + +# Maximum length: 31 characters +run_qemu -drive file="$TEST_IMG",node-name=x123456789012345678901234567890 +run_qemu -drive file="$TEST_IMG",node-name=x1234567890123456789012345678901 + +# First character must be alphabetic +# Following characters alphanumeric or -._ +run_qemu -drive file="$TEST_IMG",node-name=All-Types.of_all0wed_chars +run_qemu -drive file="$TEST_IMG",node-name=123foo +run_qemu -drive file="$TEST_IMG",node-name=_foo +run_qemu -drive file="$TEST_IMG",node-name=foo#12 + +echo echo === Device without drive === echo
tests/qemu-iotests/051.out +23 -0
@@ -47,6 +47,29 @@ Testing: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2 QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2: Cannot specify both 'driver' and 'format' +=== Node names === + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=x123456789012345678901234567890 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) quit + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=x1234567890123456789012345678901 +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=x1234567890123456789012345678901: Node name too long + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=All-Types.of_all0wed_chars +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) quit + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=123foo +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=123foo: Invalid node name + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=_foo +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=_foo: Invalid node name + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=foo#12 +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=foo#12: Invalid node name + + === Device without drive === Testing: -device VIRTIO_SCSI -device scsi-hd
tests/qemu-iotests/051.pc.out +23 -0
@@ -47,6 +47,29 @@ Testing: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2 QEMU_PROG: -drive file=TEST_DIR/t.qcow2,driver=qcow2,format=qcow2: Cannot specify both 'driver' and 'format' +=== Node names === + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=x123456789012345678901234567890 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) quit + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=x1234567890123456789012345678901 +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=x1234567890123456789012345678901: Node name too long + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=All-Types.of_all0wed_chars +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) quit + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=123foo +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=123foo: Invalid node name + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=_foo +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=_foo: Invalid node name + +Testing: -drive file=TEST_DIR/t.qcow2,node-name=foo#12 +QEMU_PROG: -drive file=TEST_DIR/t.qcow2,node-name=foo#12: Invalid node name + + === Device without drive === Testing: -device VIRTIO_SCSI -device scsi-hd
Signature · 1 line
2.13.6
[Qemu-devel] [PULL v2 07/12] block/crypto: Fix memory leak in create error path
In reply to Kevin Wolf--- block/crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/crypto.c +1 -1
@@ -551,7 +551,7 @@ static int coroutine_fn block_crypto_co_create_opts_luks(const char *filename,/* Create protocol layer */ ret =bdrv_create_file (filename, opts, errp);if (ret <0 ) { -return ret; + goto fail; } bs = bdrv_open(filename, NULL, NULL,
Signature · 1 line
2.13.6
[Qemu-devel] [PULL v2 08/12] block/blklogwrites: Change log_sector_size from int64_t to uint64_t
In reply to Kevin WolfFrom: Ari Sundholm <[email protected]>
This was a simple oversight when working on intermediate versions of the original patch which introduced blklogwrites.
--- block/blklogwrites.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
block/blklogwrites.c +3 -5
@@ -79,7 +79,7 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,QemuOpts *opts;Error *local_err =NULL ;int ret; -int64_t log_sector_size; +uint64_t log_sector_size; opts =qemu_opts_create (&runtime_opts,NULL ,0 , &error_abort);qemu_opts_absorb_qdict (opts, options, &local_err);
@@ -101,11 +101,9 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, log_sector_size =qemu_opt_get_size (opts,"log-sector-size" ,BDRV_SECTOR_SIZE ); -if (log_sector_size <0 || log_sector_size > (1ull <<23 ) || - !is_power_of_2 (log_sector_size)) - { +if (log_sector_size > (1ull <<23 ) || !is_power_of_2 (log_sector_size)) { ret = -EINVAL ; -error_setg (errp,"Invalid log sector size %" PRId64, log_sector_size); +error_setg (errp,"Invalid log sector size %" PRIu64, log_sector_size); goto fail; }
Signature · 1 line
2.13.6
[Qemu-devel] [PULL v2 11/12] file-posix: Fix creation locking
In reply to Kevin WolfFrom: Max Reitz <[email protected]>
raw_apply_lock_bytes() takes a bit mask of "permissions that are NOT shared".
Also, make the "perm" and "shared" variables uint64_t, because I do not particularly like using ~ on signed integers (and other permission masks are usually uint64_t, too).
--- block/file-posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/file-posix.c +2 -2
@@ -2112,7 +2112,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp) {BlockdevCreateOptionsFile *file_opts;int fd; -int perm, shared; +uint64_t perm, shared;int result =0 ;/* Validate options and set default values */
@@ -2148,7 +2148,7 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp) shared =BLK_PERM_ALL & ~BLK_PERM_RESIZE ;/* Step one: Take locks */ - result =raw_apply_lock_bytes (fd, perm, shared, false, errp); + result =raw_apply_lock_bytes (fd, perm, ~shared, false, errp);if (result <0 ) { goto out_close; }
Signature · 1 line
2.13.6
[Qemu-devel] [PULL v2 12/12] file-posix: Unlock FD after creation
In reply to Kevin WolfFrom: Max Reitz <[email protected]>
Closing the FD does not necessarily mean that it is unlocked. Fix this by relinquishing all permission locks before qemu_close().
--- block/file-posix.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
block/file-posix.c +14 -3
@@ -2111,6 +2111,7 @@ static int coroutine_fn raw_co_create(BlockdevCreateOptions *options, Error **errp) {BlockdevCreateOptionsFile *file_opts; +Error *local_err =NULL ;int fd;uint64_t perm, shared;int result =0 ;
@@ -2156,13 +2157,13 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)/* Step two: Check that nobody else has taken conflicting locks */ result =raw_check_lock_bytes (fd, perm, shared, errp);if (result <0 ) { - goto out_close; + goto out_unlock; }/* Clear the file by truncating it to 0 */ result =raw_regular_truncate (NULL , fd,0 ,PREALLOC_MODE_OFF , errp);if (result <0 ) { - goto out_close; + goto out_unlock; }if (file_opts->nocow) {
@@ -2185,7 +2186,17 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp) result =raw_regular_truncate (NULL , fd, file_opts->size, file_opts->preallocation, errp);if (result <0 ) { - goto out_close; + goto out_unlock; + } + +out_unlock: +raw_apply_lock_bytes (fd,0 ,0 , true, &local_err); +if (local_err) { +/* The above call should not fail, and if it does, that does +* not mean the whole creation operation has failed. So +* report it the user for their convenience, but do not report +* it to the caller. */ +error_report_err (local_err); } out_close:
Signature · 1 line
2.13.6
[Qemu-devel] [PULL v2 05/12] block: Add blklogwrites
In reply to Kevin WolfFrom: Aapo Vienamo <[email protected]>
Implements a block device write logging system, similar to Linux kernel device mapper dm-log-writes. The write operations that are performed on a block device are logged to a file or another block device. The write log format is identical to the dm-log-writes format. Currently, log markers are not supported.
This functionality can be used for crash consistency and fs consistency testing. By implementing it in qemu, tests utilizing write logs can be be used to test non-Linux drivers and older kernels.
The driver accepts an optional parameter to set the sector size used for logging. This makes the driver require all requests to be aligned to this sector size and also makes offsets and sizes of writes in the log metadata to be expressed in terms of this value (the log format has a granularity of one sector for offsets and sizes). This allows accurate logging of writes to guest block devices that have unusual sector sizes.
The implementation is based on the blkverify and blkdebug block drivers.
--- qapi/block-core.json | 33 +++- block/blklogwrites.c | 414 +++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 6 + block/Makefile.objs | 1 + 4 files changed, 448 insertions(+), 6 deletions(-) create mode 100644 block/blklogwrites.c
qapi/block-core.json +27 -6
@@ -2533,16 +2533,17 @@ # @throttle: Since 2.11 # @nvme: Since 2.12 # @copy-on-read: Since 3.0 +# @blklogwrites: Since 3.0 # # Since: 2.9 ## { 'enum': 'BlockdevDriver', - 'data': [ 'blkdebug', 'blkverify', 'bochs', 'cloop', 'copy-on-read', - 'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom', - 'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', - 'null-aio', 'null-co', 'nvme', 'parallels', 'qcow', 'qcow2', 'qed', - 'quorum', 'raw', 'rbd', 'replication', 'sheepdog', 'ssh', - 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] } + 'data': [ 'blkdebug', 'blklogwrites', 'blkverify', 'bochs', 'cloop', + 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluster', + 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks', + 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', 'qcow', + 'qcow2', 'qed', 'quorum', 'raw', 'rbd', 'replication', 'sheepdog', + 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] } ## # @BlockdevOptionsFile:
@@ -3045,6 +3046,25 @@ '*set-state': ['BlkdebugSetStateOptions'] } } ## +# @BlockdevOptionsBlklogwrites: +# +# Driver specific block device options for blklogwrites. +# +# @file: block device +# +# @log: block device used to log writes to @file +# +# @log-sector-size: sector size used in logging writes to @file, determines +# granularity of offsets and sizes of writes (default: 512) +# +# Since: 3.0 +## +{ 'struct': 'BlockdevOptionsBlklogwrites', + 'data': { 'file': 'BlockdevRef', + 'log': 'BlockdevRef', + '*log-sector-size': 'uint32' } } + +## # @BlockdevOptionsBlkverify: # # Driver specific block device options for blkverify.
@@ -3563,6 +3583,7 @@ 'discriminator': 'driver', 'data': { 'blkdebug': 'BlockdevOptionsBlkdebug', + 'blklogwrites':'BlockdevOptionsBlklogwrites', 'blkverify': 'BlockdevOptionsBlkverify', 'bochs': 'BlockdevOptionsGenericFormat', 'cloop': 'BlockdevOptionsGenericFormat',
block/blklogwrites.c new file +414 -0
414 lines not on this page · raw message
MAINTAINERS +6 -0
@@ -2052,6 +2052,12 @@ S: Supported F: block/quorum.c L: [email protected] +blklogwrites +M: Ari Sundholm <[email protected]> +L: [email protected] +S: Supported +F: block/blklogwrites.c + blkverify M: Stefan Hajnoczi <[email protected]> L: [email protected]
block/Makefile.objs +1 -0
@@ -5,6 +5,7 @@ block-obj-y += qed-check.o block-obj-y += vhdx.o vhdx-endian.o vhdx-log.o block-obj-y += quorum.o block-obj-y += parallels.o blkdebug.o blkverify.o blkreplay.o +block-obj-y += blklogwrites.o block-obj-y += block-backend.o snapshot.o qapi.o block-obj-$(CONFIG_WIN32) += file-win32.o win32-aio.o block-obj-$(CONFIG_POSIX) += file-posix.o
Signature · 1 line
2.13.6
[Qemu-devel] [PULL v2 10/12] block/blklogwrites: Add an option for the update interval of the log superblock
In reply to Kevin WolfFrom: Ari Sundholm <[email protected]>
This is a way to ensure that the log superblock is periodically updated. Before, this was only done on flush requests, which may not be enough if the VM exits abnormally, omitting the final flush.
The default interval is 4096 write requests.
--- qapi/block-core.json | 6 +++++- block/blklogwrites.c | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-)
qapi/block-core.json +5 -1
@@ -3057,13 +3057,17 @@ # @log-sector-size: sector size used in logging writes to @file, determines # granularity of offsets and sizes of writes (default: 512) # +# @log-super-update-interval: interval of write requests after which the log +# super block is updated to disk (default: 4096) +# # Since: 3.0 ## { 'struct': 'BlockdevOptionsBlklogwrites', 'data': { 'file': 'BlockdevRef', 'log': 'BlockdevRef', '*log-sector-size': 'uint32', - '*log-append': 'bool' } } + '*log-append': 'bool', + '*log-super-update-interval': 'uint64' } } ## # @BlockdevOptionsBlkverify:
block/blklogwrites.c +18 -2
@@ -55,6 +55,7 @@ typedef struct {uint32_t sectorbits;uint64_t cur_log_sector;uint64_t nr_entries; +uint64_t update_interval; } BDRVBlkLogWritesState;static QemuOptsList runtime_opts = {
@@ -71,6 +72,11 @@ static QemuOptsList runtime_opts = { .type = QEMU_OPT_SIZE, .help = "Log sector size", }, + { + .name = "log-super-update-interval", + .type = QEMU_OPT_NUMBER, + .help = "Log superblock update interval (# of write requests)", + }, {/* end of list */ } }, };
@@ -234,6 +240,14 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags, s->sectorsize = log_sector_size; s->sectorbits =blk_log_writes_log2 (log_sector_size); + s->update_interval =qemu_opt_get_number (opts,"log-super-update-interval" , +4096 ); +if (!s->update_interval) { + ret = -EINVAL ; +error_setg (errp,"Invalid log superblock update interval %" PRIu64, + s->update_interval); + goto fail_log; + } ret =0 ; fail_log:
@@ -360,8 +374,10 @@ static void coroutine_fn blk_log_writes_co_do_log(BlkLogWritesLogReq *lr) lr->zero_size, 0); } -/* Update super block on flush */ -if (lr->log_ret ==0 && lr->entry.flags &LOG_FLUSH_FLAG ) { +/* Update super block on flush or every update interval */ +if (lr->log_ret ==0 && ((lr->entry.flags &LOG_FLUSH_FLAG ) + || (s->nr_entries % s->update_interval ==0 ))) + {struct log_write_super super = { .magic =cpu_to_le64 (WRITE_LOG_MAGIC ), .version =cpu_to_le64 (WRITE_LOG_VERSION ),
Signature · 1 line
2.13.6
[Qemu-devel] [PULL v2 09/12] block/blklogwrites: Add an option for appending to an old log
In reply to Kevin WolfFrom: Ari Sundholm <[email protected]>
Suggested by Kevin Wolf. May be useful when testing multiple batches of writes or doing long-term testing involving restarts of the VM.
--- qapi/block-core.json | 3 +- block/blklogwrites.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 135 insertions(+), 15 deletions(-)
qapi/block-core.json +2 -1
@@ -3062,7 +3062,8 @@ { 'struct': 'BlockdevOptionsBlklogwrites', 'data': { 'file': 'BlockdevRef', 'log': 'BlockdevRef', - '*log-sector-size': 'uint32' } } + '*log-sector-size': 'uint32', + '*log-append': 'bool' } } ## # @BlockdevOptionsBlkverify:
block/blklogwrites.c +133 -14
184 lines not on this page · raw message
Signature · 1 line
2.13.6
Peter Maydell
AppliedQuoted 15 lines · Kevin Wolf
The following changes since commit
fe8d2d5737ab20ed0118863f5eb888cae37122ab:Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-3.0-pull-request' into staging (2018-07-04 22:38:10 +0100)
are available in the git repository at:
git://repo.or.cz/qemu/kevin.gittags/for-upstreamfor you to fetch changes up to
7c20c808a5cbf5d244735bc78fc3138c739c1946:file-posix: Unlock FD after creation (2018-07-05 11:07:58 +0200)
----------------------------------------------------------------
Block layer patches:
Quoted 8 lines
- qcow2: Use worker threads for compression to improve performance of 'qemu-img convert -W' and compressed backup jobs
- blklogwrites: New filter driver to log write requests to an image in the dm-log-writes format
- file-posix: Fix image locking during image creation
- crypto: Fix memory leak in error path
- Error out instead of silently truncating node names
Applied, thanks.
-- PMM
Re: [Qemu-devel] [PULL v2 09/12] block/blklogwrites: Add an option for appending to an old log
In reply to Kevin WolfQuoted 17 lines · Kevin Wolf
From: Ari Sundholm <[email protected]>
Suggested by Kevin Wolf. May be useful when testing multiple batches of writes or doing long-term testing involving restarts of the VM.
Signed-off-by Ari Sundholm <[email protected]>Signed-off-by Kevin Wolf <[email protected]>--- qapi/block-core.json | 3 +- block/blklogwrites.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 135 insertions(+), 15 deletions(-)qapi/block-core.json +0
-0
qapi/block-core.json line 3066
Quoted 6 lines
qapi/block-core.json +2
-1@@ -3062,7 +3062,8 @@ { 'struct': 'BlockdevOptionsBlklogwrites', 'data': { 'file': 'BlockdevRef', 'log': 'BlockdevRef', - '*log-sector-size': 'uint32' } } + '*log-sector-size': 'uint32', + '*log-append': 'bool' } }
Missing documentation (including the default value) of the new member. Since this is already pulled, please submit a followup patch.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PULL v2 09/12] block/blklogwrites: Add an option for appending to an old log
Quoted 14 lines · Eric Blake
Quoted 13 lines · Kevin Wolf
From: Ari Sundholm <[email protected]>
Suggested by Kevin Wolf. May be useful when testing multiple batches of writes or doing long-term testing involving restarts of the VM.
Signed-off-by Ari Sundholm <[email protected]>Signed-off-by Kevin Wolf <[email protected]>---
qapi/block-core.json| 3 +-
block/blklogwrites.c| 147
++++++++++++++++++++++++++++++++++++++++++++++-----2 files changed, 135 insertions(+), 15 deletions(-)
Quoted 14 lines
qapi/block-core.json line 3066
Quoted 11 lines
qapi/block-core.json +2
-1@@ -3062,7 +3062,8 @@ { 'struct': 'BlockdevOptionsBlklogwrites', 'data': { 'file': 'BlockdevRef', 'log': 'BlockdevRef', - '*log-sector-size': 'uint32' } } + '*log-sector-size': 'uint32', + '*log-append': 'bool' } }Missing documentation (including the default value) of the new member. Since this is already pulled, please submit a followup patch.
I somehow missed your message. Sorry.
Thanks for spotting this. I just sent a patch to add the missing documentation.
Thanks,
Ari Sundholm
[email protected]