]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/rbd: test map/attach with --show-cookie/--cookie options 45582/head
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Mon, 17 May 2021 08:47:53 +0000 (14:17 +0530)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 23 Mar 2022 12:31:59 +0000 (13:31 +0100)
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
(cherry picked from commit 2adfe55bcce08f8f46989e9ddbf46aa74e681992)

qa/workunits/rbd/rbd-nbd.sh

index 262cddb9abc4b3d5ede2e8d49505d399eefa82df..f832140837e991bf340c4ca26d6890d96243a938 100755 (executable)
@@ -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