1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or https://opensource.org/licenses/CDDL-1.0. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright (c) 2022 George Amanakis. All rights reserved. 25# 26 27. $STF_SUITE/include/libtest.shlib 28# 29# DESCRIPTION: 30# Verify correct output with 'zpool status -v' after corrupting a file 31# 32# STRATEGY: 33# 1. Create a pool, an ancrypted filesystem and a file 34# 2. zinject checksum errors 35# 3. Unmount the filesystem and unload the key 36# 4. Scrub the pool 37# 5. Verify we report errors in the pool in 'zpool status -v' 38 39verify_runnable "both" 40 41DISK=${DISKS%% *} 42 43function cleanup 44{ 45 log_must zinject -c all 46 destroy_pool $TESTPOOL2 47 rm -f $TESTDIR/vdev_a 48} 49 50log_assert "Verify reporting errors with unloaded keys works" 51log_onexit cleanup 52 53typeset passphrase="password" 54typeset file="/$TESTPOOL2/$TESTFS1/$TESTFILE0" 55 56truncate -s $MINVDEVSIZE $TESTDIR/vdev_a 57log_must zpool create -f -o feature@head_errlog=enabled $TESTPOOL2 $TESTDIR/vdev_a 58 59log_must eval "echo $passphrase > /$TESTPOOL2/pwd" 60 61log_must zfs create -o encryption=aes-256-ccm -o keyformat=passphrase \ 62 -o keylocation=file:///$TESTPOOL2/pwd -o primarycache=none \ 63 $TESTPOOL2/$TESTFS1 64 65log_must dd if=/dev/urandom of=$file bs=1024 count=1024 oflag=sync 66log_must eval "echo 'aaaaaaaa' >> "$file 67 68corrupt_blocks_at_level $file 0 69log_must zfs unmount $TESTPOOL2/$TESTFS1 70log_must zfs unload-key $TESTPOOL2/$TESTFS1 71log_must zpool sync $TESTPOOL2 72log_must zpool scrub $TESTPOOL2 73log_must zpool wait -t scrub $TESTPOOL2 74log_must zpool status -v $TESTPOOL2 75log_must eval "zpool status -v $TESTPOOL2 | \ 76 grep \"Permanent errors have been detected\"" 77 78log_pass "Verify reporting errors with unloaded keys works" 79