[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 34/36] block/backup: deal with zero detection
From: |
John Snow |
Subject: |
[Qemu-devel] [PULL 34/36] block/backup: deal with zero detection |
Date: |
Fri, 16 Aug 2019 19:13:16 -0400 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
We have detect_zeroes option, so at least for blockdev-backup user
should define it if zero-detection is needed. For drive-backup leave
detection enabled by default but do it through existing option instead
of open-coding.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: John Snow <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Message-id: address@hidden
Signed-off-by: John Snow <address@hidden>
---
block/backup.c | 15 ++++++---------
blockdev.c | 8 ++++----
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/block/backup.c b/block/backup.c
index a9be07258c1..083fc189af9 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -113,7 +113,10 @@ static int coroutine_fn
backup_cow_with_bounce_buffer(BackupBlockJob *job,
BlockBackend *blk = job->common.blk;
int nbytes;
int read_flags = is_write_notifier ? BDRV_REQ_NO_SERIALISING : 0;
- int write_flags = job->serialize_target_writes ? BDRV_REQ_SERIALISING : 0;
+ int write_flags =
+ (job->serialize_target_writes ? BDRV_REQ_SERIALISING : 0) |
+ (job->compress ? BDRV_REQ_WRITE_COMPRESSED : 0);
+
assert(QEMU_IS_ALIGNED(start, job->cluster_size));
bdrv_reset_dirty_bitmap(job->copy_bitmap, start, job->cluster_size);
@@ -131,14 +134,8 @@ static int coroutine_fn
backup_cow_with_bounce_buffer(BackupBlockJob *job,
goto fail;
}
- if (buffer_is_zero(*bounce_buffer, nbytes)) {
- ret = blk_co_pwrite_zeroes(job->target, start,
- nbytes, write_flags | BDRV_REQ_MAY_UNMAP);
- } else {
- ret = blk_co_pwrite(job->target, start,
- nbytes, *bounce_buffer, write_flags |
- (job->compress ? BDRV_REQ_WRITE_COMPRESSED : 0));
- }
+ ret = blk_co_pwrite(job->target, start, nbytes, *bounce_buffer,
+ write_flags);
if (ret < 0) {
trace_backup_do_cow_write_fail(job, start, ret);
if (error_is_read) {
diff --git a/blockdev.c b/blockdev.c
index 64d06d1f672..2e536dde3e9 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3615,7 +3615,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup,
JobTxn *txn,
BlockDriverState *source = NULL;
BlockJob *job = NULL;
AioContext *aio_context;
- QDict *options = NULL;
+ QDict *options;
Error *local_err = NULL;
int flags;
int64_t size;
@@ -3688,10 +3688,10 @@ static BlockJob *do_drive_backup(DriveBackup *backup,
JobTxn *txn,
goto out;
}
+ options = qdict_new();
+ qdict_put_str(options, "discard", "unmap");
+ qdict_put_str(options, "detect-zeroes", "unmap");
if (backup->format) {
- if (!options) {
- options = qdict_new();
- }
qdict_put_str(options, "driver", backup->format);
}
--
2.21.0
- [Qemu-devel] [PULL 21/36] iotests: test bitmap moving inside 254, (continued)
- [Qemu-devel] [PULL 21/36] iotests: test bitmap moving inside 254, John Snow, 2019/08/16
- [Qemu-devel] [PULL 19/36] blockdev: reduce aio_context locked sections in bitmap add/remove, John Snow, 2019/08/16
- [Qemu-devel] [PULL 20/36] qapi: implement block-dirty-bitmap-remove transaction action, John Snow, 2019/08/16
- [Qemu-devel] [PULL 22/36] iotests/257: add Pattern class, John Snow, 2019/08/16
- [Qemu-devel] [PULL 25/36] block/backup: hoist bitmap check into QMP interface, John Snow, 2019/08/16
- [Qemu-devel] [PULL 23/36] iotests/257: add EmulatedBitmap class, John Snow, 2019/08/16
- [Qemu-devel] [PULL 29/36] block/backup: add backup_is_cluster_allocated, John Snow, 2019/08/16
- [Qemu-devel] [PULL 28/36] block/backup: centralize copy_bitmap initialization, John Snow, 2019/08/16
- [Qemu-devel] [PULL 30/36] block/backup: teach TOP to never copy unallocated regions, John Snow, 2019/08/16
- [Qemu-devel] [PULL 27/36] block/backup: improve sync=bitmap work estimates, John Snow, 2019/08/16
- [Qemu-devel] [PULL 34/36] block/backup: deal with zero detection,
John Snow <=
- [Qemu-devel] [PULL 35/36] block/backup: refactor write_flags, John Snow, 2019/08/16
- [Qemu-devel] [PULL 33/36] qapi: add dirty-bitmaps to query-named-block-nodes result, John Snow, 2019/08/16
- [Qemu-devel] [PULL 26/36] iotests/257: test API failures, John Snow, 2019/08/16
- [Qemu-devel] [PULL 31/36] block/backup: support bitmap sync modes for non-bitmap backups, John Snow, 2019/08/16
- [Qemu-devel] [PULL 36/36] tests/test-hbitmap: test next_zero and _next_dirty_area after truncate, John Snow, 2019/08/16
- [Qemu-devel] [PULL 24/36] iotests/257: Refactor backup helpers, John Snow, 2019/08/16
- [Qemu-devel] [PULL 17/36] iotests: add test 257 for bitmap-mode backups, John Snow, 2019/08/16
- [Qemu-devel] [PULL 32/36] iotests/257: test traditional sync modes, John Snow, 2019/08/16
- Re: [Qemu-devel] [PULL 00/36] Bitmaps patches, Peter Maydell, 2019/08/19