From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 4D2231FF140 for ; Fri, 10 Apr 2026 18:55:31 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 02C31241F0; Fri, 10 Apr 2026 18:56:13 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup v2 17/27] sync: push: add helper for loading known chunks from previous snapshot Date: Fri, 10 Apr 2026 18:54:44 +0200 Message-ID: <20260410165454.1578501-18-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260410165454.1578501-1-c.ebner@proxmox.com> References: <20260410165454.1578501-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1775840039327 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.070 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 Message-ID-Hash: GF6WGDATBDMLGGSYZBIVWSDUBAGQMZBK X-Message-ID-Hash: GF6WGDATBDMLGGSYZBIVWSDUBAGQMZBK X-MailFrom: c.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Loading of known chunks only makes sense for snapshots which do not need encryption while pushing. To check this move the known chunk loading into a common helper method and distinguish dynamic/fixed index for loading based on archive type. Signed-off-by: Christian Ebner --- src/server/push.rs | 65 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/src/server/push.rs b/src/server/push.rs index 02718b7b6..9b7a4adcb 100644 --- a/src/server/push.rs +++ b/src/server/push.rs @@ -808,6 +808,41 @@ pub(crate) async fn push_group( Ok(stats) } +async fn load_previous_snapshot_known_chunks( + params: &PushParameters, + upload_options: &UploadOptions, + backup_writer: &BackupWriter, + archive_name: &BackupArchiveName, + known_chunks: Arc>>, +) { + if let Some(manifest) = upload_options.previous_manifest.as_ref() { + if let Some(crypt_config) = ¶ms.crypt_config { + if let Ok(Some(fingerprint)) = manifest.fingerprint() { + if *fingerprint.bytes() == crypt_config.fingerprint() { + // needs encryption during push, cannot reuse chunks from previous manifest + return; + } + } + } + + // Add known chunks, ignore errors since archive might not be present and it is better + // to proceed on unrelated errors than to fail here. + match archive_name.archive_type() { + ArchiveType::FixedIndex => { + let _res = backup_writer + .download_previous_fixed_index(archive_name, manifest, known_chunks) + .await; + } + ArchiveType::DynamicIndex => { + let _res = backup_writer + .download_previous_dynamic_index(archive_name, manifest, known_chunks) + .await; + } + ArchiveType::Blob => (), + }; + } +} + /// Push snapshot to target /// /// Creates a new snapshot on the target and pushes the content of the source snapshot to the @@ -902,6 +937,16 @@ pub(crate) async fn push_snapshot( path.push(&entry.filename); if path.try_exists()? { let archive_name = BackupArchiveName::from_path(&entry.filename)?; + + load_previous_snapshot_known_chunks( + params, + &upload_options, + &backup_writer, + &archive_name, + known_chunks.clone(), + ) + .await; + match archive_name.archive_type() { ArchiveType::Blob => { let backup_stats = if encrypt_using_key.is_some() { @@ -932,16 +977,6 @@ pub(crate) async fn push_snapshot( }); } ArchiveType::DynamicIndex => { - if let Some(manifest) = upload_options.previous_manifest.as_ref() { - // Add known chunks, ignore errors since archive might not be present - let _res = backup_writer - .download_previous_dynamic_index( - &archive_name, - manifest, - known_chunks.clone(), - ) - .await; - } let index = DynamicIndexReader::open(&path)?; let chunk_reader = reader .chunk_reader(entry.chunk_crypt_mode()) @@ -969,16 +1004,6 @@ pub(crate) async fn push_snapshot( }); } ArchiveType::FixedIndex => { - if let Some(manifest) = upload_options.previous_manifest.as_ref() { - // Add known chunks, ignore errors since archive might not be present - let _res = backup_writer - .download_previous_fixed_index( - &archive_name, - manifest, - known_chunks.clone(), - ) - .await; - } let index = FixedIndexReader::open(&path)?; let chunk_reader = reader .chunk_reader(entry.chunk_crypt_mode()) -- 2.47.3