1#!/bin/ksh -p 2 3# 4# CDDL HEADER START 5# 6# This file and its contents are supplied under the terms of the 7# Common Development and Distribution License ("CDDL"), version 1.0. 8# You may only use this file in accordance with the terms of version 9# 1.0 of the CDDL. 10# 11# A full copy of the text of the CDDL should have accompanied this 12# source. A copy of the CDDL is also available via the Internet at 13# http://www.illumos.org/license/CDDL. 14# 15# CDDL HEADER END 16# 17 18# 19# Copyright (c) 2019, Datto Inc. All rights reserved. 20# Copyright (c) 2020 by Lawrence Livermore National Security, LLC. 21# 22 23. $STF_SUITE/include/libtest.shlib 24. $STF_SUITE/tests/functional/redundancy/redundancy.kshlib 25 26# 27# DESCRIPTION: 28# Verify resilver to dRAID distributed spares. 29# 30# STRATEGY: 31# 1. For resilvers: 32# a. Create a semi-random dRAID pool configuration which can: 33# - sustain N failures (1-3), and 34# - has N distributed spares to replace all faulted vdevs 35# b. Fill the pool with data 36# c. Systematically fault a vdev, then replace it with a spare 37# d. Scrub the pool to verify no data was lost 38# e. Verify the contents of files in the pool 39# 40 41log_assert "Verify resilver to dRAID distributed spares" 42 43function cleanup_tunable 44{ 45 log_must set_tunable32 REBUILD_SCRUB_ENABLED 1 46 cleanup 47} 48 49log_onexit cleanup_tunable 50 51log_must set_tunable32 REBUILD_SCRUB_ENABLED 0 52 53for replace_mode in "healing" "sequential"; do 54 55 if [[ "$replace_mode" = "sequential" ]]; then 56 flags="-s" 57 else 58 flags="" 59 fi 60 61 parity=$(random_int_between 1 3) 62 spares=$(random_int_between $parity 3) 63 data=$(random_int_between 1 8) 64 65 (( min_children = (data + parity + spares) )) 66 children=$(random_int_between $min_children 16) 67 68 draid="draid${parity}:${data}d:${children}c:${spares}s" 69 70 setup_test_env $TESTPOOL $draid $children 71 72 i=0 73 while [[ $i -lt $spares ]]; do 74 fault_vdev="$BASEDIR/vdev$i" 75 spare_vdev="draid${parity}-0-${i}" 76 77 log_must zpool offline -f $TESTPOOL $fault_vdev 78 log_must check_vdev_state $TESTPOOL $fault_vdev "FAULTED" 79 log_must zpool replace -w $flags $TESTPOOL \ 80 $fault_vdev $spare_vdev 81 log_must check_vdev_state spare-$i "DEGRADED" 82 log_must check_vdev_state $spare_vdev "ONLINE" 83 log_must check_hotspare_state $TESTPOOL $spare_vdev "INUSE" 84 log_must zpool detach $TESTPOOL $fault_vdev 85 log_must verify_pool $TESTPOOL 86 log_must check_pool_status $TESTPOOL "scan" "repaired 0B" 87 log_must check_pool_status $TESTPOOL "scan" "with 0 errors" 88 89 (( i += 1 )) 90 done 91 92 log_must is_data_valid $TESTPOOL 93 log_must check_pool_status $TESTPOOL "errors" "No known data errors" 94 95 cleanup 96done 97 98log_pass "Verify resilver to dRAID distributed spares" 99