[pbs-devel] [PATCH] tape restore: fix datastore locking

Dietmar Maurer dietmar at proxmox.com
Fri Apr 16 09:11:35 CEST 2021


---
 src/api2/tape/restore.rs | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs
index 33176bd7..6e1c81f6 100644
--- a/src/api2/tape/restore.rs
+++ b/src/api2/tape/restore.rs
@@ -320,6 +320,15 @@ pub fn restore(
                     .join(";")
             );
 
+            let mut datastore_locks = Vec::new();
+            for store_name in store_map.used_datastores() {
+                // explicit create shared lock to prevent GC on newly created chunks
+                if let Some(store) = store_map.get_datastore(store_name) {
+                    let shared_store_lock = store.try_shared_chunk_store_lock()?;
+                    datastore_locks.push(shared_store_lock);
+                }
+            }
+
             for media_id in media_id_list.iter() {
                 request_and_restore_media(
                     &worker,
@@ -333,6 +342,8 @@ pub fn restore(
                 )?;
             }
 
+            drop(datastore_locks);
+
             task_log!(worker, "Restore mediaset '{}' done", media_set);
 
             if let Err(err) = set_tape_device_state(&drive, "") {
-- 
2.20.1





More information about the pbs-devel mailing list