Skip to content

Commit dd9497f

Browse files
committed
remvove_lun - reverted back to orifinal version
Signed-off-by: Kristian Feldsam <feldsam@gmail.com>
1 parent ef55e0d commit dd9497f

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

datastore/3par/scripts_3par.sh

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -138,42 +138,19 @@ function remove_lun {
138138
WWN="$1"
139139
cat <<EOF
140140
DEV="/dev/mapper/3$WWN"
141-
SLAVES=\$($SUDO $MULTIPATH -l 3$WWN | grep -Eo 'sd[a-z]+')
141+
DM_HOLDER=\$($SUDO $DMSETUP ls -o blkdevname | grep -Po "(?<=3$WWN\s\()[^)]+")
142+
DM_SLAVE=\$(ls /sys/block/\${DM_HOLDER}/slaves)
142143
143-
if [ -z "\${SLAVES}" ]; then
144-
SLAVES=\$($SUDO $MULTIPATH -r 3$WWN | grep -Eo 'sd[a-z]+')
145-
fi
146-
147-
$(multipath_flush "3$WWN")
144+
$(multipath_flush "\$DEV")
148145
149146
unset device
150-
for device in \${SLAVES}
147+
for device in \${DM_SLAVE}
151148
do
152149
if [ -e /dev/\${device} ]; then
153150
$SUDO $BLOCKDEV --flushbufs /dev/\${device}
154151
echo 1 | $SUDO $TEE /sys/block/\${device}/device/delete
155152
fi
156153
done
157-
158-
# wait for auto remove multipath
159-
EXISTS=1
160-
COUNTER=1
161-
while [ "\${SLAVES}" ] && [ \$EXISTS -gt 0 ] && [ \$COUNTER -le 30 ]; do
162-
sleep 1
163-
EXISTS=\$($SUDO $MULTIPATH -ll 3$WWN | head -c1 | wc -c)
164-
COUNTER=\$((\$COUNTER + 1))
165-
done
166-
167-
if [[ \$EXISTS -gt 0 ]]; then
168-
# Wait for releasing device
169-
OPEN_COUNT=1
170-
while [ \$OPEN_COUNT -gt 0 ]; do
171-
sleep 1
172-
OPEN_COUNT=\$($SUDO $DMSETUP info 3$WWN | grep -P "Open\scount:" | grep -oP "[0-9]+")
173-
done
174-
175-
$(multipath_flush "3$WWN")
176-
fi
177154
EOF
178155
}
179156

0 commit comments

Comments
 (0)