From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 37A761FF137 for ; Tue, 14 Apr 2026 15:07:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 26874193D1; Tue, 14 Apr 2026 15:08:40 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup v3 18/30] sync: push: add helper for loading known chunks from previous snapshot Date: Tue, 14 Apr 2026 14:59:11 +0200 Message-ID: <20260414125923.892345-19-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260414125923.892345-1-c.ebner@proxmox.com> References: <20260414125923.892345-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: 1776171500956 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.069 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [push.rs] Message-ID-Hash: KDRDKCRB36CMSSXFFWOKWFEEGNZZRT5Y X-Message-ID-Hash: KDRDKCRB36CMSSXFFWOKWFEEGNZZRT5Y 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 --- changes since version 2: - desructure crypt_config from now also present key_id 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 a848c989c..f9ef924e5 100644 --- a/src/server/push.rs +++ b/src/server/push.rs @@ -810,6 +810,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((_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; + } + } + } + + // 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 @@ -904,6 +939,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() { @@ -934,16 +979,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()) @@ -971,16 +1006,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