From 59f2c3af878fff9ab7ae3ee54ec42b00f724b1a9 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Sun, 9 Mar 2025 22:10:08 +0100 Subject: [PATCH] qa/workunits/rbd: wait for resize to be applied in rbd-nbd Implement the same logic as in commit 6f3d0f570f1a ("test/librbd/fsx: wait for resize to propagate in krbd_resize()"). Fixes: https://tracker.ceph.com/issues/66419 Signed-off-by: Ilya Dryomov (cherry picked from commit bedc75fff2876d2edd4e5af2e008467fa480b4c6) --- qa/workunits/rbd/luks-encryption.sh | 16 +++++++++++++++- qa/workunits/rbd/rbd-nbd.sh | 17 ++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/qa/workunits/rbd/luks-encryption.sh b/qa/workunits/rbd/luks-encryption.sh index b6305cb46c6c9..049e4caad4761 100755 --- a/qa/workunits/rbd/luks-encryption.sh +++ b/qa/workunits/rbd/luks-encryption.sh @@ -30,6 +30,20 @@ function expect_false() { if "$@"; then return 1; else return 0; fi } +function wait_for_blockdev_size() { + local dev=$1 + local size=$2 + + for s in 0.25 0.5 0.75 1 1.25 1.5 1.75 2 2.25 2.5 2.75 3 3.25 3.5 3.75; do + if (( $(sudo blockdev --getsize64 $dev) == $size )); then + return 0 + fi + sleep $s + done + + return 1 +} + function test_encryption_format() { local format=$1 @@ -62,7 +76,7 @@ function test_encryption_format() { (( $(sudo blockdev --getsize64 $LIBRBD_DEV) < (32 << 20) )) expect_false rbd resize --size 32M testimg rbd resize --size 32M --encryption-passphrase-file /tmp/passphrase testimg - (( $(sudo blockdev --getsize64 $LIBRBD_DEV) == (32 << 20) )) + wait_for_blockdev_size $LIBRBD_DEV $((32 << 20)) _sudo rbd device unmap -t nbd $LIBRBD_DEV sudo cryptsetup close cryptsetupdev diff --git a/qa/workunits/rbd/rbd-nbd.sh b/qa/workunits/rbd/rbd-nbd.sh index 98b3aff1370d1..93cc60c2ec0f2 100755 --- a/qa/workunits/rbd/rbd-nbd.sh +++ b/qa/workunits/rbd/rbd-nbd.sh @@ -124,6 +124,20 @@ unmap_device() sleep 0.5 } +function wait_for_blockdev_size() { + local dev=$1 + local size=$2 + + for s in 0.25 0.5 0.75 1 1.25 1.5 1.75 2 2.25 2.5 2.75 3 3.25 3.5 3.75; do + if (( $(sudo blockdev --getsize64 $dev) == $size )); then + return 0 + fi + sleep $s + done + + return 1 +} + # # main # @@ -212,11 +226,12 @@ devname=$(basename ${DEV}) blocks=$(awk -v dev=${devname} '$4 == dev {print $3}' /proc/partitions) test -n "${blocks}" rbd resize ${POOL}/${IMAGE} --size $((SIZE * 2))M -rbd info ${POOL}/${IMAGE} +wait_for_blockdev_size ${DEV} $(((SIZE * 2) << 20)) blocks2=$(awk -v dev=${devname} '$4 == dev {print $3}' /proc/partitions) test -n "${blocks2}" test ${blocks2} -eq $((blocks * 2)) rbd resize ${POOL}/${IMAGE} --allow-shrink --size ${SIZE}M +wait_for_blockdev_size ${DEV} $((SIZE << 20)) blocks2=$(awk -v dev=${devname} '$4 == dev {print $3}' /proc/partitions) test -n "${blocks2}" test ${blocks2} -eq ${blocks} -- 2.39.5