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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 722A7622C2 for ; Sat, 24 Oct 2020 21:27:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6D8A52E3E0 for ; Sat, 24 Oct 2020 21:27:43 +0200 (CEST) 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 2A4A42E393 for ; Sat, 24 Oct 2020 21:27:42 +0200 (CEST) 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 B949B42478; Sat, 24 Oct 2020 21:27:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=binary-kitchen.de; s=mail-20190723; t=1603567655; 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=XcuaFt4zSM5YWcfDsh894BXZgE4i8UUxFacNEezJuRs=; b=iU7gcheHeB02Z9TBGd+0cEAUg7xtv7Cu5pU5ES1Ox4CKATwnjvO1ZRIHGlTlpLbgZp1tR3 Drmyav/IDOzNXRIQupDLA0vQ8gcYUh8y8rGGXPQYNst0raB4i285EeaixhAlL6SsIDI/kE 4sX3EOA/UuEr8j6Nk/aJCQbJOkpcN6sDcxMSfJrsCfiMdtOruWu1FNREozbnPG3Rhu8RQN 8yEKKo5nCi3JXBlKodZij0UModVy29iOmqv7SnIPwlsfJnZaOyegVupXzfTzhWcslvD7L9 lnl5ep7RlPadE4osXVXykmteDRk68JMZNKCbFiUjVx+8bFpTytYGh57xUTHXPIf644ct9D J2zXo/UyfUJ0sNh6YZHKNJkQUvU9UQXqDeE27EOPJnDj2Ut0paTmIEo77MqP7oqR9myukI dkXcn6Ck25Uv9QfxhRSYWvou4nmlvcdx7t1SeU2DX5zCn+9ZGUQ6fWf9wIc9/uVn9n0usA 6Adh2fV2Vl+pWXwQilO6y+FsYrNSZ4xAS7wIXmNMIMQdukMIQRQqd6yRVffElw+lGVSW2l uB1SBliKB4XyFwnNna8PBT/hn2bTciZ3G8B2CaQ5PEEBDXWp5sy+jE1F7kzjnwe+VwbpA5 zP2AhJ02YJJ8eKJ2kSM80KZkPqaIaE6I2Tx9wH/2ZViXZ0NzDlJZA= From: =?UTF-8?q?Jan-Jonas=20S=C3=A4mann?= To: pve-devel@lists.proxmox.com Date: Sat, 24 Oct 2020 21:27:09 +0200 Message-Id: <20201024192709.27324-2-sprinterfreak@binary-kitchen.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201024192709.27324-1-sprinterfreak@binary-kitchen.de> References: <4e2bd780-260b-d757-e108-8ea8bb57c0df@proxmox.com> <20201024192709.27324-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.050 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. [diskmanage.pm, binary-kitchen.de] Subject: [pve-devel] [PATCH v2 storage] 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: Sat, 24 Oct 2020 19:27:43 -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..20dbeeb 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 = ( + "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/; + # Store wearout value, invert value if register matches "Used" + $wearout = ($attr->{name} =~ /Used/) ? 100 - $attr->{value} : $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