From: Max Reitz <mreitz@redhat.com>
To: John Snow <jsnow@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-block@nongnu.org
Cc: kwolf@redhat.com, den@openvz.org, armbru@redhat.com,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] block/backup: deal with zero detection
Date: Thu, 1 Aug 2019 13:18:04 +0200 [thread overview]
Message-ID: <9bb902a3-d2f2-6cf8-8adb-832ccbfde8f9@redhat.com> (raw)
In-Reply-To: <f13fdafd-34d2-3079-ab17-78cdb7e9f428@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 3850 bytes --]
On 30.07.19 20:40, John Snow wrote:
>
>
> On 7/30/19 12:32 PM, Vladimir Sementsov-Ogievskiy wrote:
>> 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 <vsementsov@virtuozzo.com>
>> ---
>> 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 715e1d3be8..f4aaf08df3 100644
>> --- a/block/backup.c
>> +++ b/block/backup.c
>> @@ -110,7 +110,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));
>> hbitmap_reset(job->copy_bitmap, start, job->cluster_size);
>> @@ -128,14 +131,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 4d141e9a1f..a94d754504 100644
>> --- a/blockdev.c
>> +++ b/blockdev.c
>> @@ -3434,7 +3434,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
>> BlockJob *job = NULL;
>> BdrvDirtyBitmap *bmap = NULL;
>> AioContext *aio_context;
>> - QDict *options = NULL;
>> + QDict *options;
>> Error *local_err = NULL;
>> int flags, job_flags = JOB_DEFAULT;
>> int64_t size;
>> @@ -3529,10 +3529,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);
>> }
>>
>>
>
> I'm less sure of this one personally. Is it right to always try to set
> unmap on the target?
>
> I like the idea of removing special cases and handling things more
> centrally though, but I'll want Max (or Kevin) to take a peek.
I don’t quite know why, because this is just a block job specific
question and doesn’t have much to do with the rest of the block layer,
but OK. :-)
drive-backup always set BDRV_REQ_MAY_UNMAP, as you can see. Maybe that
didn’t do anything because the target wasn’t opened with discard=unmap.
But to me, it’s clear that the intention was to indeed unmap the areas
in the target (it isn’t like the user had a choice of opening the target
with discard=unmap or not).
Max
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-08-01 11:19 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-30 16:32 [Qemu-devel] [PATCH 0/3] backup fixes for 4.1? Vladimir Sementsov-Ogievskiy
2019-07-30 16:32 ` [Qemu-devel] [PATCH 1/3] block/backup: deal with zero detection Vladimir Sementsov-Ogievskiy
2019-07-30 18:40 ` John Snow
2019-07-31 10:01 ` Vladimir Sementsov-Ogievskiy
2019-07-31 13:45 ` John Snow
2019-08-01 11:18 ` Max Reitz [this message]
2019-08-01 11:18 ` Max Reitz
2019-07-30 16:32 ` [Qemu-devel] [PATCH 2/3] block/backup: disable copy_range for compressed backup Vladimir Sementsov-Ogievskiy
2019-07-30 18:22 ` John Snow
2019-07-31 13:51 ` Vladimir Sementsov-Ogievskiy
2019-08-01 11:20 ` Max Reitz
2019-08-05 16:05 ` Max Reitz
2019-07-30 16:32 ` [Qemu-devel] [PATCH 3/3] block/backup: refactor write_flags Vladimir Sementsov-Ogievskiy
2019-07-30 18:28 ` John Snow
2019-07-31 16:01 ` Vladimir Sementsov-Ogievskiy
2019-08-01 11:28 ` Max Reitz
2019-08-01 11:32 ` Vladimir Sementsov-Ogievskiy
2019-08-01 11:37 ` Max Reitz
2019-08-01 12:02 ` Vladimir Sementsov-Ogievskiy
2019-08-01 12:21 ` Max Reitz
2019-08-01 12:40 ` Vladimir Sementsov-Ogievskiy
2019-08-01 11:28 ` Max Reitz
2019-07-30 18:41 ` [Qemu-devel] [PATCH 0/3] backup fixes for 4.1? John Snow
2019-07-31 10:29 ` Vladimir Sementsov-Ogievskiy
2019-07-31 13:46 ` John Snow
2019-08-07 23:52 ` John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9bb902a3-d2f2-6cf8-8adb-832ccbfde8f9@redhat.com \
--to=mreitz@redhat.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).