Mike Burns
2010-Mar-17 19:53 UTC
[Ovirt-devel] [PATCH][node REPOST] Improve performance of multipath translations
Cleanup the translations of /dev/sdX to /dev/mapper and vice-versa. Signed-off-by: Mike Burns <mburns at redhat.com> --- scripts/ovirt-config-storage | 59 +++++++++++++++++++++++++---------------- scripts/ovirt-functions | 22 +++++++++++++++ 2 files changed, 58 insertions(+), 23 deletions(-) diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index 6525847..539f58c 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -38,13 +38,12 @@ swap_min_size=5 get_sd_name() { local id=$1 local device_var=$2 - for device in $(ls /sys/block) - do - if [[ $id = $(cat /sys/block/$device/dev) ]]; then - eval $device_var=$device - return - fi - done + local device_sys=$(grep -H "^$id$" /sys/block/*/dev | cut -d: -f1) + + if [ -n "$device_sys" ]; then + eval $device_var=$(basename $(dirname $device_sys)) + return + fi eval $device_var=1 } @@ -83,10 +82,23 @@ translate_multipath_device() { local dev=$1 local mpath_var=$2 + if [ -z "$dev" ]; then + if [ -n "$mpath_var" ]; then + eval $mpath_var+ fi + return + fi + if [[ "$dev" =~ "/dev/mapper" ]]; then + eval $mpath_var=$dev + return + fi + local basedev=$(basename $dev) - local mpath_device=$(multipath -ll $dev |grep -n . | \ - grep "^1:" |awk '{print $1}' | sed 's/^1:/\/dev\/mapper\//g') + local dm_dev=/dev/$(multipath -ll $dev | egrep dm-[0-9]+ | sed -r 's/^.& (dm-[0-9]+) .*$/\1/') + + local mpath_device+ get_dm_device $dm_dev $mpath_device if [ -z "$mpath_device" ]; then mpath_device=$dev @@ -152,12 +164,12 @@ check_partition_sizes() printf "\n" if [ "$OVIRT_ISCSI_ENABLED" == "y" ]; then - get_drive_size $BOOTDRIVE BOOTDRIVESPACE + get_drive_size "$BOOTDRIVE" BOOTDRIVESPACE drive_list="BOOT" BOOT_NEED_SIZE=$BOOT_SIZE else - get_drive_size $ROOTDRIVE ROOTDRIVESPACE - get_drive_size $HOSTVGDRIVE HOSTVGDRIVESPACE + get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE + get_drive_size "$HOSTVGDRIVE" HOSTVGDRIVESPACE ROOT_NEED_SIZE=$(echo "scale=0; $ROOT_SIZE * 2"| bc -l) HOSTVG_NEED_SIZE=$(echo "scale=0;" \ "$SWAP_SIZE + $CONFIG_SIZE + $LOGGING_SIZE + $min_data_size" | bc -l) @@ -224,12 +236,13 @@ manual_input() while true; do read -rp "Enter disk device path: " manual_device if [ -z "$device" ]; then + echo "Aborting." return 1 fi - translate_multipath_device $manual_device manual_device - eval $return_var="$manual_device" + translate_multipath_device "$manual_device" manual_device if [ -n "$manual_device" ]; then if [ -b "$(readlink -f $device)" ]; then + eval $return_var="$manual_device" return 0 fi else @@ -321,7 +334,7 @@ get_dev_name() # There are two or more; make the user choose. # display description for each disk for d in $devices; do - get_drive_size $d >&2 + get_drive_size "$d" >&2 done local choices="$devices Abort" select device in $choices "Manual Selection" @@ -340,12 +353,12 @@ do_configure() if [ "$OVIRT_ISCSI_ENABLED" == "y" ]; then printf "\n\nPlease select the disk to use for the Boot partition.\n\n" BOOTDRIVE=$(get_dev_name) || return 0 - get_drive_size $BOOTDRIVE BOOTDRIVESPACE + get_drive_size "$BOOTDRIVE" BOOTDRIVESPACE echo $BOOTDRIVE else printf "\n\nPlease select the disk to use for the Root.\n\n" ROOTDRIVE=$(get_dev_name) || return 0 - get_drive_size $ROOTDRIVE ROOTDRIVESPACE + get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE printf "\n\nPlease select the disk to use for the HostVG.\n\n" HOSTVGDRIVE=$(get_dev_name) || return 0 @@ -367,7 +380,7 @@ do_configure() done fi $skipped && printf "Installation cannot proceed with existing HostVG.\n" && return 0 - get_drive_size $HOSTVGDRIVE HOSTVGDRIVESPACE + get_drive_size "$HOSTVGDRIVE" HOSTVGDRIVESPACE echo $HOSTVGDRIVESPACE fi printf "\n\nPlease configure storage partitions.\n\n" @@ -482,8 +495,8 @@ do_review() The selected disk will be repartitioned as follows: ===============================================- Root Drive: $(get_drive_size $ROOTDRIVE) - HostVG Drive: $(get_drive_size $HOSTVGDRIVE) + Root Drive: $(get_drive_size "$ROOTDRIVE") + HostVG Drive: $(get_drive_size "$HOSTVGDRIVE") Swap partition size: $SWAP_SIZE MB Installation partition size: $ROOT_SIZE * 2 MB Configuration partition size: $CONFIG_SIZE MB @@ -496,7 +509,7 @@ EOF The selected disk will be repartitioned as follows: ===============================================- Boot Drive: $(get_drive_size $BOOTDRIVE) + Boot Drive: $(get_drive_size "$BOOTDRIVE") Boot partition size: $BOOT_SIZE EOF @@ -917,10 +930,10 @@ DATA_SIZE=${OVIRT_VOL_DATA_SIZE:-$default_data_size} if [ -n "$OVIRT_INIT" ]; then # if present, use the drive selected with 'ovirt_init' boot parameter # setting these the same until kernel cmdline argument implemented - translate_multipath_device $OVIRT_INIT DRIVE + translate_multipath_device "$OVIRT_INIT" DRIVE ROOTDRIVE=$DRIVE HOSTVGDRIVE=$DRIVE - get_drive_size $ROOTDRIVE ROOTDRIVESPACE + get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE fi # if the node is Fedora then use GPT, otherwise use MBR diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions index 6839614..5661bee 100644 --- a/scripts/ovirt-functions +++ b/scripts/ovirt-functions @@ -765,6 +765,28 @@ test_ntp_configuration () { } +get_dm_device () +{ + local device=$1 + local return_var=$2 + major=$(stat -c '%t' $(readlink -f $device)) + minor=$(stat -c '%T' $(readlink -f $device)) + local dm_device+ local rc=1 + for dm in /dev/mapper/*; do + if [ $major = $(stat -c '%t' $dm) -a \ + $minor = $(stat -c '%T' $dm) ]; then + local dm_device=$dm + rc=0 + break + fi + done + + eval $return_var=$dm_device + + return $rc +} + # execute a function if called as a script, e.g. # ovirt-functions ovirt_store_config /etc/hosts -- 1.6.6.1
Maybe Matching Threads
- [PATCH node] Handle space in storage wwid
- [PATCH node] Enables stateless iscsi remote boot
- [PATCH] RFC: Advanced Storage Configuration
- [PATCH node] First draft of replacing some of the ovirt-config-* scripts with python equivalents.
- [PATCH node] add ability to select separate disks for Root and HostVG in o-c-storage