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) 2019 Datto, Inc. All rights reserved. 19# 20 21. $STF_SUITE/include/libtest.shlib 22 23# 24# DESCRIPTION: 25# Scrubs and self-healing should be able to repair data from additional 26# copies that may be stored. 27# 28# 29# STRATEGY: 30# 1. Create a dataset with copies=3 31# 2. Write a file to the dataset 32# 3. zinject errors into the first and second DVAs of that file 33# 4. Scrub and verify the scrub repaired all errors 34# 7. Read the file normally to check that self healing also works 35# 8. Remove the zinject handler 36# 9. Scrub again and confirm 0 bytes were scrubbed 37# 38 39verify_runnable "global" 40 41function cleanup 42{ 43 destroy_dataset $TESTPOOL/$TESTFS2 44 log_must zinject -c all 45} 46log_onexit cleanup 47 48log_assert "Scrubs and self healing must work with additional copies" 49 50log_must zfs create -o copies=3 $TESTPOOL/$TESTFS2 51typeset mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS2) 52log_must mkfile 10m $mntpnt/file 53log_must zpool sync $TESTPOOL 54 55log_must zinject -a -t data -C 0,1 -e io $mntpnt/file 56 57log_must zpool scrub $TESTPOOL 58log_must wait_scrubbed $TESTPOOL 59 60log_must check_pool_status $TESTPOOL "scan" "with 0 errors" 61log_must check_pool_status $TESTPOOL "errors" "No known data errors" 62 63log_must dd if=$mntpnt/file of=/dev/null bs=1M iflag=fullblock 64log_must check_pool_status $TESTPOOL "errors" "No known data errors" 65 66log_must zinject -c all 67 68log_must zpool scrub $TESTPOOL 69log_must wait_scrubbed $TESTPOOL 70 71zpool status 72 73log_must check_pool_status $TESTPOOL "errors" "No known data errors" 74log_must check_pool_status $TESTPOOL "scan" "with 0 errors" 75log_must check_pool_status $TESTPOOL "scan" "repaired 0" 76 77log_pass "Scrubs and self healing work with additional copies" 78