1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9# 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14# CDDL HEADER END 15# 16 17# 18# Copyright (c) 2017 Datto, Inc. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22 23# 24# DESCRIPTION: 25# 'zpool import' should import a pool with Errata #3 while preventing 26# the user from performing read write operations 27# 28# STRATEGY: 29# 1. Import a pre-packaged pool with Errata #3 30# 2. Attempt to write to the effected datasets 31# 3. Attempt to read from the effected datasets 32# 4. Attempt to perform a raw send of the effected datasets 33# 5. Perform a regular send of the datasets under a new encryption root 34# 6. Verify the new datasets can be read from and written to 35# 7. Destroy the old effected datasets 36# 8. Reimport the pool and verify that the errata is no longer present 37# 38 39verify_runnable "global" 40 41POOL_NAME=cryptv0 42POOL_FILE=cryptv0.dat 43 44function uncompress_pool 45{ 46 log_note "Creating pool from $POOL_FILE" 47 log_must eval bzcat \ 48 $STF_SUITE/tests/functional/cli_root/zpool_import/blockfiles/$POOL_FILE.bz2 \ 49 "> /$TESTPOOL/$POOL_FILE" 50} 51 52function cleanup 53{ 54 poolexists $POOL_NAME && log_must zpool destroy $POOL_NAME 55 log_must rm -f /$TESTPOOL/$POOL_FILE 56} 57log_onexit cleanup 58 59log_assert "Verify that Errata 3 is properly handled" 60 61uncompress_pool 62log_must zpool import -d /$TESTPOOL/ $POOL_NAME 63log_must eval "zpool status $POOL_NAME | grep -q Errata" # also detects 'Errata #4' 64log_must eval "zpool status $POOL_NAME | grep -q ZFS-8000-ER" 65log_must eval "echo 'password' | zfs load-key $POOL_NAME/testfs" 66log_must eval "echo 'password' | zfs load-key $POOL_NAME/testvol" 67 68log_mustnot zfs mount $POOL_NAME/testfs 69log_must zfs mount -o ro $POOL_NAME/testfs 70 71old_mntpnt=$(get_prop mountpoint $POOL_NAME/testfs) 72log_must eval "ls $old_mntpnt | grep -q testfile" 73block_device_wait /dev/zvol/$POOL_NAME/testvol 74log_mustnot dd if=/dev/zero of=/dev/zvol/$POOL_NAME/testvol bs=512 count=1 75log_must dd if=/dev/zvol/$POOL_NAME/testvol of=/dev/null bs=512 count=1 76 77log_must zpool set feature@bookmark_v2=enabled $POOL_NAME # necessary for Errata #4 78 79log_must eval "echo 'password' | zfs create \ 80 -o encryption=on -o keyformat=passphrase -o keylocation=prompt \ 81 $POOL_NAME/encroot" 82log_mustnot eval "zfs send -w $POOL_NAME/testfs@snap1 | \ 83 zfs recv $POOL_NAME/encroot/testfs" 84log_mustnot eval "zfs send -w $POOL_NAME/testvol@snap1 | \ 85 zfs recv $POOL_NAME/encroot/testvol" 86 87log_must eval "zfs send $POOL_NAME/testfs@snap1 | \ 88 zfs recv $POOL_NAME/encroot/testfs" 89log_must eval "zfs send $POOL_NAME/testvol@snap1 | \ 90 zfs recv $POOL_NAME/encroot/testvol" 91block_device_wait /dev/zvol/$POOL_NAME/encroot/testvol 92log_must dd if=/dev/zero of=/dev/zvol/$POOL_NAME/encroot/testvol bs=512 count=1 93new_mntpnt=$(get_prop mountpoint $POOL_NAME/encroot/testfs) 94log_must eval "ls $new_mntpnt | grep -q testfile" 95log_must zfs destroy -r $POOL_NAME/testfs 96log_must zfs destroy -r $POOL_NAME/testvol 97 98log_must zpool export $POOL_NAME 99log_must zpool import -d /$TESTPOOL/ $POOL_NAME 100log_mustnot eval "zpool status $POOL_NAME | grep -q 'Errata #3'" 101log_pass "Errata 3 is properly handled" 102