From 842a39af35d7c169df343a36ef9b6a11610b87aa Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 22 Feb 2022 15:57:49 +0100 Subject: [PATCH] datastore: add tuning option for chunk order currently, we sort chunks by inode when verifying or backing up to tape. we get the inode# by stat'ing each chunk, which may be more expensive than the gains of reading the chunks in order Since that is highly dependent on the underlying storage of the datastore, introduce a tuning option so that the admin can tune that behaviour for each datastore. The default stays the same (sorting by inode) Signed-off-by: Dominik Csapak --- pbs-api-types/src/datastore.rs | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 36279b3a..d0215403 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -167,6 +167,38 @@ pub struct PruneOptions { pub keep_yearly: Option, } +#[api] +#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +/// The order to sort chunks by +pub enum ChunkOrder { + /// Iterate chunks in the index order + None, + /// Iterate chunks in inode order + Inode, +} + +#[api( + properties: { + "chunk-order": { + type: ChunkOrder, + optional: true, + }, + }, +)] +#[derive(Serialize, Deserialize, Default)] +#[serde(rename_all = "kebab-case")] +/// Datastore tuning options +pub struct DatastoreTuning { + /// Iterate chunks in this order + pub chunk_order: Option, +} + +pub const DATASTORE_TUNING_STRING_SCHEMA: Schema = StringSchema::new( + "Datastore tuning options") + .format(&ApiStringFormat::PropertyString(&DatastoreTuning::API_SCHEMA)) + .schema(); + #[api( properties: { name: { @@ -224,6 +256,10 @@ pub struct PruneOptions { optional: true, type: bool, }, + tuning: { + optional: true, + schema: DATASTORE_TUNING_STRING_SCHEMA, + }, } )] #[derive(Serialize,Deserialize,Updater)] @@ -261,6 +297,9 @@ pub struct DataStoreConfig { /// Send notification only for job errors #[serde(skip_serializing_if="Option::is_none")] pub notify: Option, + /// Datastore tuning options + #[serde(skip_serializing_if="Option::is_none")] + pub tuning: Option, } #[api(