From: Prasanna Kumar Kalever Date: Mon, 17 May 2021 08:47:53 +0000 (+0530) Subject: qa/workunits/rbd: test map/attach with --show-cookie/--cookie options X-Git-Tag: v16.2.8~69^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=142cd59e605d7a32260fd23c0ea1906c4738b955;p=ceph.git qa/workunits/rbd: test map/attach with --show-cookie/--cookie options Signed-off-by: Prasanna Kumar Kalever (cherry picked from commit 2adfe55bcce08f8f46989e9ddbf46aa74e681992) --- diff --git a/qa/workunits/rbd/rbd-nbd.sh b/qa/workunits/rbd/rbd-nbd.sh index 262cddb9abc4..f832140837e9 100755 --- a/qa/workunits/rbd/rbd-nbd.sh +++ b/qa/workunits/rbd/rbd-nbd.sh @@ -343,22 +343,39 @@ cat ${LOG_FILE} expect_false grep 'quiesce failed' ${LOG_FILE} # test detach/attach -DEV=`_sudo rbd device --device-type nbd --options try-netlink map ${POOL}/${IMAGE}` +OUT=`_sudo rbd device --device-type nbd --options try-netlink,show-cookie map ${POOL}/${IMAGE}` +read DEV COOKIE <<< "${OUT}" get_pid ${POOL} _sudo mount ${DEV} ${TEMPDIR}/mnt _sudo rbd device detach ${POOL}/${IMAGE} --device-type nbd expect_false get_pid ${POOL} expect_false _sudo rbd device attach --device ${DEV} ${POOL}/${IMAGE} --device-type nbd -_sudo rbd device attach --device ${DEV} ${POOL}/${IMAGE} --device-type nbd --force +if [ -n "${COOKIE}" ]; then + _sudo rbd device attach --device ${DEV} --cookie ${COOKIE} ${POOL}/${IMAGE} --device-type nbd +else + _sudo rbd device attach --device ${DEV} ${POOL}/${IMAGE} --device-type nbd --force +fi get_pid ${POOL} _sudo rbd device detach ${DEV} --device-type nbd expect_false get_pid ${POOL} -_sudo rbd device attach --device ${DEV} ${POOL}/${IMAGE} --device-type nbd --force +if [ -n "${COOKIE}" ]; then + _sudo rbd device attach --device ${DEV} --cookie ${COOKIE} ${POOL}/${IMAGE} --device-type nbd +else + _sudo rbd device attach --device ${DEV} ${POOL}/${IMAGE} --device-type nbd --force +fi get_pid ${POOL} ls ${TEMPDIR}/mnt/ dd if=${TEMPDIR}/mnt/test of=/dev/null bs=1M count=1 _sudo dd if=${DATA} of=${TEMPDIR}/mnt/test1 bs=1M count=1 oflag=direct _sudo umount ${TEMPDIR}/mnt unmap_device ${DEV} ${PID} +# if kernel supports cookies +if [ -n "${COOKIE}" ]; then + OUT=`_sudo rbd device --device-type nbd --show-cookie --cookie "abc de" --options try-netlink map ${POOL}/${IMAGE}` + read DEV ANOTHER_COOKIE <<< "${OUT}" + get_pid ${POOL} + test "${ANOTHER_COOKIE}" = "abc de" + unmap_device ${DEV} ${PID} +fi echo OK