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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id ACA63608E3; Thu, 13 Aug 2020 13:50:36 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 998B219A97; Thu, 13 Aug 2020 13:50:36 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 3F22C19A8D; Thu, 13 Aug 2020 13:50:35 +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 01EB3445D8; Thu, 13 Aug 2020 13:50:35 +0200 (CEST) From: Stefan Reiter To: pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com Date: Thu, 13 Aug 2020 13:50:27 +0200 Message-Id: <20200813115027.11333-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 AWL -0.064 Adjusted score from AWL reputation of From: address 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: [pve-devel] [PATCH qemu] PVE: add zero block handling to PBS dump callback X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2020 11:50:36 -0000 Both the PBS and VMA dump callbacks assume that a NULL pointer can be passed as *pbuf, but that never happens, as backup-dump.c calls this function with contents of an iovec. So first, remove that assumption and add an 'assert' to verify. Secondly, while the vma-writer already does the buffer_is_zero check internally, for PBS we relied on that non-existant behaviour for zero chunks, so do the buffer_is_zero check manually and pass NULL to the rust lib in case it is true. Signed-off-by: Stefan Reiter --- This increases backup speed to PBS for VMs with free space quite dramatically. pve-backup.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pve-backup.c b/pve-backup.c index 40d8136f1a..7c99554514 100644 --- a/pve-backup.c +++ b/pve-backup.c @@ -8,6 +8,7 @@ #include "block/blockjob.h" #include "qapi/qapi-commands-block.h" #include "qapi/qmp/qerror.h" +#include "qemu/cutils.h" /* PVE backup state and related function */ @@ -136,10 +137,13 @@ pvebackup_co_dump_pbs_cb( PVEBackupDevInfo *di = opaque; assert(backup_state.pbs); + assert(buf); Error *local_err = NULL; int pbs_res = -1; + bool is_zero_block = size == di->block_size && buffer_is_zero(buf, size); + qemu_co_mutex_lock(&backup_state.dump_callback_mutex); // avoid deadlock if job is cancelled @@ -155,7 +159,8 @@ pvebackup_co_dump_pbs_cb( uint64_t to_transfer = left < di->block_size ? left : di->block_size; pbs_res = proxmox_backup_co_write_data(backup_state.pbs, di->dev_id, - buf ? buf + transferred : NULL, start + transferred, to_transfer, &local_err); + is_zero_block ? NULL : buf + transferred, start + transferred, + to_transfer, &local_err); transferred += to_transfer; if (pbs_res < 0) { @@ -168,7 +173,7 @@ pvebackup_co_dump_pbs_cb( } qemu_co_mutex_unlock(&backup_state.dump_callback_mutex); - pvebackup_add_transfered_bytes(size, !buf ? size : 0, reused); + pvebackup_add_transfered_bytes(size, is_zero_block ? size : 0, reused); return size; } @@ -190,6 +195,7 @@ pvebackup_co_dump_vma_cb( int ret = -1; assert(backup_state.vmaw); + assert(buf); uint64_t remaining = size; @@ -216,9 +222,7 @@ pvebackup_co_dump_vma_cb( qemu_co_mutex_unlock(&backup_state.dump_callback_mutex); ++cluster_num; - if (buf) { - buf += VMA_CLUSTER_SIZE; - } + buf += VMA_CLUSTER_SIZE; if (ret < 0) { Error *local_err = NULL; vma_writer_error_propagate(backup_state.vmaw, &local_err); -- 2.20.1