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 89BAA1FF17E for ; Thu, 13 Nov 2025 15:21:39 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CAD691E257; Thu, 13 Nov 2025 15:22:31 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Thu, 13 Nov 2025 15:22:14 +0100 Message-ID: <20251113142214.719217-8-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251113142214.719217-1-c.ebner@proxmox.com> References: <20251113142214.719217-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1763043720708 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.048 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 Subject: [pbs-devel] [PATCH proxmox-backup v3 7/7] api: config: guard s3-refresh on datastore recreation X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Makes sure to wait for active operations to finish and then lock the maintenance mode during the s3 refresh, which requires exclusive access to the datastore contents. Since this already holds the datastore lock, only update the maintenance mode before using the previously introduced helper, which now assures better consistency. Signed-off-by: Christian Ebner --- changes since version 1: - not present in previous version src/api2/config/datastore.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs index 0bbf2002f..ec7ca0e33 100644 --- a/src/api2/config/datastore.rs +++ b/src/api2/config/datastore.rs @@ -15,9 +15,9 @@ use proxmox_uuid::Uuid; use pbs_api_types::{ Authid, DataStoreConfig, DataStoreConfigUpdater, DatastoreBackendType, DatastoreNotify, - DatastoreTuning, KeepOptions, MaintenanceMode, Operation, PruneJobConfig, PruneJobOptions, - DATASTORE_SCHEMA, PRIV_DATASTORE_ALLOCATE, PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_MODIFY, - PRIV_SYS_MODIFY, PROXMOX_CONFIG_DIGEST_SCHEMA, UPID_SCHEMA, + DatastoreTuning, KeepOptions, MaintenanceMode, MaintenanceType, PruneJobConfig, + PruneJobOptions, DATASTORE_SCHEMA, PRIV_DATASTORE_ALLOCATE, PRIV_DATASTORE_AUDIT, + PRIV_DATASTORE_MODIFY, PRIV_SYS_MODIFY, PROXMOX_CONFIG_DIGEST_SCHEMA, UPID_SCHEMA, }; use pbs_config::BackupLockGuard; use pbs_datastore::chunk_store::ChunkStore; @@ -107,7 +107,7 @@ impl Drop for UnmountGuard { pub(crate) fn do_create_datastore( _lock: BackupLockGuard, mut config: SectionConfigData, - datastore: DataStoreConfig, + mut datastore: DataStoreConfig, reuse_datastore: bool, overwrite_in_use: bool, ) -> Result<(), Error> { @@ -194,6 +194,12 @@ pub(crate) fn do_create_datastore( }); } } + // starting out in maintenance mode s3-refresh, + // so no other operation will start until done with that. + datastore.set_maintenance_mode(Some(MaintenanceMode { + ty: MaintenanceType::S3Refresh, + message: None, + }))?; } let backup_user = pbs_config::backup_user()?; ChunkStore::create( @@ -348,7 +354,7 @@ pub fn create_datastore( Some(store_name.clone()), auth_id.to_string(), to_stdout, - move |_worker| { + move |worker| { do_create_datastore( lock, section_config, @@ -361,16 +367,8 @@ pub fn create_datastore( do_create_prune_job(prune_job_config)?; } - if reuse_datastore { - let datastore = pbs_datastore::DataStore::lookup_datastore( - &store_name, - Some(Operation::Lookup), - ) - .context("failed to lookup datastore")?; - if backend == DatastoreBackendType::S3 { - proxmox_async::runtime::block_on(datastore.s3_refresh()) - .context("S3 refresh failed")?; - } + if reuse_datastore && backend == DatastoreBackendType::S3 { + crate::api2::admin::datastore::do_s3_refresh(&store_name, &worker)?; } Ok(()) }, -- 2.47.3 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel