From 47460e6e3314afe7d7765816f1530037f43ea0bd Mon Sep 17 00:00:00 2001 From: Eduard Shishkin Date: Wed, 2 Oct 2024 12:36:18 +0200 Subject: [PATCH] zipl/src: Support md-partitions as zipl targets This patch adds support for zipl targets over partitions of md-devices. With this patch it is possible to specify a zipl target over any partition of an md-device, so that all the physical disks participating in the mirrored setup will be prepared for IPL. Unlike a whole md-device which has major number 9, its partitions have major numbers 259 and the driver name is identified as 'blkext' in '/proc/devices'. Handle this case in set_driver_name(): call ioctl() to make sure that device is an md-partition. Drop re-definition of some macros. Signed-off-by: Eduard Shishkin Reviewed-by: Stefan Haberland Signed-off-by: Steffen Eiden --- zipl/src/disk.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/zipl/src/disk.c b/zipl/src/disk.c index b6e66296..fbbf1f91 100644 --- a/zipl/src/disk.c +++ b/zipl/src/disk.c @@ -22,8 +22,10 @@ #include #include #include +#include #include #include +#include #include #include "lib/util_proc.h" @@ -35,12 +37,6 @@ #include "job.h" #include "misc.h" -/* from linux/fs.h */ -#define FIBMAP _IO(0x00,1) -#define FIGETBSZ _IO(0x00,2) -#define BLKGETSIZE _IO(0x12,96) -#define BLKSSZGET _IO(0x12,104) - /* from linux/hdregs.h */ #define HDIO_GETGEO 0x0301 @@ -492,7 +488,7 @@ static void set_source_type(struct job_target_data *td, td->source = source_auto; } -static void set_driver_name(struct disk_info *info, dev_t device) +static void set_driver_name(int fd, struct disk_info *info, dev_t device) { struct util_proc_dev_entry dev_entry; @@ -500,7 +496,14 @@ static void set_driver_name(struct disk_info *info, dev_t device) /* already set */ return; if (util_proc_dev_get_entry(device, 1, &dev_entry) == 0) { - info->drv_name = misc_strdup(dev_entry.name); + mdu_array_info_t array; + + if (strcmp(dev_entry.name, "blkext") == 0 && + ioctl(fd, GET_ARRAY_INFO, &array) >= 0) + /* it is actually an md-partition */ + info->drv_name = misc_strdup("md"); + else + info->drv_name = misc_strdup(dev_entry.name); util_proc_dev_free_entry(&dev_entry); } else { fprintf(stderr, "Warning: Could not determine driver name for " @@ -684,7 +687,7 @@ int disk_get_info(const char *device, struct job_target_data *td, if (!data) goto error; memset((void *)data, 0, sizeof(struct disk_info)); - set_driver_name(data, stats.st_rdev); + set_driver_name(fd, data, stats.st_rdev); set_source_type(td, data->drv_name, &script_file); switch (td->source) { case source_script: