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
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.
19 # Copyright (c) 2017 by Intel Corporation. All rights reserved.
20 # Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
23 . $STF_SUITE/include/libtest.shlib
24 . $STF_SUITE/include/math.shlib
25 . $STF_SUITE/tests/functional/fault/fault.cfg
29 # Testing Fault Management Agent ZED Logic - Automated Auto-Spare Test when
30 # drive is faulted and a custom ashift value needs to be provided to replace it.
33 # 1. Create a pool from 512b devices and set "ashift" pool property accordingly
34 # 2. Add one 512e spare device (4Kn would generate IO errors on replace)
35 # 3. Inject IO errors with a zinject error handler
37 # 5. Verify the ZED kicks in the hot spare and expected pool/device status
39 # 7. Verify the hot spare is available and expected pool/device status
42 verify_runnable "both"
46 log_must zinject -c all
47 destroy_pool $TESTPOOL
49 rm -f $SAFE_DEVICE $FAIL_DEVICE
52 log_assert "ZED should replace a device using the configured ashift property"
55 # Clear events from previous runs
58 SAFE_DEVICE="$TEST_BASE_DIR/safe-dev"
59 FAIL_DEVICE="$TEST_BASE_DIR/fail-dev"
61 # 1. Create a pool from 512b devices and set "ashift" pool property accordingly
62 for vdev in $SAFE_DEVICE $FAIL_DEVICE; do
63 truncate -s $SPA_MINDEVSIZE $vdev
65 log_must zpool create -f $TESTPOOL mirror $SAFE_DEVICE $FAIL_DEVICE
66 # NOTE: file VDEVs should be added as 512b devices, verify this "just in case"
67 for vdev in $SAFE_DEVICE $FAIL_DEVICE; do
68 verify_eq "9" "$(zdb -e -l $vdev | awk '/ashift: /{print $2}')" "ashift"
70 log_must zpool set ashift=9 $TESTPOOL
72 # 2. Add one 512e spare device (4Kn would generate IO errors on replace)
73 # NOTE: must be larger than the existing 512b devices, add 32m of fudge
74 load_scsi_debug $(($SPA_MINDEVSIZE/1024/1024+32)) $SDHOSTS $SDTGTS $SDLUNS '512e'
75 SPARE_DEVICE=$(get_debug_device)
76 log_must_busy zpool add $TESTPOOL spare $SPARE_DEVICE
78 # 3. Inject IO errors with a zinject error handler
79 log_must zinject -d $FAIL_DEVICE -e io -T all -f 100 $TESTPOOL
82 log_must zpool scrub $TESTPOOL
84 # 5. Verify the ZED kicks in a hot spare and expected pool/device status
85 log_note "Wait for ZED to auto-spare"
86 log_must wait_vdev_state $TESTPOOL $FAIL_DEVICE "FAULTED" 60
87 log_must wait_vdev_state $TESTPOOL $SPARE_DEVICE "ONLINE" 60
88 log_must wait_hotspare_state $TESTPOOL $SPARE_DEVICE "INUSE"
89 log_must check_state $TESTPOOL "" "DEGRADED"
92 log_must zinject -c all
93 log_must zpool clear $TESTPOOL $FAIL_DEVICE
95 # 7. Verify the hot spare is available and expected pool/device status
96 log_must wait_vdev_state $TESTPOOL $FAIL_DEVICE "ONLINE" 60
97 log_must wait_hotspare_state $TESTPOOL $SPARE_DEVICE "AVAIL"
98 log_must is_pool_resilvered $TESTPOOL
99 log_must check_state $TESTPOOL "" "ONLINE"
101 log_pass "ZED successfully replaces a device using the configured ashift property"