22set -ex
33
44CEPH_ID=${CEPH_ID:- admin}
5- TMP_FILES=" /tmp/passphrase /tmp/passphrase2 /tmp/testdata1 /tmp/testdata2 /tmp/cmpdata /tmp/rawexport /tmp/export.qcow2"
5+ TMP_FILES=" /tmp/passphrase /tmp/passphrase1 /tmp/ passphrase2 /tmp/testdata1 /tmp/testdata2 /tmp/cmpdata /tmp/rawexport /tmp/export.qcow2"
66
77_sudo ()
88{
@@ -278,8 +278,7 @@ function test_migration_clone() {
278278 rbd migration prepare testimg1 testimg2
279279
280280 # test reading
281- # FIXME: https://tracker.ceph.com/issues/63184
282- LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase)
281+ LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase)
283282 cmp $LIBRBD_DEV /tmp/cmpdata
284283
285284 # trigger copyup for an unwritten area
@@ -297,8 +296,7 @@ function test_migration_clone() {
297296 _sudo rbd device unmap -t nbd $LIBRBD_DEV
298297
299298 # test reading on a fresh mapping
300- # FIXME: https://tracker.ceph.com/issues/63184
301- LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase)
299+ LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase)
302300 cmp $LIBRBD_DEV /tmp/cmpdata
303301 _sudo rbd device unmap -t nbd $LIBRBD_DEV
304302
@@ -320,6 +318,85 @@ function test_migration_clone() {
320318 rbd rm testimg
321319}
322320
321+ function test_migration_open_clone_chain() {
322+ rbd create --size 32M testimg
323+ rbd encryption format testimg luks1 /tmp/passphrase
324+ rbd snap create testimg@snap
325+ rbd snap protect testimg@snap
326+
327+ rbd clone testimg@snap testimg1
328+ rbd encryption format testimg1 luks2 /tmp/passphrase1
329+ rbd snap create testimg1@snap
330+ rbd snap protect testimg1@snap
331+
332+ rbd clone testimg1@snap testimg2
333+ rbd encryption format testimg2 luks1 /tmp/passphrase2
334+
335+ # 1. X <-- X <-- X
336+ LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase1,encryption-passphrase-file=/tmp/passphrase)
337+ _sudo rbd device unmap -t nbd $LIBRBD_DEV
338+
339+ # 2. X <-- X <-- migrating
340+ rbd migration prepare testimg2 testimg2
341+ LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase1,encryption-passphrase-file=/tmp/passphrase)
342+ _sudo rbd device unmap -t nbd $LIBRBD_DEV
343+ rbd migration abort testimg2
344+
345+ # 3. X <-- migrating <-- X
346+ rbd migration prepare testimg1 testimg1
347+ LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase1,encryption-passphrase-file=/tmp/passphrase)
348+ _sudo rbd device unmap -t nbd $LIBRBD_DEV
349+ rbd migration abort testimg1
350+
351+ # 4. migrating <-- X <-- X
352+ rbd migration prepare testimg testimg
353+ LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase1,encryption-passphrase-file=/tmp/passphrase)
354+ _sudo rbd device unmap -t nbd $LIBRBD_DEV
355+ rbd migration abort testimg
356+
357+ # 5. migrating <-- migrating <-- X
358+ rbd migration prepare testimg testimg
359+ rbd migration prepare testimg1 testimg1
360+ LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase1,encryption-passphrase-file=/tmp/passphrase)
361+ _sudo rbd device unmap -t nbd $LIBRBD_DEV
362+ rbd migration abort testimg1
363+ rbd migration abort testimg
364+
365+ # 6. migrating <-- X <-- migrating
366+ rbd migration prepare testimg testimg
367+ rbd migration prepare testimg2 testimg2
368+ LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase1,encryption-passphrase-file=/tmp/passphrase)
369+ _sudo rbd device unmap -t nbd $LIBRBD_DEV
370+ rbd migration abort testimg2
371+ rbd migration abort testimg
372+
373+ # 7. X <-- migrating <-- migrating
374+ rbd migration prepare testimg1 testimg1
375+ rbd migration prepare testimg2 testimg2
376+ LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase1,encryption-passphrase-file=/tmp/passphrase)
377+ _sudo rbd device unmap -t nbd $LIBRBD_DEV
378+ rbd migration abort testimg2
379+ rbd migration abort testimg1
380+
381+ # 8. migrating <-- migrating <-- migrating
382+ rbd migration prepare testimg testimg
383+ rbd migration prepare testimg1 testimg1
384+ rbd migration prepare testimg2 testimg2
385+ LIBRBD_DEV=$( _sudo rbd -p rbd map testimg2 -t nbd -o encryption-passphrase-file=/tmp/passphrase2,encryption-passphrase-file=/tmp/passphrase1,encryption-passphrase-file=/tmp/passphrase)
386+ _sudo rbd device unmap -t nbd $LIBRBD_DEV
387+
388+ rbd migration abort testimg2
389+ rbd rm testimg2
390+ rbd migration abort testimg1
391+ rbd snap unprotect testimg1@snap
392+ rbd snap rm testimg1@snap
393+ rbd rm testimg1
394+ rbd migration abort testimg
395+ rbd snap unprotect testimg@snap
396+ rbd snap rm testimg@snap
397+ rbd rm testimg
398+ }
399+
323400function get_nbd_device_paths {
324401 rbd device list -t nbd | tail -n +2 | egrep " \s+rbd\s+testimg" | awk ' {print $5;}'
325402}
@@ -343,6 +420,7 @@ function clean_up {
343420 rbd snap unprotect testimg1@snap || true
344421 rbd snap remove testimg1@snap || true
345422 rbd remove testimg1 || true
423+ rbd migration abort testimg || true
346424 rbd snap remove testimg@snap2 || true
347425 rbd snap remove testimg@snap1 || true
348426 rbd snap unprotect testimg@snap || true
@@ -371,6 +449,7 @@ dd if=/dev/urandom of=/tmp/testdata2 bs=4M count=4
371449
372450# create passphrase files
373451printf " pass\0word\n" > /tmp/passphrase
452+ printf " passwo\nrd 1,1" > /tmp/passphrase1
374453printf " \t password2 " > /tmp/passphrase2
375454
376455# create an image
@@ -401,4 +480,6 @@ test_migration_clone luks1
401480rbd create --size 48M testimg
402481test_migration_clone luks2
403482
483+ test_migration_open_clone_chain
484+
404485echo OK
0 commit comments