From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id A4C6575861 for ; Tue, 13 Jul 2021 10:52:00 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 952E11E76E for ; Tue, 13 Jul 2021 10:52:00 +0200 (CEST) Received: from elsa.proxmox.com (unknown [94.136.29.99]) by firstgate.proxmox.com (Proxmox) with ESMTP id 982C91E765 for ; Tue, 13 Jul 2021 10:51:59 +0200 (CEST) Received: by elsa.proxmox.com (Postfix, from userid 0) id 80A75AE2B6C; Tue, 13 Jul 2021 10:51:59 +0200 (CEST) From: Dietmar Maurer To: pbs-devel@lists.proxmox.com Date: Tue, 13 Jul 2021 10:51:57 +0200 Message-Id: <20210713085157.681891-1-dietmar@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.532 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS 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] tape: changer: sg_pt: always retry until timeout 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: , X-List-Received-Date: Tue, 13 Jul 2021 08:52:00 -0000 --- This replaces the patch from Dominik: [PATCH proxmox-backup 1/2] tape: changer: sg_pt: do not retry on unknown errors Opposed to that, we now allways retry (after sleep) and log errors until we run into the timout. src/tape/changer/sg_pt_changer.rs | 63 ++++++++++++------------------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/src/tape/changer/sg_pt_changer.rs b/src/tape/changer/sg_pt_changer.rs index b34219c1..66da140d 100644 --- a/src/tape/changer/sg_pt_changer.rs +++ b/src/tape/changer/sg_pt_changer.rs @@ -23,9 +23,6 @@ use crate::{ }, tools::sgutils2::{ SgRaw, - SENSE_KEY_NO_SENSE, - SENSE_KEY_RECOVERED_ERROR, - SENSE_KEY_UNIT_ATTENTION, SENSE_KEY_NOT_READY, InquiryInfo, ScsiError, @@ -77,11 +74,10 @@ struct AddressAssignmentPage { } /// Execute scsi commands, optionally repeat the command until -/// successful (sleep 1 second between invovations) +/// successful or timeout (sleep 1 second between invovations) /// -/// Any Sense key other than NO_SENSE, RECOVERED_ERROR, NOT_READY and -/// UNIT_ATTENTION aborts the loop and returns an error. If the device -/// reports "Not Ready - becoming ready", we wait up to 5 minutes. +/// Timeout is 5 seconds. If the device reports "Not Ready - becoming +/// ready", we wait up to 5 minutes. /// /// Skipped errors are printed on stderr. fn execute_scsi_command( @@ -100,42 +96,33 @@ fn execute_scsi_command( loop { match sg_raw.do_command(&cmd) { Ok(data) => return Ok(data.to_vec()), + Err(err) if !retry => bail!("{} failed: {}", error_prefix, err), Err(err) => { - if !retry { - bail!("{} failed: {}", error_prefix, err); + let msg = err.to_string(); + if let Some(ref last) = last_msg { + if &msg != last { + eprintln!("{}", err); + last_msg = Some(msg); + } + } else { + eprintln!("{}", err); + last_msg = Some(msg); } - if let ScsiError::Sense(ref sense) = err { - - if sense.sense_key == SENSE_KEY_NO_SENSE || - sense.sense_key == SENSE_KEY_RECOVERED_ERROR || - sense.sense_key == SENSE_KEY_UNIT_ATTENTION || - sense.sense_key == SENSE_KEY_NOT_READY - { - let msg = err.to_string(); - if let Some(ref last) = last_msg { - if &msg != last { - eprintln!("{}", err); - last_msg = Some(msg); - } - } else { - eprintln!("{}", err); - last_msg = Some(msg); - } - - // Not Ready - becoming ready - if sense.sense_key == SENSE_KEY_NOT_READY && sense.asc == 0x04 && sense.ascq == 1 { - // wait up to 5 minutes, long enough to finish inventorize - timeout = std::time::Duration::new(5*60, 0); - } - - if start.elapsed()? > timeout { - bail!("{} failed: {}", error_prefix, err); - } - std::thread::sleep(std::time::Duration::new(1, 0)); - continue; // try again + if let ScsiError::Sense(ref sense) = err { + // Not Ready - becoming ready + if sense.sense_key == SENSE_KEY_NOT_READY && sense.asc == 0x04 && sense.ascq == 1 { + // wait up to 5 minutes, long enough to finish inventorize + timeout = std::time::Duration::new(5*60, 0); } } + + if start.elapsed()? > timeout { + bail!("{} failed: {}", error_prefix, err); + } + + std::thread::sleep(std::time::Duration::new(1, 0)); + continue; // try again } } } -- 2.30.2