112a8814cSTom Caputi#!/bin/ksh -p 212a8814cSTom Caputi# 312a8814cSTom Caputi# CDDL HEADER START 412a8814cSTom Caputi# 512a8814cSTom Caputi# This file and its contents are supplied under the terms of the 612a8814cSTom Caputi# Common Development and Distribution License ("CDDL"), version 1.0. 712a8814cSTom Caputi# You may only use this file in accordance with the terms of version 812a8814cSTom Caputi# 1.0 of the CDDL. 912a8814cSTom Caputi# 1012a8814cSTom Caputi# A full copy of the text of the CDDL should have accompanied this 1112a8814cSTom Caputi# source. A copy of the CDDL is also available via the Internet at 1212a8814cSTom Caputi# http://www.illumos.org/license/CDDL. 1312a8814cSTom Caputi# 1412a8814cSTom Caputi# CDDL HEADER END 1512a8814cSTom Caputi# 1612a8814cSTom Caputi 1712a8814cSTom Caputi# 1812a8814cSTom Caputi# Copyright (c) 2019 Datto, Inc. All rights reserved. 1912a8814cSTom Caputi# 2012a8814cSTom Caputi 2112a8814cSTom Caputi. $STF_SUITE/include/libtest.shlib 2212a8814cSTom Caputi 2312a8814cSTom Caputi# 2412a8814cSTom Caputi# DESCRIPTION: 2512a8814cSTom Caputi# Scrubs and self-healing should be able to repair data from additional 2612a8814cSTom Caputi# copies that may be stored. 2712a8814cSTom Caputi# 2812a8814cSTom Caputi# 2912a8814cSTom Caputi# STRATEGY: 3012a8814cSTom Caputi# 1. Create a dataset with copies=3 3112a8814cSTom Caputi# 2. Write a file to the dataset 3212a8814cSTom Caputi# 3. zinject errors into the first and second DVAs of that file 3312a8814cSTom Caputi# 4. Scrub and verify the scrub repaired all errors 3412a8814cSTom Caputi# 7. Read the file normally to check that self healing also works 3512a8814cSTom Caputi# 8. Remove the zinject handler 3612a8814cSTom Caputi# 9. Scrub again and confirm 0 bytes were scrubbed 3712a8814cSTom Caputi# 3812a8814cSTom Caputi 3912a8814cSTom Caputiverify_runnable "global" 4012a8814cSTom Caputi 4112a8814cSTom Caputifunction cleanup 4212a8814cSTom Caputi{ 4312a8814cSTom Caputi destroy_dataset $TESTPOOL/$TESTFS2 4412a8814cSTom Caputi log_must zinject -c all 4512a8814cSTom Caputi} 4612a8814cSTom Caputilog_onexit cleanup 4712a8814cSTom Caputi 4812a8814cSTom Caputilog_assert "Scrubs and self healing must work with additional copies" 4912a8814cSTom Caputi 5012a8814cSTom Caputilog_must zfs create -o copies=3 $TESTPOOL/$TESTFS2 5112a8814cSTom Caputitypeset mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS2) 5212a8814cSTom Caputilog_must mkfile 10m $mntpnt/file 53*09fbbb7dSAllan Judesync_pool $TESTPOOL 5412a8814cSTom Caputi 5512a8814cSTom Caputilog_must zinject -a -t data -C 0,1 -e io $mntpnt/file 5612a8814cSTom Caputi 5712a8814cSTom Caputilog_must zpool scrub $TESTPOOL 5812a8814cSTom Caputilog_must wait_scrubbed $TESTPOOL 5912a8814cSTom Caputi 6012a8814cSTom Caputilog_must check_pool_status $TESTPOOL "scan" "with 0 errors" 6112a8814cSTom Caputilog_must check_pool_status $TESTPOOL "errors" "No known data errors" 6212a8814cSTom Caputi 6312a8814cSTom Caputilog_must dd if=$mntpnt/file of=/dev/null bs=1M iflag=fullblock 6412a8814cSTom Caputilog_must check_pool_status $TESTPOOL "errors" "No known data errors" 6512a8814cSTom Caputi 6612a8814cSTom Caputilog_must zinject -c all 6712a8814cSTom Caputi 6812a8814cSTom Caputilog_must zpool scrub $TESTPOOL 6912a8814cSTom Caputilog_must wait_scrubbed $TESTPOOL 7012a8814cSTom Caputi 7112a8814cSTom Caputizpool status 7212a8814cSTom Caputi 7312a8814cSTom Caputilog_must check_pool_status $TESTPOOL "errors" "No known data errors" 7412a8814cSTom Caputilog_must check_pool_status $TESTPOOL "scan" "with 0 errors" 7512a8814cSTom Caputilog_must check_pool_status $TESTPOOL "scan" "repaired 0" 7612a8814cSTom Caputi 7712a8814cSTom Caputilog_pass "Scrubs and self healing work with additional copies" 78