From 4841f53ca6cfd56bff046cba431ce89fa8500733 Mon Sep 17 00:00:00 2001 From: "Kabanov, Dmitrii" Date: Tue, 26 May 2020 15:03:59 -0700 Subject: [PATCH] [Ceph-osd] Avoid using lsblk/blkid. The PS improves performance by replacing lsblk/blkid (In some cases blkid may be pretty slow). Also it allows to avoid deadlocks when there are RBDs mapped on the host. Change-Id: If607e168515f55478e9e55e421738d2d00269d3f --- ceph-osd/templates/bin/osd/ceph-volume/_common.sh.tpl | 11 +++++++++-- 1 file changed, 9 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 9ab63df5e3..4c5f72c50c 100644 --- a/ceph-osd/templates/bin/osd/ceph-volume/_common.sh.tpl +++ b/ceph-osd/templates/bin/osd/ceph-volume/_common.sh.tpl @@ -213,8 +213,8 @@ function zap_extra_partitions { function disk_zap { # Run all the commands that ceph-disk zap uses to clear a disk local device=${1} - local device_filter=$(echo $device | cut -d'/' -f3) - local dm_devices=$(lsblk -o name,type -l | grep "lvm" | grep "$device_filter" | awk '/ceph/{print $1}' | tr '\n' ' ') + local device_filter=$(basename "${device}") + local dm_devices=$(get_lvm_path_from_device "pv_name=~${device_filter},lv_name=~ceph") for dm_device in ${dm_devices}; do if [[ ! -z ${dm_device} ]]; then dmsetup remove ${dm_device} @@ -384,6 +384,13 @@ function get_osd_wal_device_from_device { get_lvm_tag_from_device ${device} ceph.wal_device } +function get_lvm_path_from_device { + select="$1" + + options="--noheadings -o lv_dm_path" + pvs ${options} -S "${select}" | tr -d ' ' +} + function set_device_class { if [ ! -z "$DEVICE_CLASS" ]; then if [ "x$DEVICE_CLASS" != "x$(get_device_class)" ]; then