]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/rbd: wait for resize to be applied in rbd-nbd 62189/head
authorIlya Dryomov <idryomov@gmail.com>
Sun, 9 Mar 2025 21:10:08 +0000 (22:10 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 9 Mar 2025 21:10:08 +0000 (22:10 +0100)
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 <idryomov@gmail.com>
qa/workunits/rbd/luks-encryption.sh
qa/workunits/rbd/rbd-nbd.sh

index b6305cb46c6c9049621cafddaa42221d02945469..049e4caad4761610473de925478d2b571632b63e 100755 (executable)
@@ -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
index 1f9acd144926ecf87aab0c8fdac8da04ab4a0bc7..d70fee9c7685e518f57a627dd07a019d52b501df 100755 (executable)
@@ -122,6 +122,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
 #
@@ -210,11 +224,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}