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