[pbs-devel] [PATCH proxmox-backup 3/4] tape: drive status: make some depend on the activity

Dominik Csapak d.csapak at proxmox.com
Mon May 13 12:49:25 CEST 2024


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 at proxmox.com>
---
 pbs-tape/src/sg_tape.rs | 48 +++++++++++++++++++++++++----------------
 www/tape/DriveStatus.js |  2 +-
 2 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/pbs-tape/src/sg_tape.rs b/pbs-tape/src/sg_tape.rs
index d185dd1ac..5cda91943 100644
--- a/pbs-tape/src/sg_tape.rs
+++ b/pbs-tape/src/sg_tape.rs
@@ -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);
+                    }
                 }
             }
         }
diff --git a/www/tape/DriveStatus.js b/www/tape/DriveStatus.js
index a392202ca..007273f67 100644
--- a/www/tape/DriveStatus.js
+++ b/www/tape/DriveStatus.js
@@ -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)');
-- 
2.39.2





More information about the pbs-devel mailing list