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 29E351FF146 for ; Tue, 12 May 2026 15:11:38 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F268513907; Tue, 12 May 2026 15:11:37 +0200 (CEST) From: Christian Ebner 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 Message-ID: <20260512131047.689089-4-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260512131047.689089-1-c.ebner@proxmox.com> References: <20260512131047.689089-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: 1778591344806 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.069 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [datastore.rs] Message-ID-Hash: RA2MY4SWP2VGC5SEC53CXBTKOG2ZOG6A X-Message-ID-Hash: RA2MY4SWP2VGC5SEC53CXBTKOG2ZOG6A 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: 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 --- 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 Result { + 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 { 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