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) 2021 by Lawrence Livermore National Security, LLC. 25# 26 27. $STF_SUITE/include/libtest.shlib 28. $STF_SUITE/tests/functional/redundancy/redundancy.kshlib 29 30# 31# DESCRIPTION: 32# When sequentially resilvering a dRAID pool with multiple vdevs 33# that contain silent damage a sequential resilver should never 34# introduce additional unrecoverable damage. 35# 36# STRATEGY: 37# 1. Create block device files for the test draid pool 38# 2. For each parity value [1..3] 39# - create draid pool 40# - fill it with some directories/files 41# - overwrite the maximum number of repairable devices 42# - sequentially resilver each overwritten device one at a time; 43# the device will not be correctly repaired because the silent 44# damage on the other vdevs will cause the parity calculations 45# to generate incorrect data for the resilvering vdev. 46# - verify that only the resilvering devices had invalid data 47# written and that a scrub is still able to repair the pool 48# - destroy the draid pool 49# 50 51typeset -r devs=7 52typeset -r dev_size_mb=512 53 54typeset -a disks 55 56prefetch_disable=$(get_tunable PREFETCH_DISABLE) 57rebuild_scrub_enabled=$(get_tunable REBUILD_SCRUB_ENABLED) 58 59function cleanup 60{ 61 poolexists "$TESTPOOL" && destroy_pool "$TESTPOOL" 62 63 for i in {0..$devs}; do 64 rm -f "$TEST_BASE_DIR/dev-$i" 65 done 66 67 set_tunable32 PREFETCH_DISABLE $prefetch_disable 68 set_tunable32 REBUILD_SCRUB_ENABLED $rebuild_scrub_enabled 69} 70 71function test_sequential_resilver # <pool> <parity> <dir> 72{ 73 typeset pool=$1 74 typeset nparity=$2 75 typeset dir=$3 76 77 log_must zpool export $pool 78 79 for (( i=0; i<$nparity; i=i+1 )); do 80 log_must dd conv=notrunc if=/dev/zero of=$dir/dev-$i \ 81 bs=1M seek=4 count=$(($dev_size_mb-4)) 82 done 83 84 log_must zpool import -o cachefile=none -d $dir $pool 85 86 for (( i=0; i<$nparity; i=i+1 )); do 87 spare=draid${nparity}-0-$i 88 log_must zpool replace -fsw $pool $dir/dev-$i $spare 89 done 90 91 log_must zpool scrub -w $pool 92 log_must zpool status $pool 93 94 log_mustnot check_pool_status $pool "scan" "repaired 0B" 95 log_must check_pool_status $pool "errors" "No known data errors" 96 log_must check_pool_status $pool "scan" "with 0 errors" 97} 98 99log_onexit cleanup 100 101log_must set_tunable32 PREFETCH_DISABLE 1 102log_must set_tunable32 REBUILD_SCRUB_ENABLED 0 103 104# Disk files which will be used by pool 105for i in {0..$(($devs - 1))}; do 106 device=$TEST_BASE_DIR/dev-$i 107 log_must truncate -s ${dev_size_mb}M $device 108 disks[${#disks[*]}+1]=$device 109done 110 111# Disk file which will be attached 112log_must truncate -s 512M $TEST_BASE_DIR/dev-$devs 113 114for nparity in 1 2 3; do 115 raid=draid${nparity}:${nparity}s 116 dir=$TEST_BASE_DIR 117 118 log_must zpool create -O compression=off -f -o cachefile=none $TESTPOOL $raid ${disks[@]} 119 log_must zfs set primarycache=metadata $TESTPOOL 120 121 log_must zfs create $TESTPOOL/fs 122 log_must fill_fs /$TESTPOOL/fs 1 512 100 1024 R 123 124 log_must zfs create -o compress=on $TESTPOOL/fs2 125 log_must fill_fs /$TESTPOOL/fs2 1 512 100 1024 R 126 127 log_must zfs create -o compress=on -o recordsize=8k $TESTPOOL/fs3 128 log_must fill_fs /$TESTPOOL/fs3 1 512 100 1024 R 129 130 log_must zpool export $TESTPOOL 131 log_must zpool import -o cachefile=none -d $dir $TESTPOOL 132 133 log_must check_pool_status $TESTPOOL "errors" "No known data errors" 134 135 test_sequential_resilver $TESTPOOL $nparity $dir 136 137 log_must zpool destroy "$TESTPOOL" 138done 139 140log_pass "draid damaged device(s) test succeeded." 141