From da68897268a79015fc7b490ac6090ccf500f09e6 Mon Sep 17 00:00:00 2001 From: Jackie Huang Date: Tue, 1 Mar 2022 11:40:54 +0800 Subject: [PATCH] kickstarts: add support for mpath device The device node in /dev/ and device path in /dev/disk/by-path can not be used directly for mpath devices, use /dev/mapper/mpathN and /dev/disk/by-id/dm-uuid-mpath- instead. Test Plan: * with local disks PASS: install Standard with default boot menu PASS: install AIO with default boot menu PASS: install AIO (lowlatency) with boot_device= rootfs_device= * with mpath device PASS: install AIO with boot_device= rootfs_device= PASS: install AIO with boot_device=mpatha rootfs_device=mpatha PASS: install Standard with boot_device=mpatha rootfs_device=mpatha PASS: install AIO (lowlatency)with boot_device=mpatha rootfs_device=mpatha PASS: install AIO with boot_device=mpathb rootfs_device=mpathb PASS: install AIO with boot_device=/dev/mapper/mpatha rootfs_device=/dev/mapper/mpatha Failure Path: * with local disks PASS: install AIO with boot_device=mpatha rootfs_device=mpatha * with mpath device PASS: install AIO with default boot menu Story: 2010046 Task: 45419 Signed-off-by: Jackie Huang Signed-off-by: Thiago Miranda Change-Id: I60c5b2a7c7ca42d8e5e36ea517327c8a5431dde7 --- bsp-files/kickstarts/functions.sh | 21 +++++++++++++++++++ .../kickstarts/pre_disk_setup_common.cfg | 19 +++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/bsp-files/kickstarts/functions.sh b/bsp-files/kickstarts/functions.sh index 2ee36267..3b05a3b8 100644 --- a/bsp-files/kickstarts/functions.sh +++ b/bsp-files/kickstarts/functions.sh @@ -18,6 +18,14 @@ function wlog() function get_by_path() { + local dev_name=\$(basename \$1) + for p in /dev/mapper/mpath*; do + if [ "\$p" = "\$1" -o "\$p" = "/dev/mapper/\$dev_name" ]; then + find -L /dev/disk/by-id/dm-uuid* -samefile /dev/mapper/\$dev_name + return + fi + done + local disk=\$(cd /dev ; readlink -f \$1) for p in /dev/disk/by-path/*; do if [ "\$disk" = "\$(readlink -f \$p)" ]; then @@ -29,6 +37,11 @@ function get_by_path() function get_disk() { + if echo \$1 | grep -q mpath; then + find -L /dev/mapper/ -samefile \$1 + return + fi + echo \$(cd /dev ; readlink -f \$1) } @@ -95,6 +108,8 @@ function get_disk_dev() if [ -d /sys/block/\$blk_dev ]; then disk=\$(ls -l /sys/block/\$blk_dev | grep -v usb | head -n1 | sed 's/^.*\([vsdh]d[a-z]\+\).*$/\1/'); if [ -n "\$disk" ]; then + exec_retry 3 0.5 "multipath -c /dev/\$disk" > /dev/null && continue + echo "\$disk" return fi @@ -109,6 +124,12 @@ function get_disk_dev() fi fi done + for mpath_dev in mpatha mpathb; do + if [ -e /dev/mapper/\$mpath_dev ]; then + echo "/dev/mapper/\$mpath_dev" + return + fi + done } function exec_no_fds() diff --git a/bsp-files/kickstarts/pre_disk_setup_common.cfg b/bsp-files/kickstarts/pre_disk_setup_common.cfg index b5e48081..522990a7 100644 --- a/bsp-files/kickstarts/pre_disk_setup_common.cfg +++ b/bsp-files/kickstarts/pre_disk_setup_common.cfg @@ -56,10 +56,21 @@ wlog "Detected storage devices:" for f in /dev/disk/by-path/*; do dev=$(readlink -f $f) exec_retry 2 0.5 "lsblk --nodeps --pairs $dev" | grep -q 'TYPE="disk"' - if [ $? -eq 0 ] - then - STOR_DEVS="$STOR_DEVS $dev" - wlog " ${f}->${dev}" + if [ $? -eq 0 ]; then + exec_retry 3 0.5 "multipath -c $dev" > /dev/null + if [ $? -eq 0 ]; then + mpath_dev=/dev/mapper/$(exec_retry 3 0.5 "multipath -l $dev" | head -n1 | cut -d " " -f 1) + if echo $STOR_DEVS | grep -q -w $mpath_dev; then + continue + else + STOR_DEVS="$STOR_DEVS $mpath_dev" + mpath_path=$(find -L /dev/disk/by-id/dm-uuid* -samefile $mpath_dev) + wlog " ${mpath_path}->${mpath_dev}" + fi + else + STOR_DEVS="$STOR_DEVS $dev" + wlog " ${f}->${dev}" + fi fi done