]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/rbd-nbd: work around "rbd feature disable" hang 49614/head
authorIlya Dryomov <idryomov@gmail.com>
Thu, 16 Feb 2023 11:53:02 +0000 (12:53 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 16 Feb 2023 12:05:05 +0000 (13:05 +0100)
"rbd feature disable" appears to reliably hang if the corresponding
remote request is proxied to rbd-nbd (because rbd-nbd happens to own
the exclusive lock after a series of blkdiscard calls) [1].  Work
around it here by enabling journaling before the image is mapped
and disabling it after the image is unmapped.

Also, don't assert on the output of "rbd journal inspect --verbose"
having a certain number of entries.  This is racy: if the script gets
delayed after the last blkdiscard call for some reason, there may be
fewer entries present in the journal or none at all.

[1] https://tracker.ceph.com/issues/58740

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
qa/workunits/rbd/rbd-nbd.sh

index 51dafd41c09c52adab2821cd614338a77eeba6b2..54b22d846a63307a0ab19cc0d487250a5a7e325f 100755 (executable)
@@ -443,10 +443,10 @@ expect_false get_pid ${POOL}
 DEV=
 
 # test discard granularity with journaling
-DEV=`_sudo rbd device --device-type nbd map ${POOL}/${IMAGE}`
-get_pid ${POOL}
 rbd config image set ${POOL}/${IMAGE} rbd_discard_granularity_bytes 4096
 rbd feature enable ${POOL}/${IMAGE} journaling
+DEV=`_sudo rbd device --device-type nbd map ${POOL}/${IMAGE}`
+get_pid ${POOL}
 # since a discard will now be pruned to only whole blocks (0..4095, 4096..8191)
 # let us test all the cases around those alignments. 512 is the smallest
 # possible block blkdiscard allows us to use. Thus the test checks
@@ -457,34 +457,6 @@ _sudo blkdiscard --offset 0 --length $((4096+512)) ${DEV}
 _sudo blkdiscard --offset 512 --length $((8192-1024)) ${DEV}
 _sudo blkdiscard --offset 512 --length $((8192-512)) ${DEV}
 _sudo blkdiscard --offset 512 --length 8192 ${DEV}
-expected='Entry: tag_id=1, commit_tid=1
-{
-    "event_type": "AioDiscard",
-    "offset": 0,
-    "length": 4096,
-    "discard_granularity_bytes": 4096,
-Entry: tag_id=1, commit_tid=2
-{
-    "event_type": "AioDiscard",
-    "offset": 0,
-    "length": 4096,
-    "discard_granularity_bytes": 4096,
-Entry: tag_id=1, commit_tid=3
-{
-    "event_type": "AioDiscard",
-    "offset": 4096,
-    "length": 4096,
-    "discard_granularity_bytes": 4096,
-Entry: tag_id=1, commit_tid=4
-{
-    "event_type": "AioDiscard",
-    "offset": 4096,
-    "length": 4096,
-    "discard_granularity_bytes": 4096,'
-out=`rbd journal inspect --pool ${POOL} --image ${IMAGE} --verbose | \
-    grep -A5 --no-group-separator Entry`
-rbd config image rm ${POOL}/${IMAGE} rbd_discard_granularity_bytes
-[ "${out}" == "${expected}" ]
 # wait for commit log to be empty, 10 seconds should be well enough
 tries=0
 queue_length=`rbd journal inspect --pool ${POOL} --image ${IMAGE} | awk '/entries inspected/ {print $1}'`
@@ -494,9 +466,10 @@ while [ ${tries} -lt 10 ] && [ ${queue_length} -gt 0 ]; do
     queue_length=`rbd journal inspect --pool ${POOL} --image ${IMAGE} | awk '/entries inspected/ {print $1}'`
     tries=$((tries+1))
 done
-rbd feature disable ${POOL}/${IMAGE} journaling
 [ ${queue_length} -eq 0 ]
 unmap_device ${DEV} ${PID}
 DEV=
+rbd feature disable ${POOL}/${IMAGE} journaling
+rbd config image rm ${POOL}/${IMAGE} rbd_discard_granularity_bytes
 
 echo OK