From 8d5d478532ade6f908f8117955ad74f0fa55f00e Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Sat, 3 Dec 2022 15:37:14 +0100 Subject: [PATCH] qa/workunits/rbd: add encryption-aware resize test Note that we are hitting https://tracker.ceph.com/issues/58160 here because by the time we get to "rbd resize" RAW_DEV mapping owns the lock (due to a write to /dev/mapper/cryptsetupdev being last). While at it, resurrect the ability to easily run this script on vstart clusters -- see commit f737c2855a19 ("qa/workunits/rbd: make luks-encryption test work on vstart cluster"). Signed-off-by: Ilya Dryomov --- qa/workunits/rbd/luks-encryption.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/qa/workunits/rbd/luks-encryption.sh b/qa/workunits/rbd/luks-encryption.sh index b85bb0e546a33..5d3cc68cdf34b 100755 --- a/qa/workunits/rbd/luks-encryption.sh +++ b/qa/workunits/rbd/luks-encryption.sh @@ -56,7 +56,18 @@ function test_encryption_format() { dd if=$LIBRBD_DEV of=/tmp/cmpdata iflag=direct bs=4M count=4 cmp -n 16MB /tmp/cmpdata /tmp/testdata2 - sudo rbd device unmap -t nbd $LIBRBD_DEV + # FIXME: encryption-aware flatten/resize misbehave if proxied to + # RAW_DEV mapping (i.e. if RAW_DEV mapping ows the lock) + # (acquire and) release the lock as a side effect + rbd bench --io-type read --io-size 1 --io-threads 1 --io-total 1 testimg + + # check that encryption-aware resize compensates LUKS header overhead + (( $(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) )) + + _sudo rbd device unmap -t nbd $LIBRBD_DEV } function test_clone_encryption() { @@ -77,7 +88,7 @@ function test_clone_encryption() { dd if=$LIBRBD_DEV of=/tmp/cmpdata iflag=direct bs=1M count=1 cmp -n 1MB /tmp/cmpdata /tmp/testdata1 dd if=/tmp/testdata1 of=$LIBRBD_DEV seek=1 skip=1 oflag=direct bs=1M count=1 - sudo rbd device unmap -t nbd $LIBRBD_DEV + _sudo rbd device unmap -t nbd $LIBRBD_DEV # second clone (luks2) rbd snap create testimg1@snap @@ -91,7 +102,7 @@ function test_clone_encryption() { dd if=$LIBRBD_DEV of=/tmp/cmpdata iflag=direct bs=1M count=2 cmp -n 2MB /tmp/cmpdata /tmp/testdata1 dd if=/tmp/testdata1 of=$LIBRBD_DEV seek=2 skip=2 oflag=direct bs=1M count=1 - sudo rbd device unmap -t nbd $LIBRBD_DEV + _sudo rbd device unmap -t nbd $LIBRBD_DEV # flatten expect_false rbd flatten testimg2 --encryption-format luks1 --encryption-format luks2 --encryption-passphrase-file /tmp/passphrase2 --encryption-passphrase-file /tmp/passphrase @@ -103,7 +114,7 @@ function test_clone_encryption() { sudo chmod 666 /dev/mapper/cryptsetupdev dd if=/dev/mapper/cryptsetupdev of=/tmp/cmpdata iflag=direct bs=1M count=3 cmp -n 3MB /tmp/cmpdata /tmp/testdata1 - sudo rbd device unmap -t nbd $RAW_FLAT_DEV + _sudo rbd device unmap -t nbd $RAW_FLAT_DEV } function test_clone_and_load_with_a_single_passphrase {