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) 2020, Datto Inc. All rights reserved.
22 .
$STF_SUITE/include
/libtest.shlib
23 .
$STF_SUITE/tests
/functional
/replacement
/replacement.cfg
27 # Testing resilver completes when scan errors are encountered, but relevant
28 # DTL's have not been lost.
31 # 1. Create a pool (1k recordsize)
32 # 2. Create a 32m file (32k records)
33 # 3. Inject an error halfway through the file
34 # 4. Start a resilver, ensure the error is triggered and that the resilver
35 # does not restart after finishing
37 # NB: use legacy scanning to ensure scan of specific block causes error
42 log_must zinject
-c all
43 destroy_pool
$TESTPOOL1
44 rm -f ${VDEV_FILES[@]} $SPARE_VDEV_FILE
45 log_must set_tunable32 SCAN_LEGACY
$ORIG_SCAN_LEGACY
48 log_assert
"Check for resilver restarts caused by scan errors"
50 ORIG_SCAN_LEGACY
=$
(get_tunable SCAN_LEGACY
)
54 # use legacy scan to ensure injected error will be triggered
55 log_must set_tunable32 SCAN_LEGACY
1
57 # create the pool and a 32M file (32k blocks)
58 log_must truncate
-s $VDEV_FILE_SIZE ${VDEV_FILES[0]} $SPARE_VDEV_FILE
59 log_must zpool create
-f -O recordsize
=1k
$TESTPOOL1 ${VDEV_FILES[0]}
60 log_must
dd if=/dev
/urandom of
=/$TESTPOOL1/file bs
=1M count
=32 > /dev
/null
2>&1
62 # determine objset/object
63 objset
=$
(zdb
-d $TESTPOOL1/ |
sed -ne 's/.*ID \([0-9]*\).*/\1/p')
64 object
=$
(ls -i /$TESTPOOL1/file |
awk '{print $1}')
66 # inject event to cause error during resilver
67 log_must zinject
-b `printf "%x:%x:0:3fff" $objset $object` $TESTPOOL1
69 # clear events and start resilver
70 log_must zpool events
-c
71 log_must zpool attach
$TESTPOOL1 ${VDEV_FILES[0]} $SPARE_VDEV_FILE
73 log_note
"waiting for read errors to start showing up"
77 err
=$
(zpool status
$TESTPOOL1 |
grep ${VDEV_FILES[0]} |
awk '{print $3}')
78 (( $err > 0 )) && break
82 (( $err == 0 )) && log_fail
"Unable to induce errors in resilver"
84 log_note
"waiting for resilver to finish"
87 finish
=$
(zpool events |
grep "sysevent.fs.zfs.resilver_finish" |
wc -l)
88 (( $finish > 0 )) && break
92 (( $finish == 0 )) && log_fail
"resilver took too long to finish"
94 # wait a few syncs to ensure that zfs does not restart the resilver
95 log_must zpool sync
$TESTPOOL1
96 log_must zpool sync
$TESTPOOL1
98 # check if resilver was restarted
99 start
=$
(zpool events |
grep "sysevent.fs.zfs.resilver_start" |
wc -l)
100 (( $start != 1 )) && log_fail
"resilver restarted unnecessarily"
102 log_pass
"Resilver did not restart unnecessarily from scan errors"