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 proxmox-backup v3 3/7] pbs-config/datastore: add common helper for parsing tuning options
Date: Tue, 12 May 2026 15:10:43 +0200	[thread overview]
Message-ID: <20260512131047.689089-4-c.ebner@proxmox.com> (raw)
In-Reply-To: <20260512131047.689089-1-c.ebner@proxmox.com>

The datastore tuning options are parsed in several places, add and
use a common helper just like for the datastore backend config.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 pbs-config/src/datastore.rs    | 12 +++++++++++-
 pbs-datastore/src/datastore.rs | 25 ++++++-------------------
 src/api2/config/datastore.rs   | 12 ++++--------
 3 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/pbs-config/src/datastore.rs b/pbs-config/src/datastore.rs
index d75d6c557..704841fb2 100644
--- a/pbs-config/src/datastore.rs
+++ b/pbs-config/src/datastore.rs
@@ -6,7 +6,7 @@ use anyhow::Error;
 use proxmox_schema::{AllOfSchema, ApiType};
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
 
-use pbs_api_types::{DataStoreConfig, DatastoreBackendConfig, DATASTORE_SCHEMA};
+use pbs_api_types::{DataStoreConfig, DatastoreBackendConfig, DatastoreTuning, DATASTORE_SCHEMA};
 
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard, ConfigVersionCache};
 
@@ -119,6 +119,16 @@ pub fn parse_backend_config(config: &DataStoreConfig) -> Result<DatastoreBackend
     config.backend.as_deref().unwrap_or("").parse()
 }
 
+/// Parse the datastore tuning options from a datastore config.
+pub fn parse_datastore_tuning_options(config: &DataStoreConfig) -> Result<DatastoreTuning, Error> {
+    config
+        .tuning
+        .as_deref()
+        .unwrap_or("")
+        .parse()
+        .map_err(Error::from)
+}
+
 /// Returns the datastore backend type from its name.
 pub fn datastore_backend_type(store: &str) -> Result<pbs_api_types::DatastoreBackendType, Error> {
     let (config, _) = self::config()?;
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index e39bdeb0a..b589ff1e0 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -33,8 +33,8 @@ use proxmox_worker_task::WorkerTaskContext;
 use pbs_api_types::{
     ArchiveType, Authid, BackupGroupDeleteStats, BackupNamespace, BackupType, ChunkOrder,
     DataStoreConfig, DatastoreBackendConfig, DatastoreBackendType, DatastoreFSyncLevel,
-    DatastoreTuning, GarbageCollectionCacheStats, GarbageCollectionStatus, MaintenanceMode,
-    MaintenanceType, Operation, S3Statistics, MAX_NAMESPACE_DEPTH, UPID,
+    GarbageCollectionCacheStats, GarbageCollectionStatus, MaintenanceMode, MaintenanceType,
+    Operation, S3Statistics, MAX_NAMESPACE_DEPTH, UPID,
 };
 use pbs_config::s3::S3_CFG_TYPE_ID;
 use pbs_config::{BackupLockGuard, ConfigVersionCache};
@@ -599,10 +599,7 @@ impl DataStore {
             }
             Arc::clone(&datastore.chunk_store)
         } else {
-            let tuning: DatastoreTuning = serde_json::from_value(
-                DatastoreTuning::API_SCHEMA
-                    .parse_property_string(config.tuning.as_deref().unwrap_or(""))?,
-            )?;
+            let tuning = pbs_config::datastore::parse_datastore_tuning_options(&config)?;
             Arc::new(ChunkStore::open(
                 lookup.name,
                 config.absolute_path(),
@@ -691,10 +688,7 @@ impl DataStore {
 
         ensure_datastore_is_mounted(&config)?;
 
-        let tuning: DatastoreTuning = serde_json::from_value(
-            DatastoreTuning::API_SCHEMA
-                .parse_property_string(config.tuning.as_deref().unwrap_or(""))?,
-        )?;
+        let tuning = pbs_config::datastore::parse_datastore_tuning_options(&config)?;
         let chunk_store = ChunkStore::open(
             &name,
             config.absolute_path(),
@@ -735,11 +729,7 @@ impl DataStore {
             GarbageCollectionStatus::default()
         };
 
-        let tuning: DatastoreTuning = serde_json::from_value(
-            DatastoreTuning::API_SCHEMA
-                .parse_property_string(config.tuning.as_deref().unwrap_or(""))?,
-        )?;
-
+        let tuning = pbs_config::datastore::parse_datastore_tuning_options(&config)?;
         let backend_config = pbs_config::datastore::parse_backend_config(&config)?;
 
         let (lru_store_caching, request_counters) =
@@ -2393,10 +2383,7 @@ impl DataStore {
             cache_stats: Some(GarbageCollectionCacheStats::default()),
             ..Default::default()
         };
-        let tuning: DatastoreTuning = serde_json::from_value(
-            DatastoreTuning::API_SCHEMA
-                .parse_property_string(gc_store_config.tuning.as_deref().unwrap_or(""))?,
-        )?;
+        let tuning = pbs_config::datastore::parse_datastore_tuning_options(&gc_store_config)?;
 
         let s3_client = match self.backend()? {
             DatastoreBackend::Filesystem => None,
diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs
index 16e85a636..99c7d8e47 100644
--- a/src/api2/config/datastore.rs
+++ b/src/api2/config/datastore.rs
@@ -14,9 +14,9 @@ use proxmox_uuid::Uuid;
 
 use pbs_api_types::{
     Authid, DataStoreConfig, DataStoreConfigUpdater, DatastoreBackendType, DatastoreNotify,
-    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,
+    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;
@@ -121,11 +121,7 @@ pub(crate) fn do_create_datastore(
         param_bail!("path", err);
     }
 
-    let tuning: DatastoreTuning = serde_json::from_value(
-        DatastoreTuning::API_SCHEMA
-            .parse_property_string(datastore.tuning.as_deref().unwrap_or(""))?,
-    )?;
-
+    let tuning = pbs_config::datastore::parse_datastore_tuning_options(&datastore)?;
     let (backend_type, backend_s3_client) =
         match DataStore::s3_client_and_backend_from_datastore_config(&datastore)? {
             (backend_type, Some(s3_client)) => {
-- 
2.47.3





  parent reply	other threads:[~2026-05-12 13:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 13:10 [PATCH proxmox{,-backup} v3 0/7] fix sync level updates for chunk store Christian Ebner
2026-05-12 13:10 ` [PATCH proxmox v3 1/7] pbs-api-types: derive FromStr for DatastoreTuning parsing Christian Ebner
2026-05-12 13:10 ` [PATCH proxmox-backup v3 2/7] datastore: GC: avoid double parsing of datastore tuning options Christian Ebner
2026-05-12 13:10 ` Christian Ebner [this message]
2026-05-12 13:10 ` [PATCH proxmox-backup v3 4/7] datastore: restrict chunk store mutex scope to crate only Christian Ebner
2026-05-12 13:10 ` [PATCH proxmox-backup v3 5/7] datastore: avoid useless double borrowing of datastore Christian Ebner
2026-05-12 13:10 ` [PATCH proxmox-backup v3 6/7] datastore: move try_ensure_sync_level() implementation to chunk store Christian Ebner
2026-05-12 13:10 ` [PATCH proxmox-backup v3 7/7] datastore: fix sync level update propagation " 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=20260512131047.689089-4-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