tape: automatically reload tapes inside autoloader
We always automatically unload tapes to free library slots, so it should not happen that an ejected tape resides inside the drive. This is just a safe guard to handle the situation in case it happens ... You can manually produce the situation by ejecting a tape without unloading: mt -f /dev/nst0 eject Note: Our "proxmox-tape eject" does automatic unload
This commit is contained in:
parent
5654d8ceba
commit
a484c9cf96
@ -67,13 +67,22 @@ impl LinuxTapeDrive {
|
||||
/// - check if it is a non-rewinding tape device
|
||||
/// - check if drive is ready (tape loaded)
|
||||
/// - check block size
|
||||
/// - for autoloader only, try to reload ejected tapes
|
||||
pub fn open(&self) -> Result<LinuxTapeHandle, Error> {
|
||||
|
||||
let file = open_linux_tape_device(&self.path)?;
|
||||
|
||||
let mut handle = LinuxTapeHandle::new(file);
|
||||
|
||||
let drive_status = handle.get_drive_status()?;
|
||||
let mut drive_status = handle.get_drive_status()?;
|
||||
|
||||
if !drive_status.tape_is_ready() {
|
||||
// for autoloader only, try to reload ejected tapes
|
||||
if self.changer.is_some() {
|
||||
let _ = handle.mtload(); // just try, ignore error
|
||||
drive_status = handle.get_drive_status()?;
|
||||
}
|
||||
}
|
||||
|
||||
if !drive_status.tape_is_ready() {
|
||||
bail!("tape not ready (no tape loaded)");
|
||||
@ -158,6 +167,17 @@ impl LinuxTapeHandle {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mtload(&mut self) -> Result<(), Error> {
|
||||
|
||||
let cmd = mtop { mt_op: MTCmd::MTLOAD, mt_count: 1, };
|
||||
|
||||
unsafe {
|
||||
mtioctop(self.file.as_raw_fd(), &cmd)
|
||||
}.map_err(|err| format_err!("MTLOAD failed - {}", err))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn forward_space_count_files(&mut self, count: i32) -> Result<(), Error> {
|
||||
|
||||
let cmd = mtop { mt_op: MTCmd::MTFSF, mt_count: count, };
|
||||
|
Loading…
Reference in New Issue
Block a user