[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH v12 2/2] block/backup: fix backup_c
Re: [Qemu-block] [Qemu-devel] [PATCH v12 2/2] block/backup: fix backup_cow_with_offload for last cluster
Wed, 18 Sep 2019 16:14:22 -0400
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0
On 9/17/19 12:07 PM, Vladimir Sementsov-Ogievskiy wrote:
We shouldn't try to copy bytes beyond EOF. Fix it.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
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
@@ -161,7 +161,7 @@ static int coroutine_fn
- 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
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?
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?
job->cluster_size * nr_clusters);