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 1B09464335 for ; Fri, 30 Oct 2020 04:57:29 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0A025D444 for ; Fri, 30 Oct 2020 04:57:29 +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 390E3D43B for ; Fri, 30 Oct 2020 04:57:28 +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 0909D4254C; Fri, 30 Oct 2020 04:57:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=binary-kitchen.de; s=mail-20190723; t=1604030248; 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=PZjvFX7U4ycwAlYXzWtJoiEXJPRmNOn8LW2NZmFnQnxZ2Mk3P7O3c3XaDsLOWMTt6gaJtg VPPOkcC+J6Fb56jBhKF8VOhw8D8xpJCuJCldjG6AaqxwHSjmONx9NcwBdWQAkiLYpyeOXq aITQtqt5WdwBbamKEVBDh8S2JNinMKAAjAbzJRYjExp+pzs3LQRuBiNvARzDiSTp1wWkAN v0CfGyGxyd5NCbWXYB9FDDx9PvhrL94eUCtce4nxUAyyI13uB+rhpPxkSlxIIX9O+yCCOc R4CfEPixE1kmUAY8yOW8gXn9jBLDc6qBknP00ApEpNjXePuR93i4JFZrwdHKEPt9cin7G1 c/MRdm+g1gyiI3mGFz6R7zjbETzd3eCskH5SSjk4+YJRK+VzaClZQA3gYcvyy7ONV3RCXQ cVTXePz9EDUg8jfDpLSKN+JEIYIxKRQwYDQTkcrEd288iTiQkcel48a8DQxX6ik5sqMDGU SegNxVtI9rlgXaHqy8g/3EyIxtvPl1Jv5+PXh+XMgSRLbWIrIRP90wk1b3ZaCqRHKoBn0h l3Q3Oeugh2DDFX7pP/oiW+CJx6kmxj8VA+phTgPTGH3Je7qKOtHaH7kEN1M2KtZmiHpCiG KFEy6C4bSseLnUeG/0HTs3WrYYw+smYkS52XXgYBtHL7LrzNVQNwY= From: =?UTF-8?q?Jan-Jonas=20S=C3=A4mann?= To: pve-devel@lists.proxmox.com Date: Fri, 30 Oct 2020 04:57:22 +0100 Message-Id: <20201030035722.28150-3-sprinterfreak@binary-kitchen.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201030035722.28150-1-sprinterfreak@binary-kitchen.de> References: <20201030033149.19828-2-sprinterfreak@binary-kitchen.de> <20201030035722.28150-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.183 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 storage v4 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:57:29 -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