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) 2020 by Lawrence Livermore National Security, LLC.
20#
21
22. $STF_SUITE/include/libtest.shlib
23. $STF_SUITE/tests/functional/redundancy/redundancy.kshlib
24
25#
26# DESCRIPTION:
27# Verify multiple dRAID spares can be used.
28#
29# STRATEGY:
30# 1. Create a pool and fill it with data.
31# 2. Engage 3 distributed spares and verify the pool
32# 3. Refill the filesystem with new data
33# 4. Clear the pool to online previous faulted devices and resilver
34# 5. Verify the pool and its contents
35#
36
37log_assert "Verify multiple dRAID spares"
38
39log_onexit cleanup
40
41parity=1
42spares=3
43data=$(random_int_between 1 4)
44children=10
45draid="draid${parity}:${data}d:${children}c:${spares}s"
46
47setup_test_env $TESTPOOL $draid $children
48
49# Replace vdev7 -> draid1-0-0
50log_must zpool offline -f $TESTPOOL $BASEDIR/vdev7
51log_must zpool replace -w $TESTPOOL $BASEDIR/vdev7 draid1-0-0
52
53# Replace vdev8 -> draid1-0-1
54log_must zpool offline -f $TESTPOOL $BASEDIR/vdev8
55log_must zpool replace -w $TESTPOOL $BASEDIR/vdev8 draid1-0-1
56
57# Replace vdev9 -> draid1-0-2
58log_must zpool offline -f $TESTPOOL $BASEDIR/vdev9
59log_must zpool replace -w $TESTPOOL $BASEDIR/vdev9 draid1-0-2
60
61# Verify, refill and verify the pool contents.
62verify_pool $TESTPOOL
63refill_test_env $TESTPOOL
64verify_pool $TESTPOOL
65
66# Bring everything back online and check for errors.
67log_must zpool clear $TESTPOOL
68log_must zpool wait -t resilver $TESTPOOL
69
70log_must wait_hotspare_state $TESTPOOL draid1-0-0 "AVAIL"
71log_must wait_hotspare_state $TESTPOOL draid1-0-1 "AVAIL"
72log_must wait_hotspare_state $TESTPOOL draid1-0-2 "AVAIL"
73
74log_must zpool scrub -w $TESTPOOL
75log_must check_pool_status $TESTPOOL "scan" "repaired 0B"
76log_must check_pool_status $TESTPOOL "scan" "with 0 errors"
77
78log_must is_data_valid $TESTPOOL
79
80log_pass "Verify multiple dRAID spares"
81