tape: drive status: make some depend on the activity

when the tape drive has an activity (and the tape is in motion), certain
calls block until the operation is finished. Since we cannot predict how
long it's going to be and it can be quite long in certain cases,
skip those calls when the drive is doing anything.

If we cannot determine the activity, try to do the queries.

We have to extend the check for a loaded drive in the UI, since the
position is not available during any activity.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2024-05-13 12:49:25 +02:00 committed by Dietmar Maurer
parent 1d6b1e0258
commit 4ebb08a5f0
2 changed files with 31 additions and 19 deletions

View File

@ -962,10 +962,18 @@ impl SgTape {
let drive_status = self.read_drive_status()?;
let drive_activity = read_device_activity(&mut self.file).ok();
let alert_flags = self
.tape_alert_flags()
.map(|flags| format!("{:?}", flags))
.ok();
// some operations block when the tape moves, which can take up to 2 hours
// (e.g. for calibrating) so skip those queries while it's doing that
let is_moving = !matches!(drive_activity, None | Some(DeviceActivity::NoActivity));
let alert_flags = if !is_moving {
self.tape_alert_flags()
.map(|flags| format!("{:?}", flags))
.ok()
} else {
None
};
let mut status = LtoDriveAndMediaStatus {
vendor: self.info().vendor.clone(),
@ -993,10 +1001,12 @@ impl SgTape {
status.write_protect = Some(drive_status.write_protect);
}
let position = self.position()?;
if !is_moving {
let position = self.position()?;
status.file_number = Some(position.logical_file_id);
status.block_number = Some(position.logical_object_number);
status.file_number = Some(position.logical_file_id);
status.block_number = Some(position.logical_object_number);
}
if let Ok(mam) = self.cartridge_memory() {
match mam_extract_media_usage(&mam) {
@ -1010,20 +1020,22 @@ impl SgTape {
}
}
if let Ok(volume_stats) = self.volume_statistics() {
let passes = std::cmp::max(
volume_stats.beginning_of_medium_passes,
volume_stats.middle_of_tape_passes,
);
if !is_moving {
if let Ok(volume_stats) = self.volume_statistics() {
let passes = std::cmp::max(
volume_stats.beginning_of_medium_passes,
volume_stats.middle_of_tape_passes,
);
// assume max. 16000 medium passes
// see: https://en.wikipedia.org/wiki/Linear_Tape-Open
let wearout: f64 = (passes as f64) / 16000.0_f64;
// assume max. 16000 medium passes
// see: https://en.wikipedia.org/wiki/Linear_Tape-Open
let wearout: f64 = (passes as f64) / 16000.0_f64;
status.medium_passes = Some(passes);
status.medium_wearout = Some(wearout);
status.medium_passes = Some(passes);
status.medium_wearout = Some(wearout);
status.volume_mounts = Some(volume_stats.volume_mounts);
status.volume_mounts = Some(volume_stats.volume_mounts);
}
}
}
}

View File

@ -45,7 +45,7 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
onLoad: function() {
let me = this;
let statusgrid = me.lookup('statusgrid');
let online = statusgrid.getObjectValue('file-number') !== undefined;
let online = statusgrid.getObjectValue('file-number') !== undefined || statusgrid.getObjectValue('manufactured');
let vm = me.getViewModel();
vm.set('online', online);
let title = online ? gettext('Status') : gettext('Status (No Tape loaded)');