]> granicus.if.org Git - zfs/commitdiff
Add support for nvme disk detection
authortimor <timor.dd@googlemail.com>
Wed, 21 Mar 2018 15:35:20 +0000 (16:35 +0100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 21 Mar 2018 15:35:20 +0000 (08:35 -0700)
This treats /dev/nvme.. devices the same way as /dev/sd... devices.  The
motivation behind this is that whole disk detection did not work on nvme
SSDs without that, because it DKC_UNKNOWN was returned for such devices.

Perhaps there should be a separate DKC_ type for this, but I don't know
enough about the code to know the implications of that.

Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: timor <timor.dd@googlemail.com>
Closes #7304

lib/libefi/rdwr_efi.c

index e9fb15ee2a6e7144fafd6a44050161958a933e74..7935047ebfcd811dcb002344ec5a9ed51396933b 100644 (file)
@@ -300,6 +300,20 @@ efi_get_info(int fd, struct dk_cinfo *dki_info)
                rval = sscanf(dev_path, "/dev/loop%[0-9]p%hu",
                    dki_info->dki_dname + 4,
                    &dki_info->dki_partition);
+       } else if ((strncmp(dev_path, "/dev/nvme", 9) == 0)) {
+               strcpy(dki_info->dki_cname, "nvme");
+               dki_info->dki_ctype = DKC_SCSI_CCS;
+               strcpy(dki_info->dki_dname, "nvme");
+               (void) sscanf(dev_path, "/dev/nvme%[0-9]",
+                   dki_info->dki_dname + 4);
+               size_t controller_length = strlen(
+                   dki_info->dki_dname);
+               strcpy(dki_info->dki_dname + controller_length,
+                   "n");
+               rval = sscanf(dev_path,
+                   "/dev/nvme%*[0-9]n%[0-9]p%hu",
+                   dki_info->dki_dname + controller_length + 1,
+                   &dki_info->dki_partition);
        } else {
                strcpy(dki_info->dki_dname, "unknown");
                strcpy(dki_info->dki_cname, "unknown");