From fcfef0a19e1d85a8b9414909268f1370ec82808d Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Thu, 16 Feb 2023 12:53:02 +0100 Subject: [PATCH] qa/workunits/rbd-nbd: work around "rbd feature disable" hang "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 --- qa/workunits/rbd/rbd-nbd.sh | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/qa/workunits/rbd/rbd-nbd.sh b/qa/workunits/rbd/rbd-nbd.sh index 51dafd41c09c5..54b22d846a633 100755 --- a/qa/workunits/rbd/rbd-nbd.sh +++ b/qa/workunits/rbd/rbd-nbd.sh @@ -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 -- 2.39.5