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 3/4] tape: drive status: make some depend on the activity
Date: Mon, 13 May 2024 12:49:25 +0200	[thread overview]
Message-ID: <20240513104926.3113394-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20240513104926.3113394-1-d.csapak@proxmox.com>

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



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  parent reply	other threads:[~2024-05-13 10:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13 10:49 [pbs-devel] [PATCH proxmox-backup 0/4] tape: improve UX by showing device activity Dominik Csapak
2024-05-13 10:49 ` [pbs-devel] [PATCH proxmox-backup 1/4] tape: add functions to parse drive " Dominik Csapak
2024-05-13 10:49 ` [pbs-devel] [PATCH proxmox-backup 2/4] tape: add drive activity to drive status api Dominik Csapak
2024-05-13 10:49 ` Dominik Csapak [this message]
2024-05-13 10:49 ` [pbs-devel] [PATCH proxmox-backup 4/4] tape: include drive activity in status Dominik Csapak
2024-05-14  8:32 ` [pbs-devel] applied: [PATCH proxmox-backup 0/4] tape: improve UX by showing device activity 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=20240513104926.3113394-4-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