From 9bcc19de588811e11dabe6bf126bbb2932880049 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Thu, 26 Jun 2014 17:34:19 +0400 Subject: [PATCH] map-unmap.sh: fail if 'rbd rm' fails Fail if 'rbd rm' fails - most probably it'd fail with "image still has watchers" and in that case it's a bug in the kernel client which we do want to notice. Also nuke the trap-based error handling - cleanup() is half-baked and not really necessary here. Signed-off-by: Ilya Dryomov --- qa/workunits/rbd/map-unmap.sh | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/qa/workunits/rbd/map-unmap.sh b/qa/workunits/rbd/map-unmap.sh index a6fb5049452..ce7d20fca0a 100755 --- a/qa/workunits/rbd/map-unmap.sh +++ b/qa/workunits/rbd/map-unmap.sh @@ -21,28 +21,14 @@ function map_unmap() { [ $# -eq 1 ] || exit 99 local image_name="$1" - DEV="$(sudo rbd map "${image_name}")" - sudo rbd unmap "${DEV}" + local dev + dev="$(sudo rbd map "${image_name}")" + sudo rbd unmap "${dev}" } -function setup() { - [ $# -eq 2 ] || exit 99 - local image_name="$1" - local image_size="$2" - - rbd create "${image_name}" --size="${image_size}" -} - -function cleanup() { - # Have to rely on globals for the trap call - # rbd unmap "${DEV}" || true - rbd rm "${IMAGE_NAME}" || true -} -trap cleanup EXIT HUP INT - #### Start -setup "${IMAGE_NAME}" "${IMAGE_SIZE}" +rbd create "${IMAGE_NAME}" --size="${IMAGE_SIZE}" COUNT=0 START_TIME=$(get_time) @@ -53,6 +39,6 @@ while ! times_up "${END_TIME}"; do done ELAPSED=$(expr "$(get_time)" - "${START_TIME}") -echo "${COUNT} iterations completed in ${ELAPSED} seconds" +rbd rm "${IMAGE_NAME}" -exit 0 +echo "${COUNT} iterations completed in ${ELAPSED} seconds" -- 2.47.3