Skip to content

Commit

Permalink
qa/workunits/rbd: add encryption-aware resize test
Browse files Browse the repository at this point in the history
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 f737c28 ("qa/workunits/rbd: make
luks-encryption test work on vstart cluster").

Signed-off-by: Ilya Dryomov <[email protected]>
  • Loading branch information
idryomov committed Dec 4, 2022
1 parent 51d8c52 commit 8d5d478
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions qa/workunits/rbd/luks-encryption.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 8d5d478

Please sign in to comment.