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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 1EC358BE85 for ; Fri, 28 Oct 2022 09:35:27 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 036A07969 for ; Fri, 28 Oct 2022 09:34:57 +0200 (CEST) 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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 28 Oct 2022 09:34:55 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id D754344C54 for ; Fri, 28 Oct 2022 09:34:49 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Fri, 28 Oct 2022 09:34:47 +0200 Message-Id: <20221028073449.1120342-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221028073449.1120342-1-d.csapak@proxmox.com> References: <20221028073449.1120342-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.067 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 v4 1/3] datastore: improve sync level code a bit 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: Fri, 28 Oct 2022 07:35:27 -0000 fixups for DatastoreFSyncLevel: * use derive for Default * add some more derives (Clone, Copy) chunk store: * drop to_owned for chunk_dir_path Signed-off-by: Dominik Csapak --- pbs-api-types/src/datastore.rs | 9 ++------- pbs-datastore/src/chunk_store.rs | 5 ++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 865a7b55..4c9eda2f 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -169,7 +169,7 @@ pub enum ChunkOrder { } #[api] -#[derive(PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] /// The level of syncing that is done when writing into a datastore. pub enum DatastoreFSyncLevel { @@ -181,6 +181,7 @@ pub enum DatastoreFSyncLevel { /// which reduces IO pressure. /// But it may cause losing data on powerloss or system crash without any uninterruptible power /// supply. + #[default] None, /// Triggers a fsync after writing any chunk on the datastore. While this can slow down /// backups significantly, depending on the underlying file system and storage used, it @@ -198,12 +199,6 @@ pub enum DatastoreFSyncLevel { Filesystem, } -impl Default for DatastoreFSyncLevel { - fn default() -> Self { - DatastoreFSyncLevel::None - } -} - #[api( properties: { "chunk-order": { diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs index a8582485..75880331 100644 --- a/pbs-datastore/src/chunk_store.rs +++ b/pbs-datastore/src/chunk_store.rs @@ -470,11 +470,10 @@ impl ChunkStore { let chunk_dir_path = chunk_path .parent() - .ok_or_else(|| format_err!("unable to get chunk dir"))? - .to_owned(); + .ok_or_else(|| format_err!("unable to get chunk dir"))?; proxmox_sys::fs::replace_file( - chunk_path, + &chunk_path, raw_data, CreateOptions::new(), self.sync_level == DatastoreFSyncLevel::File, -- 2.30.2