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 0FDE21FF13B for ; Wed, 06 May 2026 18:57:22 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 974DADC5; Wed, 6 May 2026 18:57:20 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup v2 04/10] datastore: restrict chunk store scope to pbs-datastore crate Date: Wed, 6 May 2026 18:56:45 +0200 Message-ID: <20260506165651.1322947-5-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260506165651.1322947-1-c.ebner@proxmox.com> References: <20260506165651.1322947-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: 1778086519273 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: 5FEG5WUVPC77FXK42LLTKCQ2V7WOBFKX X-Message-ID-Hash: 5FEG5WUVPC77FXK42LLTKCQ2V7WOBFKX 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: Implementation details of the chunk store should not be used outside of the pbs-datastore crate. After refactoring datastore creation to be contained within the crate boundary in previous code changes, the only remaining outside dependency is the list and check for allowed chunk sizes, which is however only used by the proxmox-backup-client. Therefore, move the list to the client, inline the check and limit the chunk store scope to be crate only. Signed-off-by: Christian Ebner --- pbs-datastore/src/chunk_store.rs | 17 ----------------- pbs-datastore/src/lib.rs | 3 +-- pbs-datastore/src/local_datastore_lru_cache.rs | 2 +- proxmox-backup-client/src/main.rs | 15 +++++++++++++-- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs index 68db88eab..735744506 100644 --- a/pbs-datastore/src/chunk_store.rs +++ b/pbs-datastore/src/chunk_store.rs @@ -39,23 +39,6 @@ pub struct ChunkStore { // TODO: what about sysctl setting vm.vfs_cache_pressure (0 - 100) ? -pub fn verify_chunk_size(size: usize) -> Result<(), Error> { - static SIZES: [usize; 7] = [ - 64 * 1024, - 128 * 1024, - 256 * 1024, - 512 * 1024, - 1024 * 1024, - 2048 * 1024, - 4096 * 1024, - ]; - - if !SIZES.contains(&size) { - bail!("Got unsupported chunk size '{size}'"); - } - Ok(()) -} - fn digest_to_prefix(digest: &[u8]) -> PathBuf { let mut buf = Vec::::with_capacity(2 + 1 + 2 + 1); diff --git a/pbs-datastore/src/lib.rs b/pbs-datastore/src/lib.rs index 6647ee2b6..34d9a6339 100644 --- a/pbs-datastore/src/lib.rs +++ b/pbs-datastore/src/lib.rs @@ -183,7 +183,7 @@ pub mod catalog; pub mod checksum_reader; pub mod checksum_writer; pub mod chunk_stat; -pub mod chunk_store; +pub(crate) mod chunk_store; pub mod chunker; pub mod crypt_reader; pub mod crypt_writer; @@ -206,7 +206,6 @@ pub mod fixed_index; pub use backup_info::{BackupDir, BackupGroup, BackupInfo}; pub use checksum_reader::ChecksumReader; pub use checksum_writer::ChecksumWriter; -pub use chunk_store::ChunkStore; pub use chunker::{Chunker, ChunkerImpl, PayloadChunker}; pub use crypt_reader::CryptReader; pub use crypt_writer::CryptWriter; diff --git a/pbs-datastore/src/local_datastore_lru_cache.rs b/pbs-datastore/src/local_datastore_lru_cache.rs index ac27d4637..b4853a3d8 100644 --- a/pbs-datastore/src/local_datastore_lru_cache.rs +++ b/pbs-datastore/src/local_datastore_lru_cache.rs @@ -9,7 +9,7 @@ use http_body_util::BodyExt; use pbs_tools::async_lru_cache::AsyncLruCache; use proxmox_s3_client::S3Client; -use crate::ChunkStore; +use crate::chunk_store::ChunkStore; use crate::DataBlob; /// LRU cache using local datastore for caching chunks diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs index 5e8bb5393..c2943dbcd 100644 --- a/proxmox-backup-client/src/main.rs +++ b/proxmox-backup-client/src/main.rs @@ -51,7 +51,6 @@ use pbs_client::{ BACKUP_SOURCE_SCHEMA, }; use pbs_datastore::catalog::{BackupCatalogWriter, CatalogReader, CatalogWriter}; -use pbs_datastore::chunk_store::verify_chunk_size; use pbs_datastore::dynamic_index::{BufferedDynamicReader, DynamicIndexReader, LocalDynamicReadAt}; use pbs_datastore::fixed_index::FixedIndexReader; use pbs_datastore::index::IndexFile; @@ -85,6 +84,16 @@ pub use snapshot::*; mod task; pub use task::*; +static ALLOWED_CHUNK_SIZES: [usize; 7] = [ + 64 * 1024, + 128 * 1024, + 256 * 1024, + 512 * 1024, + 1024 * 1024, + 2048 * 1024, + 4096 * 1024, +]; + fn record_repository(repo: &BackupRepository) { let base = match BaseDirectories::with_prefix("proxmox-backup") { Ok(v) => v, @@ -813,7 +822,9 @@ async fn create_backup( let chunk_size_opt = param["chunk-size"].as_u64().map(|v| (v * 1024) as usize); if let Some(size) = chunk_size_opt { - verify_chunk_size(size)?; + if !ALLOWED_CHUNK_SIZES.contains(&size) { + bail!("Got unsupported chunk size '{size}'"); + } } let rate_limit = RateLimitConfig::from_client_config(limit); -- 2.47.3