From 844058bf4d366f1ef7b57ed66a748d9d9642d04d Mon Sep 17 00:00:00 2001 From: Alexander Egorenkov Date: Wed, 18 Aug 2021 08:24:54 +0200 Subject: [PATCH] zipl: Extend disk_get_info() to recognize NVMe disks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Until now, NVMe disks were handled by zipl as SCSI disks. To support NVMe stand-alone dump, it became necessary to further differentiate between both types of disks. There are two cases that must be handled: 1. A non-device-mapper device is a NVMe disk if it is assigned to the blkext device driver. 2. A device-mapper disk is a NVMe disk if the ioctl NVME_IOCTL_ID succeeds. This case is necessary to properly recognize NVMe disks which are DM devices and, therefore, not directly handled by the blkext device driver. Signed-off-by: Alexander Egorenkov Acked-by: Stefan Haberland Acked-by: Alexander Gordeev Signed-off-by: Jan Höppner --- zipl/include/disk.h | 1 + zipl/src/disk.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/zipl/include/disk.h b/zipl/include/disk.h index 3c3b4f74..4280aa7c 100644 --- a/zipl/include/disk.h +++ b/zipl/include/disk.h @@ -88,6 +88,7 @@ struct disk_info { char* drv_name; source_t source; definition_t targetbase; + int is_nvme; }; struct file_range { diff --git a/zipl/src/disk.c b/zipl/src/disk.c index 6d3cfb57..52e55286 100644 --- a/zipl/src/disk.c +++ b/zipl/src/disk.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "lib/util_proc.h" @@ -346,6 +347,9 @@ disk_get_info(const char* device, struct job_target_data* target, data->device = stats.st_rdev; data->targetbase = defined_as_name; } + if (data->type == disk_type_scsi && + ioctl(fd, NVME_IOCTL_ID) >= 0) + data->is_nvme = 1; goto type_determined; } if (ioctl(fd, BLKSSZGET, &data->phy_block_size)) { @@ -407,9 +411,11 @@ disk_get_info(const char* device, struct job_target_data* target, goto out_close; } /* NVMe path, driver name is 'blkext' */ - } else if (strcmp(data->drv_name, "blkext") == 0) { + } else if (strcmp(data->drv_name, "blkext") == 0 && + ioctl(fd, NVME_IOCTL_ID) >= 0) { data->devno = -1; data->type = disk_type_scsi; + data->is_nvme = 1; if (util_sys_dev_is_partition(stats.st_rdev)) { if (util_sys_get_base_dev(stats.st_rdev, &data->device))