2019-10-24 09:49:05 +03:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Dietmar Maurer <dietmar@proxmox.com>
|
|
|
|
Date: Thu, 24 Oct 2019 08:06:51 +0200
|
|
|
|
Subject: [PATCH] avoid calling dump_cb with NULL data pointer for small/last
|
|
|
|
cluster
|
|
|
|
|
|
|
|
The last block of a backup may be smaller than cluster_size.
|
|
|
|
|
|
|
|
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
|
|
|
|
---
|
|
|
|
block/backup.c | 7 ++++++-
|
|
|
|
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/block/backup.c b/block/backup.c
|
2019-11-22 12:05:29 +03:00
|
|
|
index 2398a4d602..c682c99f7a 100644
|
2019-10-24 09:49:05 +03:00
|
|
|
--- a/block/backup.c
|
|
|
|
+++ b/block/backup.c
|
2019-11-20 17:45:35 +03:00
|
|
|
@@ -131,7 +131,12 @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,
|
2019-10-24 09:49:05 +03:00
|
|
|
|
2019-11-20 17:45:35 +03:00
|
|
|
if (buffer_is_zero(*bounce_buffer, nbytes)) {
|
2019-10-24 09:49:05 +03:00
|
|
|
if (job->dump_cb) {
|
2019-11-20 17:45:35 +03:00
|
|
|
- ret = job->dump_cb(job->common.job.opaque, job->target, start, nbytes, NULL);
|
|
|
|
+ if (nbytes == job->cluster_size) {
|
2019-10-24 09:49:05 +03:00
|
|
|
+ // Note: pass NULL to indicate that we want to write [0u8; cluster_size]
|
2019-11-20 17:45:35 +03:00
|
|
|
+ ret = job->dump_cb(job->common.job.opaque, job->target, start, nbytes, NULL);
|
2019-10-24 09:49:05 +03:00
|
|
|
+ } else {
|
2019-11-20 17:45:35 +03:00
|
|
|
+ ret = job->dump_cb(job->common.job.opaque, job->target, start, nbytes, *bounce_buffer);
|
2019-10-24 09:49:05 +03:00
|
|
|
+ }
|
|
|
|
} else {
|
|
|
|
ret = blk_co_pwrite_zeroes(job->target, start,
|
2019-11-20 17:45:35 +03:00
|
|
|
nbytes, write_flags | BDRV_REQ_MAY_UNMAP);
|