Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mimic: qa/workunits/rbd: wait for rbd-nbd unmap to complete #28310

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions qa/workunits/rbd/rbd-nbd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ function get_pid()
ps -p ${PID} -o cmd | grep rbd-nbd
}

unmap_device()
{
local unmap_dev=$1
local list_dev=$2
_sudo rbd-nbd unmap ${unmap_dev}

for s in 0.5 1 2 4 8 16 32; do
sleep ${s}
rbd-nbd list-mapped | expect_false grep "${list_dev} $" && return 0
done
return 1
}

#
# main
#
Expand Down Expand Up @@ -110,8 +123,7 @@ get_pid
# map test specifying the device
expect_false _sudo rbd-nbd --device ${DEV} map ${POOL}/${IMAGE}
dev1=${DEV}
_sudo rbd-nbd unmap ${DEV}
rbd-nbd list-mapped | expect_false grep "${DEV} $"
unmap_device ${DEV} ${DEV}
DEV=
# XXX: race possible when the device is reused by other process
DEV=`_sudo rbd-nbd --device ${dev1} map ${POOL}/${IMAGE}`
Expand Down Expand Up @@ -190,8 +202,7 @@ ps -p ${PID} -o cmd | expect_false grep rbd-nbd
rbd snap create ${POOL}/${IMAGE}@snap
DEV=`_sudo rbd-nbd map ${POOL}/${IMAGE}@snap`
get_pid
_sudo rbd-nbd unmap "${IMAGE}@snap"
rbd-nbd list-mapped | expect_false grep "${DEV} $"
unmap_device "${IMAGE}@snap" ${DEV}
DEV=
ps -p ${PID} -o cmd | expect_false grep rbd-nbd

Expand Down