From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 32AD81FF38E for ; Mon, 13 May 2024 12:49:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F156D139DE; Mon, 13 May 2024 12:49:31 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Mon, 13 May 2024 12:49:25 +0200 Message-Id: <20240513104926.3113394-4-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240513104926.3113394-1-d.csapak@proxmox.com> References: <20240513104926.3113394-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 3/4] tape: drive status: make some depend on the activity X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" 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 --- 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