btrfs/012: add a regression test for deleting ext2_saved
authorLiu Bo <bo.li.liu@oracle.com>
Mon, 2 Nov 2015 00:00:48 +0000 (11:00 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 2 Nov 2015 00:00:48 +0000 (11:00 +1100)
Btrfs now has changed to delete subvolume/snapshot asynchronously,
which means that after umount, if we've already deleted 'ext2_saved',
rollback can still be completed, which should not.

So this adds a regression test for this.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
tests/btrfs/012

index d5137595949c9c93c1289ff767be2519351cd83a..b39dec0c755468c316d26ade10b01c94d4a3b506 100755 (executable)
@@ -112,6 +112,18 @@ diff -r /lib/modules/`uname -r`/ $SCRATCH_MNT/`uname -r`/ 2>&1 | grep -vw "sourc
 
 _scratch_unmount
 
+# Convert it to btrfs, mount it and delete "ext2_saved"
+$BTRFS_CONVERT_PROG $SCRATCH_DEV >> $seqres.full 2>&1 || \
+       _fail "btrfs-convert failed"
+_scratch_mount || _fail "Could not mount new btrfs fs"
+$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/ext2_saved >> $seqres.full 2>&1 ||
+       _fail "failed to delete ext2_saved subvolume"
+_scratch_unmount
+
+# Now restore the ext4 device, expecting a failure
+$BTRFS_CONVERT_PROG -r $SCRATCH_DEV >> $seqres.full 2>&1
+[ $? -eq 1 ] || _fail "Failure is expected, but btrfs-convert returns with rollback complete"
+
 # success, all done
 status=0
 exit