]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0047-PVE-add-zero-block-handling-to-PBS-dump-callback.patch
Update to QEMU 5.2
[pve-qemu.git] / debian / patches / pve / 0047-PVE-add-zero-block-handling-to-PBS-dump-callback.patch
CommitLineData
c5f7dc1d
TL
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Stefan Reiter <s.reiter@proxmox.com>
3Date: Thu, 13 Aug 2020 13:50:27 +0200
4Subject: [PATCH] PVE: add zero block handling to PBS dump callback
5
6Both the PBS and VMA dump callbacks assume that a NULL pointer can be
7passed as *pbuf, but that never happens, as backup-dump.c calls this
8function with contents of an iovec.
9
10So first, remove that assumption and add an 'assert' to verify.
11
12Secondly, while the vma-writer already does the buffer_is_zero check
13internally, for PBS we relied on that non-existant behaviour for zero
14chunks, so do the buffer_is_zero check manually and pass NULL to the
15rust lib in case it is true.
16
17Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
18---
19 pve-backup.c | 14 +++++++++-----
20 1 file changed, 9 insertions(+), 5 deletions(-)
21
22diff --git a/pve-backup.c b/pve-backup.c
817b7667 23index 3eba85506a..40c2697b37 100644
c5f7dc1d
TL
24--- a/pve-backup.c
25+++ b/pve-backup.c
26@@ -8,6 +8,7 @@
27 #include "block/blockjob.h"
28 #include "qapi/qapi-commands-block.h"
29 #include "qapi/qmp/qerror.h"
30+#include "qemu/cutils.h"
31
32 /* PVE backup state and related function */
33
34@@ -136,10 +137,13 @@ pvebackup_co_dump_pbs_cb(
35 PVEBackupDevInfo *di = opaque;
36
37 assert(backup_state.pbs);
38+ assert(buf);
39
40 Error *local_err = NULL;
41 int pbs_res = -1;
42
43+ bool is_zero_block = size == di->block_size && buffer_is_zero(buf, size);
44+
45 qemu_co_mutex_lock(&backup_state.dump_callback_mutex);
46
47 // avoid deadlock if job is cancelled
48@@ -155,7 +159,8 @@ pvebackup_co_dump_pbs_cb(
49 uint64_t to_transfer = left < di->block_size ? left : di->block_size;
50
51 pbs_res = proxmox_backup_co_write_data(backup_state.pbs, di->dev_id,
52- buf ? buf + transferred : NULL, start + transferred, to_transfer, &local_err);
53+ is_zero_block ? NULL : buf + transferred, start + transferred,
54+ to_transfer, &local_err);
55 transferred += to_transfer;
56
57 if (pbs_res < 0) {
58@@ -168,7 +173,7 @@ pvebackup_co_dump_pbs_cb(
59 }
60
61 qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
62- pvebackup_add_transfered_bytes(size, !buf ? size : 0, reused);
63+ pvebackup_add_transfered_bytes(size, is_zero_block ? size : 0, reused);
64
65 return size;
66 }
67@@ -190,6 +195,7 @@ pvebackup_co_dump_vma_cb(
68 int ret = -1;
69
70 assert(backup_state.vmaw);
71+ assert(buf);
72
73 uint64_t remaining = size;
74
75@@ -216,9 +222,7 @@ pvebackup_co_dump_vma_cb(
76 qemu_co_mutex_unlock(&backup_state.dump_callback_mutex);
77
78 ++cluster_num;
79- if (buf) {
80- buf += VMA_CLUSTER_SIZE;
81- }
82+ buf += VMA_CLUSTER_SIZE;
83 if (ret < 0) {
84 Error *local_err = NULL;
85 vma_writer_error_propagate(backup_state.vmaw, &local_err);