From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup v4 06/14] datastore: restrict chunk store scope to pbs-datastore crate
Date: Mon, 3 Aug 2026 11:07:39 +0200 [thread overview]
Message-ID: <20260803090747.265683-7-c.ebner@proxmox.com> (raw)
In-Reply-To: <20260803090747.265683-1-c.ebner@proxmox.com>
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 <c.ebner@proxmox.com>
---
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 6d2ffdbde..dd564c078 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::<u8>::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 ecee8b4e3..579fd8c3e 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
next prev parent reply other threads:[~2026-08-03 9:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 9:07 [PATCH proxmox{,-backup} v4 00/14] keep datastore config unlocked during long running operations Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox v4 01/14] pbs-api-types: add datastore create maintenance-mode type Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox-backup v4 02/14] api: config: early perform user access checks for datastore creation Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox-backup v4 03/14] api: config: unlocked s3 bucket access check " Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox-backup v4 04/14] api: config: rearrange independent code block " Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox-backup v4 05/14] api/datastore: refactor datastore creation helper logic Christian Ebner
2026-08-03 9:07 ` Christian Ebner [this message]
2026-08-03 9:07 ` [PATCH proxmox-backup v4 07/14] datastore: move lock files base path constant to central location Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox-backup v4 08/14] datastore: move file lock helper to centralized place Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox-backup v4 09/14] datastore: add additional check for device number on lock helper Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox-backup v4 10/14] datastore: create lockdir with correct mode for backup user access Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox-backup v4 11/14] api/datastore: use maintenance-mode lock to protect against changes Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox-backup v4 12/14] pbs-config: add helper to check new datastore config sections Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox-backup v4 13/14] api: datastore: move prune job and s3 backend logic to create helper Christian Ebner
2026-08-03 9:07 ` [PATCH proxmox-backup v4 14/14] datastore: protect datastore creation by maintenance-mode 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=20260803090747.265683-7-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.