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 B80C362B10 for ; Tue, 27 Oct 2020 20:07:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3C60019AC7 for ; Tue, 27 Oct 2020 20:06:55 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 8934E19ABA for ; Tue, 27 Oct 2020 20:06:53 +0100 (CET) Received: from [10.88.7.169] (p5dc3c0b1.dip0.t-ipconnect.de [93.195.192.177]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 0D78B424A5; Tue, 27 Oct 2020 20:06:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=binary-kitchen.de; s=mail-20190723; t=1603825607; 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=vq/Z5ffUpy7j51G5wJFdlvCCeQM3navHtUN8qw0VFXM=; b=Gi3Bo6zz9ax+ebYIjGRG/TG/4SIiKguEx1js2MPtkQMgcMWPGMQtx1+3swMepIR1U+wE8Q zuNhAwtdCVwP9G5TFM4QlQ8bcNM/Jz+KFSdA0dmF1z+TaFy5fFwO/DS5XnG3fiZdD/rH25 lMwRnXPr7rhASH6bd/mgdohCw+jdU9vbbYZoTgecGrc4Lfl1xhu0EtwCRHo/7W6VplkD3D LkT4vz0DU0Iz/svSSYJxjl9SwBbhviiSNvsIqJ2xdiywxotBO+YUl1iPdsR5/sY5gNiE+s Dr2bbr4dBpIy+4TF8xqgQPN8YL8jFfzDJ1bbAgg5Fd6BiTNVleFt0lGuK3UDbm5P8J/iW6 AJoUw5a+IqX2oXQqUmV7BrslAsWkRGptCR+oPzzIQNQ0NcJB4fJzy7UH2TXIcWC48oQL3o 6Q5/5Qhc3qZjdMA3OtFjG17hHUGK6EWgnMM6cNYAGECA8LCcz8L3BjxS0M3RjvUpwyunBo aR3JiUwFC1WJvYJP7TsJvTbsoV6crqabZLG+IPiI2bBzwvzslGtxzbP0b6DI6hhRNsER4h PFuHB/7MqR8QlgDZU71t15h9OlLz9lWi2KRjjVGDgD93gyfWq4b2wb/vhXxVsD+ukv716Y z4Sn7RSYf9e8nFWhRy+Gc9He5zmoaleoFSCIKGeaEDlelYS/GAPS8= To: Proxmox VE development discussion References: <4e2bd780-260b-d757-e108-8ea8bb57c0df@proxmox.com> <20201024192709.27324-1-sprinterfreak@binary-kitchen.de> <20201024192709.27324-2-sprinterfreak@binary-kitchen.de> <4b08a126-036b-0ad6-26be-091a147f2162@proxmox.com> From: =?UTF-8?Q?Jan-Jonas_S=c3=a4mann?= Cc: Thomas Lamprecht Message-ID: <6fd0bef8-f8dd-9692-0a36-c9d70f1258a8@binary-kitchen.de> Date: Tue, 27 Oct 2020 20:06:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <4b08a126-036b-0ad6-26be-091a147f2162@proxmox.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US 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 1.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 NICE_REPLY_A -2.167 Looks like a legit reply (A) 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, smartmontools.org] Subject: Re: [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: Tue, 27 Oct 2020 19:07:25 -0000 On 27.10.20 09:08, Thomas Lamprecht wrote: > On 24.10.20 21:27, Jan-Jonas Sämann wrote: >> 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(-) >> > > seems like a nicer approach in general, could you please point to some code/reference > from where you took those register names below? It's directly from the sources of smartmontools: https://www.smartmontools.org/browser/trunk/smartmontools/drivedb.h Most of them correspond to the old value from vendormap. There are a couple exceptions where some vendors/drives do not have a direct equivalent. There I estimated the closest possible match. It's still a mess. Would be really cool if at least smartmontools provided a common fixed attribute for each drive. So maybe I missed some, hard to say. The register names ensure we don't acidently interpret unrelated data in some weird circumstances. > >> 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); >> } >> }; >> > > >