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-<WWID> 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 <jackie.huang@windriver.com>
Signed-off-by: Thiago Miranda <ThiagoOliveira.Miranda@windriver.com>
Change-Id: I60c5b2a7c7ca42d8e5e36ea517327c8a5431dde7
This commit is contained in:
Jackie Huang 2022-03-01 11:40:54 +08:00 committed by Felipe Sanches Zanoni
parent 3ac0bcfd99
commit da68897268
2 changed files with 36 additions and 4 deletions

View File

@ -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()

View File

@ -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