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 360E11FF13E for ; Fri, 17 Apr 2026 11:26:41 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 178681B90C; Fri, 17 Apr 2026 11:26:41 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup v6 08/15] sync: pull: factor out backup group locking and owner check Date: Fri, 17 Apr 2026 11:26:14 +0200 Message-ID: <20260417092621.455374-9-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260417092621.455374-1-c.ebner@proxmox.com> References: <20260417092621.455374-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: 1776417914189 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: OPXUBNHG45AIRJDVX4BOCFFM3OCHOSO6 X-Message-ID-Hash: OPXUBNHG45AIRJDVX4BOCFFM3OCHOSO6 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: Creates a dedicated entry point for parallel group pulling and simplifies the backup group loop logic. While locking and owner check could have been moved to pull_group() as well, that function is already hard to parse as is. Logging of errors is moved to the helper to facilitate it for parallel pulling. Signed-off-by: Christian Ebner --- changes since version 5: - adapted to better fit subsequent introduction of log line sender src/server/pull.rs | 76 +++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/src/server/pull.rs b/src/server/pull.rs index 45fe9f8b1..7126a5102 100644 --- a/src/server/pull.rs +++ b/src/server/pull.rs @@ -1050,6 +1050,47 @@ pub(crate) async fn pull_store(mut params: PullParameters) -> Result Result { + let (owner, _lock_guard) = + match params + .target + .store + .create_locked_backup_group(target_namespace, group, ¶ms.owner) + { + Ok(res) => res, + Err(err) => { + info!("sync group {group} failed - group lock failed: {err}"); + info!("create_locked_backup_group failed"); + return Err(err); + } + }; + + if params.owner != owner { + // only the owner is allowed to create additional snapshots + info!( + "sync group {group} failed - owner check failed ({} != {owner})", + params.owner + ); + return Err(format_err!("owner check failed")); + } + + match pull_group(params, namespace, group, progress).await { + Ok(stats) => Ok(stats), + Err(err) => { + info!("sync group {group} failed - {err:#}"); + Err(err) + } + } +} + /// Pulls a namespace according to `params`. /// /// Pulling a namespace consists of the following steps: @@ -1098,38 +1139,9 @@ async fn pull_ns( progress.done_snapshots = 0; progress.group_snapshots = 0; - let (owner, _lock_guard) = - match params - .target - .store - .create_locked_backup_group(&target_ns, &group, ¶ms.owner) - { - Ok(result) => result, - Err(err) => { - info!("sync group {} failed - group lock failed: {err}", &group); - errors = true; - // do not stop here, instead continue - info!("create_locked_backup_group failed"); - continue; - } - }; - - // permission check - if params.owner != owner { - // only the owner is allowed to create additional snapshots - info!( - "sync group {} failed - owner check failed ({} != {owner})", - &group, params.owner - ); - errors = true; // do not stop here, instead continue - } else { - match pull_group(params, namespace, &group, &mut progress).await { - Ok(stats) => sync_stats.add(stats), - Err(err) => { - info!("sync group {} failed - {err:#}", &group); - errors = true; // do not stop here, instead continue - } - } + match lock_and_pull_group(params, &group, &namespace, &target_ns, &mut progress).await { + Ok(stats) => sync_stats.add(stats), + Err(_err) => errors = true, } } -- 2.47.3