tape: add optional timeout to wait_until_ready

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>
This commit is contained in:
Dominik Csapak 2023-12-12 12:32:45 +01:00 committed by Dietmar Maurer
parent cbb478fa19
commit ee6c5560a8
2 changed files with 4 additions and 3 deletions

View File

@ -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() {

View File

@ -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()?;