Merge "kickstarts: add support for mpath device"

This commit is contained in:
Zuul 2022-05-24 14:23:09 +00:00 committed by Gerrit Code Review
commit be95984d5c
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)
}
@ -99,6 +112,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
@ -113,6 +128,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

@ -61,10 +61,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