Skip to content

Commit

Permalink
mxraid_assemble: Add support for nvme devices
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas committed Jan 21, 2019
1 parent 592ce5c commit c62f14e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions mxraid/mxraid_assemble
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ if ($opts{l}) {
my $md = $hd->mddev_by_member()->{$rec->[0]};
$md = 'n/a' unless defined $md;
$reg{$md}+=1;
printf " %-5s %5s %-16s '%s'\n", $md, @$rec;
printf " %-5s %-9s %-16s '%s'\n", $md, @$rec;
}
print " Note: this doesn't look like a standard configuration.\n" if scalar keys %reg != 1;
print "\n";
}
if ($VERBOSE >= 2) {
print "Disks not part of a configured SW-RAID:\n";
for my $rec (@{$hd->non_raid_disks()}) {
printf " %5s %-16s '%s'\n", @$rec;
printf " %-9s %-16s '%s'\n", @$rec;
}
print "\n";
}
Expand All @@ -159,7 +159,7 @@ if ($opts{n}) {
$entry .= $opts{n}.':';
for my $rec (@{$hd->non_raid_disks()}) {
my $dev = $rec->[0];
next unless $dev =~ m/sd[a-z]+/;
next unless $dev =~ m/(sd[a-z]+|nvme\d+n\d+)/;
if (grep {m|^/dev/$dev\d*\b|} @mounts) {
warn "# NOTE: /dev/$dev is mounted, skipping.\n" if $VERBOSE >= 2;
next;
Expand Down Expand Up @@ -520,7 +520,10 @@ exit;
sub discover_basic {
my $self = shift;

my @disks = ( glob('/sys/block/sd[a-z]'), glob('/sys/block/sd[a-z][a-z]') ); # 676 disks max
# take only whole disks, no partitions
my @disks = grep {m:/(sd[a-z]+|nvme\d+n\d+)$:} (
glob('/sys/block/sd[a-z]*'), glob('/sys/block/nvme[0-9]*')
);
my $diskinfo = $self->get_hd_info(\@disks);
my @non_raid;
my %configured_raids;
Expand Down Expand Up @@ -670,13 +673,16 @@ exit;
# }

my $serial_number;
if (-e '/sys/block/'.$dk.'/device/vpd_pg80') {
if (-e '/sys/block/'.$dk.'/device/vpd_pg80') { # exists even for ahci attached disks
# Vital Product Data, page xyz
my $vpd_pg80 = parse_vpd_pg80(sys_fs_get_prop('/sys/block/'.$dk.'/device/vpd_pg80'));
if (defined $MxRaid::HostData::BAD_MODELS{uc($model)}) {
$vpd_pg80 = $MxRaid::HostData::BAD_MODELS{uc($model)}($vpd_pg80);
}
$serial_number = $vpd_pg80;
} elsif (-e '/sys/block/'.$dk.'/device/serial') { # nvme disks are supposed to have this
$serial_number = sys_fs_get_prop('/sys/block/'.$dk.'/device/serial');
$serial_number =~ s/^\s+//;
} else {
if ($self->{root_priv}) {
$serial_number = smartctl_info($dev_list->[$i], 'Serial_Number');
Expand Down

0 comments on commit c62f14e

Please sign in to comment.