From: John Snow <jsnow@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-block@nongnu.org
Cc: kwolf@redhat.com, den@openvz.org, mreitz@redhat.com,
qemu-devel@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v12 2/2] block/backup: fix backup_cow_with_offload for last cluster
Date: Wed, 18 Sep 2019 16:14:22 -0400 [thread overview]
Message-ID: <d5144da7-687c-f37e-4e6a-0687605aca0b@redhat.com> (raw)
In-Reply-To: <20190917160731.10895-3-vsementsov@virtuozzo.com>
On 9/17/19 12:07 PM, Vladimir Sementsov-Ogievskiy wrote:
> We shouldn't try to copy bytes beyond EOF. Fix it.
>
> Fixes: 9ded4a0114968e
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Reviewed-by: Max Reitz <mreitz@redhat.com>
> ---
> block/backup.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/backup.c b/block/backup.c
> index d8fdbfadfe..89f7f89200 100644
> --- a/block/backup.c
> +++ b/block/backup.c
> @@ -161,7 +161,7 @@ static int coroutine_fn backup_cow_with_offload(BackupBlockJob *job,
>
> assert(QEMU_IS_ALIGNED(job->copy_range_size, job->cluster_size));
> assert(QEMU_IS_ALIGNED(start, job->cluster_size));
> - nbytes = MIN(job->copy_range_size, end - start);
> + nbytes = MIN(job->copy_range_size, MIN(end, job->len) - start);
I'm a little confused. I think the patch as written is correct, but I
don't know what problem it solves.
If we're going to allow the caller to pass in an end that's beyond EOF,
does that mean we are *requiring* the caller to pass in a value that's
aligned?
We should probably assert what kind of a value we're accepted here,
right? We do for start, but should we for 'end' as well?
Then ...
> nr_clusters = DIV_ROUND_UP(nbytes, job->cluster_size);
Don't we just round this right back up immediately anyway? Does that
mean we have callers that are passing in an 'end' that's more than 1
job-cluster beyond EOF? That seems like something that should be fixed
in the caller, surely?
> bdrv_reset_dirty_bitmap(job->copy_bitmap, start,
> job->cluster_size * nr_clusters);
>
next prev parent reply other threads:[~2019-09-18 20:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-17 16:07 [Qemu-devel] [PATCH v12 0/2] backup: copy_range fixes Vladimir Sementsov-Ogievskiy
2019-09-17 16:07 ` [Qemu-devel] [PATCH v12 1/2] block/backup: fix max_transfer handling for copy_range Vladimir Sementsov-Ogievskiy
2019-09-18 19:57 ` John Snow
2019-09-19 6:50 ` Vladimir Sementsov-Ogievskiy
2019-09-20 1:13 ` John Snow
2019-09-20 7:52 ` Vladimir Sementsov-Ogievskiy
2019-09-17 16:07 ` [Qemu-devel] [PATCH v12 2/2] block/backup: fix backup_cow_with_offload for last cluster Vladimir Sementsov-Ogievskiy
2019-09-18 20:14 ` John Snow [this message]
2019-09-19 7:02 ` Vladimir Sementsov-Ogievskiy
2019-09-20 0:55 ` 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=d5144da7-687c-f37e-4e6a-0687605aca0b@redhat.com \
--to=jsnow@redhat.com \
--cc=den@openvz.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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).