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.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
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]
24 # Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
27 .
$STF_SUITE/include
/libtest.shlib
28 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_reopen
/zpool_reopen.shlib
29 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_scrub
/zpool_scrub.cfg
33 # Scrubbing a pool with offline devices correctly preserves DTL entries
37 # 2. Offline the first device
38 # 3. Write to the pool
40 # 5. Online the first device and offline the second device
41 # 6. Scrub the pool again
42 # 7. Verify data integrity
45 # Ported from script used to reproduce issue #5806
48 verify_runnable
"global"
52 poolexists
$TESTPOOL2 && destroy_pool
$TESTPOOL2
53 log_must
rm -f $DISK1 $DISK2 $DISK3 $DISK4
57 # Update to [online|offline] $device status on $pool synchronously
59 function zpool_do_sync
# <status> <pool> <device>
65 if [[ $status != "online" && $status != "offline" ]]; then
66 log_fail
"zpool_do_sync: invalid status $status"
69 log_must zpool
$status $pool $device
71 check_state
$pool $device $status && return 0
73 log_fail
"Failed to $status device $device"
77 # Start a scrub on $pool and wait for its completion
79 function zpool_scrub_sync
# <pool>
83 log_must zpool scrub
$pool
84 while ! is_pool_scrubbed
$pool; do
89 log_assert
"Scrubbing a pool with offline devices correctly preserves DTLs"
94 TESTDIR
="$TEST_BASE_DIR/zpool_scrub_offline_device"
95 DISK1
="$TEST_BASE_DIR/zpool_disk1.dat"
96 DISK2
="$TEST_BASE_DIR/zpool_disk2.dat"
97 DISK3
="$TEST_BASE_DIR/zpool_disk3.dat"
98 DISK4
="$TEST_BASE_DIR/zpool_disk4.dat"
102 log_must truncate
-s $DEVSIZE $DISK1
103 log_must truncate
-s $DEVSIZE $DISK2
104 log_must truncate
-s $DEVSIZE $DISK3
105 log_must truncate
-s $DEVSIZE $DISK4
106 poolexists
$TESTPOOL2 && destroy_pool
$TESTPOOL2
107 log_must zpool create
-O mountpoint
=$TESTDIR $TESTPOOL2 \
108 raidz2
$DISK1 $DISK2 $DISK3 $DISK4
110 # 2. Offline the first device
111 zpool_do_sync
'offline' $TESTPOOL2 $DISK1
113 # 3. Write to the pool
114 log_must mkfile
$FILESIZE "$TESTDIR/data.bin"
117 zpool_scrub_sync
$TESTPOOL2
119 # 5. Online the first device and offline the second device
120 zpool_do_sync
'online' $TESTPOOL2 $DISK1
121 zpool_do_sync
'offline' $TESTPOOL2 $DISK2
122 log_must wait_for_resilver_end
$TESTPOOL2 $RESILVER_TIMEOUT
124 # 6. Scrub the pool again
125 zpool_scrub_sync
$TESTPOOL2
127 # 7. Verify data integrity
128 cksum=$
(zpool status
$TESTPOOL2 |
awk 'L{print $NF;L=0} /CKSUM$/{L=1}')
129 if [[ $cksum != 0 ]]; then
130 log_fail
"Unexpected CKSUM errors found on $TESTPOOL2 ($cksum)"
133 log_pass
"Scrubbing a pool with offline devices correctly preserves DTLs"