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 68AAC642D3 for ; Fri, 30 Oct 2020 04:32:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 541ACD1C2 for ; Fri, 30 Oct 2020 04:32:25 +0100 (CET) Received: from lithium.binary-kitchen.net (lithium.binary-kitchen.net [IPv6:2a02:958:0:f6::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 6AD1DD1A9 for ; Fri, 30 Oct 2020 04:32:24 +0100 (CET) Received: from jayjay.reg.saenet.de (p5dc3c0b1.dip0.t-ipconnect.de [93.195.192.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by lithium.binary-kitchen.net (Postfix) with ESMTPSA id 2EEEB42529; Fri, 30 Oct 2020 04:32:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=binary-kitchen.de; s=mail-20190723; t=1604028738; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xRQdwNmk3LD2RKdqSbyEsA6HIgxqLTA0jSRiIq5S8+U=; b=Xh58lIjuAAUZd9D69ThtTy2edCw6qz82IpH2d+OE0vLkNTPK4cF6os4dh9UBojNOXgDxNa YLqjfCiBXQpa9dAs6zTe6t0geuo73/Pa0Szz28N20zjulQXFo7e3WfxgAOI1i3ZmjQtE8n lJJA0UDk0Zw8VmzydPwML7t80fi+6+p8r+LcCqP7W8sAI4xlLsoQrqHtETX+VViRvlPPBl L6SptlQw3EojQe5CWFoKXXJv6SwTOFaTJp23UKizfr2dpj/UfSMrJzYL84XOJJk5BTGSMw sAK2UK5RwchxKM6TUNkFJPY+GyP3GCb/0VIjxdrEzXBjn0Ihmq+7bN0n0I1gbENsqPE+g6 4I/PkVZKWJRedBNCGhTs6cneRbABt2FwVtk3Q1G2+3wBEUKOs4GaxfnLOzS21GovaFPaov jowazQi+YgkK6/FQMGEuz4NnXHLfZ3B8d1ktMhv/4IcvYwFGp5IfbzUX06BYfa4g1WV+1H j0ldKXFrSAYoPgI4f8PWuc9uyWoTDHJTGBYDcKLRPgN2xGUwzvMmImRnmbpT3vvpGG4o+8 AJbK/MkPj3Y9t7UnXMfFcZbGgrtJDsBFG56CyHlr8J7QnOHFBkfjC2aj9uWuiFCjdB9S/M +osnu/dx3fcIjEXXS0JoMysCp4XYJrh2qYCzl62PmF86+xCWG1jfY= From: =?UTF-8?q?Jan-Jonas=20S=C3=A4mann?= To: pve-devel@lists.proxmox.com Date: Fri, 30 Oct 2020 04:31:49 +0100 Message-Id: <20201030033149.19828-3-sprinterfreak@binary-kitchen.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201030033149.19828-1-sprinterfreak@binary-kitchen.de> References: <8f4377de-7b18-461b-4882-26a7e59affa1@proxmox.com> <20201030033149.19828-1-sprinterfreak@binary-kitchen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authentication-Results: ORIGINATING; auth=pass smtp.auth=sprinterfreak smtp.mailfrom=sprinterfreak@binary-kitchen.de X-SPAM-LEVEL: Spam detection results: 0 AWL -0.247 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain GAPPY_SUBJECT 0.1 Subject: contains G.a.p.p.y-T.e.x.t SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [binary-kitchen.de, diskmanage.pm] Subject: [pve-devel] [PATCH storage v3 2/2] Diskmanage: Use S.M.A.R.T. attributes for SSDs wearout lookup X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2020 03:32:25 -0000 This replaces a locally maintained hardware map in get_wear_leveling_info() by commonly used register names of smartmontool. Smartmontool maintains a labeled register database that contains a majority of drives (including versions). The current lookup produces false estimates, this approach hopefully provides more reliable data. Signed-off-by: Jan-Jonas Sämann --- PVE/Diskmanage.pm | 58 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm index 79aafcc..2552add 100644 --- a/PVE/Diskmanage.pm +++ b/PVE/Diskmanage.pm @@ -396,7 +396,7 @@ sub get_sysdir_info { } sub get_wear_leveling_info { - my ($smartdata, $model) = @_; + my ($smartdata) = @_; my $attributes = $smartdata->{attributes}; if (defined($smartdata->{wearout})) { @@ -405,37 +405,35 @@ sub get_wear_leveling_info { my $wearout; - my $vendormap = { - 'kingston' => 231, - 'samsung' => 177, - 'intel' => 233, - 'sandisk' => 233, - 'crucial' => 202, - 'default' => 233, - }; - - # find target attr id - - my $attrid; - - foreach my $vendor (keys %$vendormap) { - if ($model =~ m/$vendor/i) { - $attrid = $vendormap->{$vendor}; - # found the attribute - last; + # Common register names that represent percentage values of potential + # failure indicators used in drivedb.h of smartmontool's. Order matters, + # as some drives may have multiple definitions + my @wearoutregisters = ( + "Media_Wearout_Indicator", + "SSD_Life_Left", + "Wear_Leveling_Count", + "Perc_Write\/Erase_Ct_BC", + "Perc_Rated_Life_Remain", + "Remaining_Lifetime_Perc", + "Percent_Lifetime_Remain", + "Lifetime_Left", + "PCT_Life_Remaining", + "Lifetime_Remaining", + "Percent_Life_Remaining", + "Percent_Lifetime_Used", + "Perc_Rated_Life_Used" + ); + + # Search for S.M.A.R.T. attributes for known register + foreach my $register (@wearoutregisters) { + last if defined $wearout; + foreach my $attr (@$attributes) { + next if $attr->{name} !~ m/$register/; + $wearout = $attr->{value}; + last; } } - if (!$attrid) { - $attrid = $vendormap->{default}; - } - - foreach my $attr (@$attributes) { - next if $attr->{id} != $attrid; - $wearout = $attr->{value}; - last; - } - return $wearout; } @@ -559,7 +557,7 @@ sub get_disks { if (is_ssdlike($type)) { # if we have an ssd we try to get the wearout indicator - my $wearval = get_wear_leveling_info($smartdata, $data->{model} || $sysdata->{model}); + my $wearval = get_wear_leveling_info($smartdata); $wearout = $wearval if defined($wearval); } }; -- 2.25.1