From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id EBFCF62F4C for ; Tue, 14 Jul 2020 15:17:57 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D816F2759A for ; Tue, 14 Jul 2020 15:17:27 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D5FD927591 for ; Tue, 14 Jul 2020 15:17:26 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 5EAEE44141 for ; Tue, 14 Jul 2020 15:17:26 +0200 (CEST) From: Stefan Reiter To: pbs-devel@lists.proxmox.com Date: Tue, 14 Jul 2020 15:17:17 +0200 Message-Id: <20200714131717.8494-1-s.reiter@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH qemu] PVE: handle PBS write callback with big blocks correctly X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jul 2020 13:17:58 -0000 Under certain conditions QEMU will push more than the given blocksize into the callback at once. Handle it like VMA does, by iterating the data in PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE (or smaller, for last one) sized blocks. Signed-off-by: Stefan Reiter --- As briefly tested by Fabian, it seems to fix the original issue. pve-backup.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/pve-backup.c b/pve-backup.c index 77eb475563..4d423611e1 100644 --- a/pve-backup.c +++ b/pve-backup.c @@ -147,17 +147,29 @@ pvebackup_co_dump_pbs_cb( return -1; } - pbs_res = proxmox_backup_co_write_data(backup_state.pbs, di->dev_id, buf, start, size, &local_err); - qemu_co_mutex_unlock(&backup_state.dump_callback_mutex); + uint64_t transferred = 0; + uint64_t reused = 0; + while (transferred < size) { + uint64_t left = size - transferred; + uint64_t to_transfer = left < PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE ? + left : PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE; - if (pbs_res < 0) { - pvebackup_propagate_error(local_err); - return pbs_res; - } else { - size_t reused = (pbs_res == 0) ? size : 0; - pvebackup_add_transfered_bytes(size, !buf ? size : 0, reused); + pbs_res = proxmox_backup_co_write_data(backup_state.pbs, di->dev_id, + buf ? buf + transferred : NULL, start + transferred, to_transfer, &local_err); + transferred += to_transfer; + + if (pbs_res < 0) { + pvebackup_propagate_error(local_err); + qemu_co_mutex_unlock(&backup_state.dump_callback_mutex); + return pbs_res; + } + + reused += pbs_res == 0 ? to_transfer : 0; } + qemu_co_mutex_unlock(&backup_state.dump_callback_mutex); + pvebackup_add_transfered_bytes(size, !buf ? size : 0, reused); + return size; } -- 2.20.1