From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 09ED71FF138 for ; Tue, 21 Jul 2026 12:33:24 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 3481321523; Tue, 21 Jul 2026 12:33:18 +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: Tue, 21 Jul 2026 12:32:53 +0200 Message-ID: <20260721103259.329643-5-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260721103259.329643-1-c.ebner@proxmox.com> References: <20260721103259.329643-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: 1784629970752 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.278 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_LOW -0.7 Sender listed at https://www.dnswl.org/, low trust 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: UZ73CRIGUUACKLBKCSRAITFJMS4EDPR2 X-Message-ID-Hash: UZ73CRIGUUACKLBKCSRAITFJMS4EDPR2 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 a936f5034..d3faf1214 100644 --- a/pbs-datastore/src/chunk_store.rs +++ b/pbs-datastore/src/chunk_store.rs @@ -45,23 +45,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 d9d7a4cb6..f522fadf7 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 1bde8ee5a..91aaaedc0 100644 --- a/pbs-datastore/src/local_datastore_lru_cache.rs +++ b/pbs-datastore/src/local_datastore_lru_cache.rs @@ -9,8 +9,8 @@ use http_body_util::BodyExt; use pbs_tools::async_lru_cache::AsyncLruCache; use proxmox_s3_client::S3Client; -use crate::ChunkStore; use crate::DataBlob; +use crate::chunk_store::ChunkStore; /// 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 5c52b7917..30ee28c1a 100644 --- a/proxmox-backup-client/src/main.rs +++ b/proxmox-backup-client/src/main.rs @@ -54,7 +54,6 @@ use pbs_client::{ parse_backup_specification, view_task_result, }; 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; @@ -88,6 +87,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, @@ -816,7 +825,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