[pbs-devel] [PATCH proxmox-backup 1/4] tape: add optional timeout to wait_until_ready

Dominik Csapak d.csapak at proxmox.com
Tue Dec 12 12:32:45 CET 2023


instead of hardcodign the default timeout as only option. This will come
in handy when we need to wait for LTO9+ initialization that can take up
to two hours.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 pbs-tape/src/sg_tape.rs   | 5 +++--
 src/tape/drive/lto/mod.rs | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/pbs-tape/src/sg_tape.rs b/pbs-tape/src/sg_tape.rs
index b28a5f27..16ef31f9 100644
--- a/pbs-tape/src/sg_tape.rs
+++ b/pbs-tape/src/sg_tape.rs
@@ -571,9 +571,10 @@ impl SgTape {
         }
     }
 
-    pub fn wait_until_ready(&mut self) -> Result<(), Error> {
+    pub fn wait_until_ready(&mut self, timeout: Option<u64>) -> Result<(), Error> {
         let start = SystemTime::now();
-        let max_wait = std::time::Duration::new(Self::SCSI_TAPE_DEFAULT_TIMEOUT as u64, 0);
+        let timeout = timeout.unwrap_or(Self::SCSI_TAPE_DEFAULT_TIMEOUT as u64);
+        let max_wait = std::time::Duration::new(timeout, 0);
 
         loop {
             match self.test_unit_ready() {
diff --git a/src/tape/drive/lto/mod.rs b/src/tape/drive/lto/mod.rs
index 2c3a5a63..97dd540f 100644
--- a/src/tape/drive/lto/mod.rs
+++ b/src/tape/drive/lto/mod.rs
@@ -55,7 +55,7 @@ pub fn open_lto_tape_drive(config: &LtoTapeDrive) -> Result<LtoTapeHandle, Error
             }
         }
 
-        handle.sg_tape.wait_until_ready()?;
+        handle.sg_tape.wait_until_ready(None)?;
 
         handle.set_default_options()?;
 
-- 
2.39.2




More information about the pbs-devel mailing list