]> git.proxmox.com Git - pve-storage.git/commitdiff
disk management: set more specific type for nvme
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 9 Oct 2020 16:06:33 +0000 (18:06 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 9 Oct 2020 16:06:38 +0000 (18:06 +0200)
some users are confused, and it's nicer to have the more specific
type presented here.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/Diskmanage.pm
test/disk_tests/nvme_smart/disklist_expected.json

index 0339177681f972f9fe75d6ee46315f90d6e57c8d..79aafccd0c2401b3ec3a0274542fef5488405c08 100644 (file)
@@ -464,6 +464,11 @@ sub is_iscsi {
     return 0;
 }
 
     return 0;
 }
 
+my sub is_ssdlike {
+    my ($type) = @_;
+    return $type eq 'ssd' || $type eq 'nvme';
+}
+
 sub get_disks {
     my ($disks, $nosmart) = @_;
     my $disklist = {};
 sub get_disks {
     my ($disks, $nosmart) = @_;
     my $disklist = {};
@@ -533,6 +538,7 @@ sub get_disks {
 
        if ($sysdata->{rotational} == 0) {
            $type = 'ssd';
 
        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) {
            $data->{rpm} = 0;
        } elsif ($sysdata->{rotational} == 1) {
            if ($data->{rpm} != -1) {
@@ -548,10 +554,10 @@ sub get_disks {
 
        if (!$nosmart) {
            eval {
 
        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};
 
                $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);
                    # 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);
index 1bcdb7d11d28561142afe91f5956a4db3fc171cb..4d1c92f6122ee4ca4abc2e40f3b54181be4d8013 100644 (file)
@@ -11,6 +11,6 @@
        "devpath" : "/dev/nvme0n1",
        "gpt" : 0,
        "wwn" : "unknown",
        "devpath" : "/dev/nvme0n1",
        "gpt" : 0,
        "wwn" : "unknown",
-       "type" : "ssd"
+       "type" : "nvme"
     }
 }
     }
 }