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 BBC5E1FF136 for ; Mon, 20 Apr 2026 18:16:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EF5FA942D; Mon, 20 Apr 2026 18:16:40 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup v4 18/30] sync: push: add helper for loading known chunks from previous snapshot Date: Mon, 20 Apr 2026 18:15:21 +0200 Message-ID: <20260420161533.1055484-19-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260420161533.1055484-1-c.ebner@proxmox.com> References: <20260420161533.1055484-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: 1776701666899 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: QL67D3BGA6K556LTDRXRH4I7XJE2QGOW X-Message-ID-Hash: QL67D3BGA6K556LTDRXRH4I7XJE2QGOW 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 | 69 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/src/server/push.rs b/src/server/push.rs index 74094225c..5c76cf2eb 100644 --- a/src/server/push.rs +++ b/src/server/push.rs @@ -816,6 +816,45 @@ 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((_id, 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; + } + } else { + // previous manifest is not pre-encrypted or failed to check if so, + // fallback to not reuse chunks + 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 @@ -910,6 +949,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() { @@ -940,16 +989,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()) @@ -977,16 +1016,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