zipl: Extend disk_get_info() to recognize NVMe disks

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 <egorenar@linux.ibm.com>
Acked-by: Stefan Haberland <sth@linux.ibm.com>
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Alexander Egorenkov
2021-08-18 08:24:54 +02:00
committed by Jan Höppner
parent dc49b4fcf0
commit 844058bf4d
2 changed files with 8 additions and 1 deletions

View File

@@ -88,6 +88,7 @@ struct disk_info {
char* drv_name;
source_t source;
definition_t targetbase;
int is_nvme;
};
struct file_range {

View File

@@ -23,6 +23,7 @@
#include <unistd.h>
#include <linux/fs.h>
#include <linux/fiemap.h>
#include <linux/nvme_ioctl.h>
#include <assert.h>
#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))