From e09753f2a3b2f23ca6e96814f7bb621ddd723e73 Mon Sep 17 00:00:00 2001 From: Eduard Shishkin Date: Wed, 28 Aug 2024 11:18:04 +0200 Subject: [PATCH] chreipl_helper.device-mapper: complete device resolution process MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes 670bf3e8 which actually isn't an equivalent refactoring. The generic dm-device resolution procedure was modified to not resolve the topmost dm-device in the path. So that any calles who don't expect it, should complete the resolutioin process by themselves. In case of chreipl_helper such completion was missed. chreipl(8) utility doesn't expect dm-devices at the output of chreipl_helper.device-mapper Example: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk |-sda1 8:1 0 20G 0 part `-mpathb 253:0 0 20G 0 mpath `-mpathb1 253:2 0 20G 0 part / sdb 8:16 0 20G 0 disk |-sdb1 8:17 0 20G 0 part `-mpathb 253:0 0 20G 0 mpath `-mpathb1 253:2 0 20G 0 part / Expected result: 8:16 Actual result: 253:0 As a result, the chreipl(8) "node" option stopped working. The fixup adds the completion. Reported-by: Alexander Egorenkov Signed-off-by: Eduard Shishkin Tested-by: Alexander Egorenkov Signed-off-by: Jan Höppner --- zipl/src/zipl_helper.device-mapper.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/zipl/src/zipl_helper.device-mapper.c b/zipl/src/zipl_helper.device-mapper.c index b0c7ccaf..6f96eae9 100644 --- a/zipl/src/zipl_helper.device-mapper.c +++ b/zipl/src/zipl_helper.device-mapper.c @@ -19,7 +19,7 @@ * device-mapper table for this device conforms to the following rules: * - directory is located on a device consisting of a single device-mapper * target - * - only linear, mirror and multipath targets are supported + * - only linear, multipath, mirror and raid targets are supported * - supported physical device types are DASD and SCSI devices * - all of the device which contains the directory must be located on a single * physical device (which may be mirrored or accessed through a multipath @@ -1179,6 +1179,11 @@ static struct util_list *dmpath_walk(struct ext_dev *bottom, const char *dir, return NULL; } +/* + * In case of success PD contains a dmpath. The topmost target of that + * dmpath is a dm-device. So, any callers who don't expect it, should + * complete the resolution process by themselves + */ static int get_physical_device(struct physical_device *pd, struct ext_dev *dev, const char *dir) { @@ -1401,7 +1406,13 @@ static int dm_dev_to_chreipl_params(dev_t dev, char *dir) if (get_physical_device(&pd, &xdev, dir)) return -1; - top_dev = get_top_entry(&pd)->dev.dev; + /* + * chreipl(8) utility doesn't expect dm-device at the + * chreipl_helper output. So, complete the resolution + * process (see the comment to get_physical_device) + */ + top_dev = first_device_by_target_data(get_top_entry(&pd)->target); + printf("%u:%u\n", major(top_dev), minor(top_dev)); dmpath_free(pd.dmpath); return 0;