public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH v2 proxmox-backup 4/9] server: pull: move target manifest loading logic into reusable helper
Date: Thu,  3 Dec 2026 16:04:43 +0100	[thread overview]
Message-ID: <20261203150448.412515-5-c.ebner@proxmox.com> (raw)
In-Reply-To: <20261203150448.412515-1-c.ebner@proxmox.com>

Extract the local manifest reading and parsing from pull_snapshot()
into a dedicated load_target_manifest() helper.

In preparation for checking snapshots being unchanged since the last
sync under a shared instead of exclusive lock.

No functional changes.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 src/server/pull.rs | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/src/server/pull.rs b/src/server/pull.rs
index 5ab47ac3f..308ac752b 100644
--- a/src/server/pull.rs
+++ b/src/server/pull.rs
@@ -3,6 +3,7 @@
 use std::collections::hash_map::Entry;
 use std::collections::{HashMap, HashSet};
 use std::io::Seek;
+use std::path::Path;
 use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
 use std::sync::{Arc, Mutex};
 use std::time::{Duration, SystemTime};
@@ -613,6 +614,23 @@ async fn pull_single_archive<'a>(
     Ok(sync_stats)
 }
 
+fn load_target_manifest(manifest_name: &Path, prefix: &str) -> Result<BackupManifest, Error> {
+    let manifest_blob = proxmox_lang::try_block!({
+        let mut manifest_file = std::fs::File::open(manifest_name).map_err(|err| {
+            format_err!("{prefix}: unable to open local manifest {manifest_name:?} - {err}")
+        })?;
+
+        let manifest_blob =
+            DataBlob::load_from_reader(&mut manifest_file).with_context(|| prefix.to_owned())?;
+        Ok(manifest_blob)
+    })
+    .map_err(|err: Error| {
+        format_err!("{prefix}: unable to read local manifest {manifest_name:?} - {err}")
+    })?;
+
+    BackupManifest::try_from(manifest_blob).with_context(|| prefix.to_owned())
+}
+
 /// Actual implementation of pulling a snapshot.
 ///
 /// Pulling a snapshot consists of the following steps:
@@ -690,21 +708,7 @@ async fn pull_snapshot<'a>(
     let mut manifest = BackupManifest::try_from(manifest_blob).with_context(|| prefix.clone())?;
 
     let existing_target_manifest = if manifest_name.exists() && !corrupt {
-        let manifest_blob = proxmox_lang::try_block!({
-            let mut manifest_file = std::fs::File::open(&manifest_name).map_err(|err| {
-                format_err!("{prefix}: unable to open local manifest {manifest_name:?} - {err}")
-            })?;
-
-            let manifest_blob =
-                DataBlob::load_from_reader(&mut manifest_file).with_context(|| prefix.clone())?;
-            Ok(manifest_blob)
-        })
-        .map_err(|err: Error| {
-            format_err!("{prefix}: unable to read local manifest {manifest_name:?} - {err}")
-        })?;
-
-        let existing_manifest =
-            BackupManifest::try_from(manifest_blob).with_context(|| prefix.clone())?;
+        let existing_manifest = load_target_manifest(&manifest_name, &prefix)?;
 
         // the target never inherits the source's verify state (see below), so a manifest that
         // only differs in it means the snapshot did not change since it was last synced
-- 
2.47.3





  parent reply	other threads:[~2026-12-03 15:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 15:04 [PATCH v2 proxmox-backup 0/9] pull: avoid lock contention with verify on unchanged snapshots Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 1/9] server: pull: refactor snapshot sync start logging Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 2/9] server: pull: defer sync stats instantiation until needed Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 3/9] server: pull: load source manifest into memory instead of a temp file Christian Ebner
2026-12-03 15:04 ` Christian Ebner [this message]
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 5/9] server: pull: decouple decryption key gathering from logging Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 6/9] pbs-datastore: add BackupDir::lock_with_timeout() Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 7/9] pbs-datastore: add create_locked_backup_dir_with_timeout() Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 8/9] server: pull: check for unchanged snapshots under a shared lock Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 9/9] server: pull: skip exclusive lock when source has no client log Christian Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203150448.412515-5-c.ebner@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal