From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 41175C397 for ; Mon, 28 Nov 2022 14:26:44 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 28AC334214 for ; Mon, 28 Nov 2022 14:26:44 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 28 Nov 2022 14:26:42 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 5A2FA44C45 for ; Mon, 28 Nov 2022 14:26:42 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Mon, 28 Nov 2022 14:26:40 +0100 Message-Id: <20221128132641.3458244-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221128132641.3458244-1-d.csapak@proxmox.com> References: <20221128132641.3458244-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.064 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 Subject: [pbs-devel] [PATCH proxmox-backup 2/3] use derive 'Default' for ChunkOrder X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2022 13:26:44 -0000 instead of hardcoding the default deep inside the code. This makes it much easier to see what is the actual default the first instance of ChunkOrder::None was only for the test case, were the ordering doe not matter Signed-off-by: Dominik Csapak --- pbs-api-types/src/datastore.rs | 3 ++- pbs-datastore/src/datastore.rs | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index dde385c3..d75ead90 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -158,13 +158,14 @@ pub const PRUNE_SCHEMA_KEEP_YEARLY: Schema = .schema(); #[api] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, 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 + #[default] Inode, } diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index da7bdf87..73e6a3a9 100644 --- a/pbs-datastore/src/datastore.rs +++ b/pbs-datastore/src/datastore.rs @@ -71,7 +71,7 @@ impl DataStoreImpl { gc_mutex: Mutex::new(()), last_gc_status: Mutex::new(GarbageCollectionStatus::default()), verify_new: false, - chunk_order: ChunkOrder::None, + chunk_order: Default::default(), last_digest: None, sync_level: Default::default(), }) @@ -260,14 +260,13 @@ impl DataStore { DatastoreTuning::API_SCHEMA .parse_property_string(config.tuning.as_deref().unwrap_or(""))?, )?; - let chunk_order = tuning.chunk_order.unwrap_or(ChunkOrder::Inode); Ok(DataStoreImpl { chunk_store, gc_mutex: Mutex::new(()), last_gc_status: Mutex::new(gc_status), verify_new: config.verify_new.unwrap_or(false), - chunk_order, + chunk_order: tuning.chunk_order.unwrap_or_default(), last_digest, sync_level: tuning.sync_level.unwrap_or_default(), }) -- 2.30.2