]> git.proxmox.com Git - proxmox-backup.git/commitdiff
datastore: improve sync level code a bit
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 28 Oct 2022 07:34:47 +0000 (09:34 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 28 Oct 2022 11:04:22 +0000 (13:04 +0200)
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 <d.csapak@proxmox.com>
pbs-api-types/src/datastore.rs
pbs-datastore/src/chunk_store.rs

index 865a7b5526a2ab9d6bdeea41a64491511ab922af..4c9eda2f57f5ff9a5f9f78e7beaefa926aa15917 100644 (file)
@@ -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": {
index a8582485ffca196f0e51ed3182a33f3e856881dc..758803313f93aa5fd4993e824290d822eff76d48 100644 (file)
@@ -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,