From 80a3f18cafb4add1624cc690bba436a1284dc634 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 11 Mar 2020 15:11:10 -0400 Subject: [PATCH] qa/workunits/rbd: wait for nbd map to close after unmap The unmap action only sends a signal to the kernel to notify the rbd-nbd daemon to disconnect. Therefore, it's possible that an unmap followed by an immediate re-map to the same device might fail since the unmap is still in-progress. Fixes: https://tracker.ceph.com/issues/44567 Signed-off-by: Jason Dillaman --- qa/workunits/rbd/rbd-nbd.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/qa/workunits/rbd/rbd-nbd.sh b/qa/workunits/rbd/rbd-nbd.sh index 2d718b3e26a..f4fe2481186 100755 --- a/qa/workunits/rbd/rbd-nbd.sh +++ b/qa/workunits/rbd/rbd-nbd.sh @@ -101,7 +101,7 @@ function get_pid() unmap_device() { local unmap_dev=$1 - local list_dev=$2 + local list_dev=${2:-$1} _sudo rbd-nbd unmap ${unmap_dev} for s in 0.5 1 2 4 8 16 32; do @@ -138,7 +138,7 @@ get_pid # map test specifying the device expect_false _sudo rbd-nbd --device ${DEV} map ${POOL}/${IMAGE} dev1=${DEV} -unmap_device ${DEV} ${DEV} +unmap_device ${DEV} DEV= # XXX: race possible when the device is reused by other process DEV=`_sudo rbd-nbd --device ${dev1} map ${POOL}/${IMAGE}` @@ -183,7 +183,7 @@ test -n "${blocks2}" test ${blocks2} -eq ${blocks} # read-only option test -_sudo rbd-nbd unmap ${DEV} +unmap_device ${DEV} DEV=`_sudo rbd-nbd map --read-only ${POOL}/${IMAGE}` PID=$(rbd-nbd list-mapped | awk -v pool=${POOL} -v img=${IMAGE} -v dev=${DEV} \ '$2 == pool && $3 == img && $5 == dev {print $1}') @@ -192,7 +192,7 @@ ps -p ${PID} -o cmd | grep rbd-nbd _sudo dd if=${DEV} of=/dev/null bs=1M expect_false _sudo dd if=${DATA} of=${DEV} bs=1M oflag=direct -_sudo rbd-nbd unmap ${DEV} +unmap_device ${DEV} # exclusive option test DEV=`_sudo rbd-nbd map --exclusive ${POOL}/${IMAGE}` @@ -201,15 +201,14 @@ get_pid _sudo dd if=${DATA} of=${DEV} bs=1M oflag=direct expect_false timeout 10 \ rbd bench ${IMAGE} --io-type write --io-size=1024 --io-total=1024 -_sudo rbd-nbd unmap ${DEV} +unmap_device ${DEV} DEV= rbd bench ${IMAGE} --io-type write --io-size=1024 --io-total=1024 # unmap by image name test DEV=`_sudo rbd-nbd map ${POOL}/${IMAGE}` get_pid -_sudo rbd-nbd unmap "${IMAGE}" -rbd-nbd list-mapped | expect_false grep "${DEV} $" +unmap_device ${IMAGE} ${DEV} DEV= ps -p ${PID} -o cmd | expect_false grep rbd-nbd -- 2.39.5