From 3db20bccefdb63a6b6b8c9731db67f08a768e7fa Mon Sep 17 00:00:00 2001 From: Eduard Shishkin Date: Wed, 4 Dec 2024 13:37:46 +0100 Subject: [PATCH] zipl_helper.device-mapper: Add missed step in logical device resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the problem: \# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 5G 0 loop |-loop0p1 253:15 0 128M 0 part `-loop0p2 253:16 0 4.9G 0 part /mnt \# ./zipl_helper.device-mapper 253:16 Expected result: targetbase=7:0 targettype=SCSI targetblocksize=4096 targetoffset=32784 Actual result: targetbase=253:16 targettype=SCSI targetblocksize=4096 targetoffset=32784 The problem is in a missed step which resolves the uppermost logical dm-device to a physical device. Reproducible only for loop devices. Add missing step to correctly resolve to a physical device. Fixes: 670bf3e8709e ("zipl: refactor zipl_helper.device-mapper") Signed-off-by: Eduard Shishkin Acked-by: Jan Höppner Signed-off-by: Jan Höppner --- zipl/src/zipl_helper.device-mapper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zipl/src/zipl_helper.device-mapper.c b/zipl/src/zipl_helper.device-mapper.c index aca52be1..73862ea9 100644 --- a/zipl/src/zipl_helper.device-mapper.c +++ b/zipl/src/zipl_helper.device-mapper.c @@ -1306,13 +1306,13 @@ static int complete_physical_device(struct physical_device *pd, dev_t *base_dev) *base_dev = base_entry->dev.dev; } else { /* - * In this case base device is the uppermost logical + * In this case base device is the uppermost physical * device which provides access to boot sectors */ base_entry = find_base_entry(pd->dmpath, dc->bootsectors); if (!base_entry) return -1; - *base_dev = base_entry->dev.dev; + *base_dev = first_device_by_target_data(base_entry->target); } /* Check for valid offset of filesystem */ if ((pd->offset % (dc->blocksize / SECTOR_SIZE)) != 0) {