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 AAA6A8D257 for ; Mon, 7 Nov 2022 15:59:21 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 84C062D212 for ; Mon, 7 Nov 2022 15:58:51 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 for ; Mon, 7 Nov 2022 15:58:50 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A6CBE41659 for ; Mon, 7 Nov 2022 15:58:50 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Date: Mon, 7 Nov 2022 15:58:45 +0100 Message-Id: <20221107145845.373811-1-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.034 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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] applied: [PATCH] pbs: prune: avoid getting all snapshots for group assembly if fixed anyway 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: Mon, 07 Nov 2022 14:59:21 -0000 If both type and vmid is defined we don't need to list the current snapshots, we simply can derive the single backup group from that and let the PBS client handle the rest. Should be a not so small speedup for most setups using PBS backup and pruning configured on PVE side, as vzdump calls this separately for every vmid on backup jobs with multiple guests included. Signed-off-by: Thomas Lamprecht --- PVE/Storage/PBSPlugin.pm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/PVE/Storage/PBSPlugin.pm b/PVE/Storage/PBSPlugin.pm index 633c399..4320974 100644 --- a/PVE/Storage/PBSPlugin.pm +++ b/PVE/Storage/PBSPlugin.pm @@ -403,19 +403,25 @@ sub prune_backups { $logfunc //= sub { print "$_[1]\n" }; - my $backups = eval { $class->list_volumes($storeid, $scfg, $vmid, ['backup']) }; - die "failed to get list of all backups to prune - $@" if $@; - $type = 'vm' if defined($type) && $type eq 'qemu'; $type = 'ct' if defined($type) && $type eq 'lxc'; my $backup_groups = {}; - foreach my $backup (@{$backups}) { - (my $backup_type = $backup->{format}) =~ s/^pbs-//; - next if defined($type) && $backup_type ne $type; - my $backup_group = "$backup_type/$backup->{vmid}"; - $backup_groups->{$backup_group} = 1; + if (defined($vmid) && defined($type)) { + # no need to get the list of volumes, we only got a single backup group anyway + $backup_groups->{"$type/$vmid"} = 1; + } else { + my $backups = eval { $class->list_volumes($storeid, $scfg, $vmid, ['backup']) }; + die "failed to get list of all backups to prune - $@" if $@; + + foreach my $backup (@{$backups}) { + (my $backup_type = $backup->{format}) =~ s/^pbs-//; + next if defined($type) && $backup_type ne $type; + + my $backup_group = "$backup_type/$backup->{vmid}"; + $backup_groups->{$backup_group} = 1; + } } my @param; -- 2.34.1