all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 3/4] backup/chunk_store: optionally log progress on creation
Date: Tue,  1 Jun 2021 14:13:49 +0200	[thread overview]
Message-ID: <20210601121350.19919-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210601121350.19919-1-d.csapak@proxmox.com>

and enable it for the worker variant

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/api2/config/datastore.rs |  6 +++---
 src/backup/chunk_store.rs    | 11 +++++++----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs
index 16ac030f..5c2ad050 100644
--- a/src/api2/config/datastore.rs
+++ b/src/api2/config/datastore.rs
@@ -131,7 +131,7 @@ pub fn create_datastore(param: Value) -> Result<(), Error> {
     let path: PathBuf = datastore.path.clone().into();
 
     let backup_user = crate::backup::backup_user()?;
-    let _store = ChunkStore::create(&datastore.name, path, backup_user.uid, backup_user.gid)?;
+    let _store = ChunkStore::create(&datastore.name, path, backup_user.uid, backup_user.gid, None)?;
 
     config.set_data(&datastore.name, "datastore", &datastore)?;
 
@@ -226,12 +226,12 @@ pub fn create_datastore_worker(
         Some(datastore.name.to_string()),
         auth_id,
         false,
-        move |_worker| {
+        move |worker| {
             let _lock = lock; // keep the lock
             let path: PathBuf = datastore.path.clone().into();
 
             let backup_user = crate::backup::backup_user()?;
-            let _store = ChunkStore::create(&datastore.name, path, backup_user.uid, backup_user.gid)?;
+            let _store = ChunkStore::create(&datastore.name, path, backup_user.uid, backup_user.gid, Some(&worker))?;
 
             config.set_data(&datastore.name, "datastore", &datastore)?;
 
diff --git a/src/backup/chunk_store.rs b/src/backup/chunk_store.rs
index 31e8307c..e9cc3897 100644
--- a/src/backup/chunk_store.rs
+++ b/src/backup/chunk_store.rs
@@ -7,6 +7,7 @@ use std::os::unix::io::AsRawFd;
 
 use proxmox::tools::fs::{CreateOptions, create_path, create_dir};
 
+use crate::task_log;
 use crate::tools;
 use crate::api2::types::GarbageCollectionStatus;
 
@@ -61,7 +62,7 @@ impl ChunkStore {
         chunk_dir
     }
 
-    pub fn create<P>(name: &str, path: P, uid: nix::unistd::Uid, gid: nix::unistd::Gid) -> Result<Self, Error>
+    pub fn create<P>(name: &str, path: P, uid: nix::unistd::Uid, gid: nix::unistd::Gid, worker: Option<&dyn TaskState>) -> Result<Self, Error>
     where
         P: Into<PathBuf>,
     {
@@ -104,7 +105,9 @@ impl ChunkStore {
             }
             let percentage = (i*100)/(64*1024);
             if percentage != last_percentage {
-                // eprintln!("ChunkStore::create {}%", percentage);
+                if let Some(worker) = worker {
+                    task_log!(worker, "Chunkstore create: {}%", percentage)
+                }
                 last_percentage = percentage;
             }
         }
@@ -461,7 +464,7 @@ fn test_chunk_store1() {
     assert!(chunk_store.is_err());
 
     let user = nix::unistd::User::from_uid(nix::unistd::Uid::current()).unwrap().unwrap();
-    let chunk_store = ChunkStore::create("test", &path, user.uid, user.gid).unwrap();
+    let chunk_store = ChunkStore::create("test", &path, user.uid, user.gid, None).unwrap();
 
     let (chunk, digest) = super::DataChunkBuilder::new(&[0u8, 1u8]).build().unwrap();
 
@@ -472,7 +475,7 @@ fn test_chunk_store1() {
     assert!(exists);
 
 
-    let chunk_store = ChunkStore::create("test", &path, user.uid, user.gid);
+    let chunk_store = ChunkStore::create("test", &path, user.uid, user.gid, None);
     assert!(chunk_store.is_err());
 
     if let Err(_e) = std::fs::remove_dir_all(".testdir") { /* ignore */ }
-- 
2.20.1





  parent reply	other threads:[~2021-06-01 12:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01 12:13 [pbs-devel] [PATCH proxmox-backup 0/4] improve datastore removal/creation Dominik Csapak
2021-06-01 12:13 ` [pbs-devel] [PATCH proxmox-backup 1/4] proxmox-backup-proxy: fix leftover references on datastore removal Dominik Csapak
2021-06-01 14:25   ` Thomas Lamprecht
2021-06-01 12:13 ` [pbs-devel] [PATCH proxmox-backup 2/4] api2/confif/datastore: add create datastore api call in a worker Dominik Csapak
2021-06-01 14:33   ` Thomas Lamprecht
2021-06-02  6:34     ` Dietmar Maurer
2021-06-01 12:13 ` Dominik Csapak [this message]
2021-06-01 12:13 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui: DataStoreList: add remove button Dominik Csapak
2021-06-01 14:37   ` Thomas Lamprecht

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=20210601121350.19919-4-d.csapak@proxmox.com \
    --to=d.csapak@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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal