From 88f7d5f42cc1a9cafb057953b599bcf77ededb30 Mon Sep 17 00:00:00 2001 From: "Taylor, Stephen (st053q)" Date: Tue, 2 Jun 2020 11:55:07 -0600 Subject: [PATCH] [ceph-osd] Optimize symlink creation in udev_settle This change optimizes the creation of symlinks in udev_settle by only looking at the disks related to the OSD being deployed/started and skipping the ln command for existing symlinks. A second "udevadm settle" command is also added after the creation of the symlinks in order to allow any logical volumes related to new symlinks to become established. Change-Id: I3283021fd80c8a05f0aa0c9917bb7ba0ea144303 --- .../templates/bin/osd/ceph-volume/_common.sh.tpl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ceph-osd/templates/bin/osd/ceph-volume/_common.sh.tpl b/ceph-osd/templates/bin/osd/ceph-volume/_common.sh.tpl index 967f4e9d6..39adc1bd8 100644 --- a/ceph-osd/templates/bin/osd/ceph-volume/_common.sh.tpl +++ b/ceph-osd/templates/bin/osd/ceph-volume/_common.sh.tpl @@ -225,12 +225,15 @@ function disk_zap { } function udev_settle { + osd_devices="${OSD_DEVICE}" partprobe "${OSD_DEVICE}" if [ "${OSD_BLUESTORE:-0}" -eq 1 ]; then if [ ! -z "$BLOCK_DB" ]; then + osd_devices="${osd_devices}\|${BLOCK_DB}" partprobe "${BLOCK_DB}" fi if [ ! -z "$BLOCK_WAL" ] && [ "$BLOCK_WAL" != "$BLOCK_DB" ]; then + osd_devices="${osd_devices}\|${BLOCK_WAL}" partprobe "${BLOCK_WAL}" fi else @@ -238,6 +241,7 @@ function udev_settle { OSD_JOURNAL=$(readlink -f ${OSD_JOURNAL}) if [ ! -z "$OSD_JOURNAL" ]; then local JDEV=$(echo ${OSD_JOURNAL} | sed 's/[0-9]//g') + osd_devices="${osd_devices}\|${JDEV}" partprobe "${JDEV}" fi fi @@ -247,11 +251,17 @@ function udev_settle { # On occassion udev may not make the correct device symlinks for Ceph, just in case we make them manually mkdir -p /dev/disk/by-partuuid - for dev in $(awk '!/rbd/{print $4}' /proc/partitions | grep "[0-9]"); do + for dev in $(awk '!/rbd/{print $4}' /proc/partitions | grep "${osd_devices}" | grep "[0-9]"); do diskdev=$(echo "${dev//[!a-z]/}") partnum=$(echo "${dev//[!0-9]/}") - ln -s "../../${dev}" "/dev/disk/by-partuuid/$(sgdisk -i ${partnum} /dev/${diskdev} | awk '/Partition unique GUID/{print tolower($4)}')" || true + symlink="/dev/disk/by-partuuid/$(sgdisk -i ${partnum} /dev/${diskdev} | awk '/Partition unique GUID/{print tolower($4)}')" + if [ ! -e "${symlink}" ]; then + ln -s "../../${dev}" "${symlink}" + fi done + + # Give udev another chance now that all symlinks exist for devices we care about + udevadm settle --timeout=600 } # Helper function to get an lvm tag from a logical volume