From: Thomas Lamprecht Date: Fri, 9 Oct 2020 16:06:33 +0000 (+0200) Subject: disk management: set more specific type for nvme X-Git-Url: https://git.proxmox.com/?p=pve-storage.git;a=commitdiff_plain;h=4731eb11180b0894814b58717eb78457ef4b03b6 disk management: set more specific type for nvme some users are confused, and it's nicer to have the more specific type presented here. Signed-off-by: Thomas Lamprecht --- diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm index 0339177..79aafcc 100644 --- a/PVE/Diskmanage.pm +++ b/PVE/Diskmanage.pm @@ -464,6 +464,11 @@ sub is_iscsi { return 0; } +my sub is_ssdlike { + my ($type) = @_; + return $type eq 'ssd' || $type eq 'nvme'; +} + sub get_disks { my ($disks, $nosmart) = @_; my $disklist = {}; @@ -533,6 +538,7 @@ sub get_disks { if ($sysdata->{rotational} == 0) { $type = 'ssd'; + $type = 'nvme' if $dev =~ m/^nvme\d+n\d+$/; $data->{rpm} = 0; } elsif ($sysdata->{rotational} == 1) { if ($data->{rpm} != -1) { @@ -548,10 +554,10 @@ sub get_disks { if (!$nosmart) { eval { - my $smartdata = get_smart_data($devpath, ($type ne 'ssd')); + my $smartdata = get_smart_data($devpath, !is_ssdlike($type)); $health = $smartdata->{health} if $smartdata->{health}; - if ($type eq 'ssd') { + 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}); $wearout = $wearval if defined($wearval); diff --git a/test/disk_tests/nvme_smart/disklist_expected.json b/test/disk_tests/nvme_smart/disklist_expected.json index 1bcdb7d..4d1c92f 100644 --- a/test/disk_tests/nvme_smart/disklist_expected.json +++ b/test/disk_tests/nvme_smart/disklist_expected.json @@ -11,6 +11,6 @@ "devpath" : "/dev/nvme0n1", "gpt" : 0, "wwn" : "unknown", - "type" : "ssd" + "type" : "nvme" } }