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: [pbs-devel] [PATCH proxmox-backup v3 7/7] api: config: guard s3-refresh on datastore recreation
Date: Thu, 13 Nov 2025 15:22:14 +0100	[thread overview]
Message-ID: <20251113142214.719217-8-c.ebner@proxmox.com> (raw)
In-Reply-To: <20251113142214.719217-1-c.ebner@proxmox.com>

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 <c.ebner@proxmox.com>
---
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


  parent reply	other threads:[~2025-11-13 14:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 14:22 [pbs-devel] [PATCH proxmox-backup v3 0/7] wait for active operations to finish before s3 refresh Christian Ebner
2025-11-13 14:22 ` [pbs-devel] [PATCH proxmox-backup v3 1/7] api: admin: drop useless option for do_unmount_device() parameter Christian Ebner
2025-11-13 14:22 ` [pbs-devel] [PATCH proxmox-backup v3 2/7] api: admin: rework waiting on active operations and maintenance locking Christian Ebner
2025-11-13 14:22 ` [pbs-devel] [PATCH proxmox-backup v3 3/7] api: admin: make s3 refresh handler sync Christian Ebner
2025-11-13 14:22 ` [pbs-devel] [PATCH proxmox-backup v3 4/7] datastore: s3 refresh: set/unset maintenance mode in api handler Christian Ebner
2025-11-13 14:22 ` [pbs-devel] [PATCH proxmox-backup v3 5/7] api: datastore: wait for active operations to clear before s3 refresh Christian Ebner
2025-11-13 14:22 ` [pbs-devel] [PATCH proxmox-backup v3 6/7] api: config: avoid unneeded backend instance on s3 store recreation Christian Ebner
2025-11-13 14:22 ` Christian Ebner [this message]
2025-11-14  8:48 ` [pbs-devel] applied-series: [PATCH proxmox-backup v3 0/7] wait for active operations to finish before s3 refresh Fabian Grünbichler

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=20251113142214.719217-8-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