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 C1B066281C for ; Tue, 27 Oct 2020 09:08:27 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B4E1E15409 for ; Tue, 27 Oct 2020 09:08:27 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 28828153FE for ; Tue, 27 Oct 2020 09:08:27 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E61E845F42; Tue, 27 Oct 2020 09:08:26 +0100 (CET) To: Proxmox VE development discussion , =?UTF-8?Q?Jan-Jonas_S=c3=a4mann?= References: <4e2bd780-260b-d757-e108-8ea8bb57c0df@proxmox.com> <20201024192709.27324-1-sprinterfreak@binary-kitchen.de> <20201024192709.27324-2-sprinterfreak@binary-kitchen.de> From: Thomas Lamprecht Message-ID: <4b08a126-036b-0ad6-26be-091a147f2162@proxmox.com> Date: Tue, 27 Oct 2020 09:08:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Thunderbird/83.0 MIME-Version: 1.0 In-Reply-To: <20201024192709.27324-2-sprinterfreak@binary-kitchen.de> Content-Type: text/plain; charset=UTF-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.913 Adjusted score from AWL reputation of From: address GAPPY_SUBJECT 0.1 Subject: contains G.a.p.p.y-T.e.x.t KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -2.167 Looks like a legit reply (A) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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] 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 08:08:27 -0000 On 24.10.20 21:27, Jan-Jonas S=C3=A4mann 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 reliabl= e > data. >=20 > Signed-off-by: Jan-Jonas S=C3=A4mann > --- > PVE/Diskmanage.pm | 58 +++++++++++++++++++++++------------------------= > 1 file changed, 28 insertions(+), 30 deletions(-) >=20 seems like a nicer approach in general, could you please point to some co= de/reference from where you took those register names below? > 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 { > } > =20 > sub get_wear_leveling_info { > - my ($smartdata, $model) =3D @_; > + my ($smartdata) =3D @_; > my $attributes =3D $smartdata->{attributes}; > =20 > if (defined($smartdata->{wearout})) { > @@ -405,37 +405,35 @@ sub get_wear_leveling_info { > =20 > my $wearout; > =20 > - my $vendormap =3D { > - 'kingston' =3D> 231, > - 'samsung' =3D> 177, > - 'intel' =3D> 233, > - 'sandisk' =3D> 233, > - 'crucial' =3D> 202, > - 'default' =3D> 233, > - }; > - > - # find target attr id > - > - my $attrid; > - > - foreach my $vendor (keys %$vendormap) { > - if ($model =3D~ m/$vendor/i) { > - $attrid =3D $vendormap->{$vendor}; > - # found the attribute > - last; > + # Common register names that represent percentage values of potent= ial > + # failure indicators used in drivedb.h of smartmontool's. Order ma= tters, > + # as some drives may have multiple definitions > + my @wearoutregisters =3D ( > + "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 =3D ($attr->{name} =3D~ /Used/) ? 100 - $attr->{value} : = $attr->{value}; > + last; > } > } > =20 > - if (!$attrid) { > - $attrid =3D $vendormap->{default}; > - } > - > - foreach my $attr (@$attributes) { > - next if $attr->{id} !=3D $attrid; > - $wearout =3D $attr->{value}; > - last; > - } > - > return $wearout; > } > =20 > @@ -559,7 +557,7 @@ sub get_disks { > =20 > if (is_ssdlike($type)) { > # if we have an ssd we try to get the wearout indicator > - my $wearval =3D get_wear_leveling_info($smartdata, $data->{model= } || $sysdata->{model}); > + my $wearval =3D get_wear_leveling_info($smartdata); > $wearout =3D $wearval if defined($wearval); > } > }; >=20