Skip to content

Commit

Permalink
remvove_lun - reverted back to orifinal version
Browse files Browse the repository at this point in the history
Signed-off-by: Kristian Feldsam <[email protected]>
  • Loading branch information
feldsam committed Jun 25, 2023
1 parent ef55e0d commit dd9497f
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions datastore/3par/scripts_3par.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,42 +138,19 @@ function remove_lun {
WWN="$1"
cat <<EOF
DEV="/dev/mapper/3$WWN"
SLAVES=\$($SUDO $MULTIPATH -l 3$WWN | grep -Eo 'sd[a-z]+')
DM_HOLDER=\$($SUDO $DMSETUP ls -o blkdevname | grep -Po "(?<=3$WWN\s\()[^)]+")
DM_SLAVE=\$(ls /sys/block/\${DM_HOLDER}/slaves)
if [ -z "\${SLAVES}" ]; then
SLAVES=\$($SUDO $MULTIPATH -r 3$WWN | grep -Eo 'sd[a-z]+')
fi
$(multipath_flush "3$WWN")
$(multipath_flush "\$DEV")
unset device
for device in \${SLAVES}
for device in \${DM_SLAVE}
do
if [ -e /dev/\${device} ]; then
$SUDO $BLOCKDEV --flushbufs /dev/\${device}
echo 1 | $SUDO $TEE /sys/block/\${device}/device/delete
fi
done
# wait for auto remove multipath
EXISTS=1
COUNTER=1
while [ "\${SLAVES}" ] && [ \$EXISTS -gt 0 ] && [ \$COUNTER -le 30 ]; do
sleep 1
EXISTS=\$($SUDO $MULTIPATH -ll 3$WWN | head -c1 | wc -c)
COUNTER=\$((\$COUNTER + 1))
done
if [[ \$EXISTS -gt 0 ]]; then
# Wait for releasing device
OPEN_COUNT=1
while [ \$OPEN_COUNT -gt 0 ]; do
sleep 1
OPEN_COUNT=\$($SUDO $DMSETUP info 3$WWN | grep -P "Open\scount:" | grep -oP "[0-9]+")
done
$(multipath_flush "3$WWN")
fi
EOF
}

Expand Down

0 comments on commit dd9497f

Please sign in to comment.