public inbox for pbs-devel@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 1/4] tape: add optional timeout to wait_until_ready
Date: Tue, 12 Dec 2023 12:32:45 +0100	[thread overview]
Message-ID: <20231212113248.159105-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20231212113248.159105-1-d.csapak@proxmox.com>

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@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




  reply	other threads:[~2023-12-12 11:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12 11:32 [pbs-devel] [PATCH proxmox-backup 0/4] better handle lto9 format Dominik Csapak
2023-12-12 11:32 ` Dominik Csapak [this message]
2023-12-12 11:32 ` [pbs-devel] [PATCH proxmox-backup 2/4] tape: derive PartialEq and PartialOrd for TapeDensity Dominik Csapak
2023-12-12 11:32 ` [pbs-devel] [PATCH proxmox-backup 3/4] tape: adapt format_media for LTO9+ Dominik Csapak
2023-12-12 11:32 ` [pbs-devel] [PATCH proxmox-backup 4/4] api: tape: add lto9 initialization message to task log Dominik Csapak
2023-12-12 12:37 ` [pbs-devel] applied: [PATCH proxmox-backup 0/4] better handle lto9 format Dietmar Maurer

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=20231212113248.159105-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal