]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_multiple_copies.ksh
Multiple DVA Scrubbing Fix
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_scrub / zpool_scrub_multiple_copies.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
8 # 1.0 of the CDDL.
9 #
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
13 #
14 # CDDL HEADER END
15 #
16
17 #
18 # Copyright (c) 2019 Datto, Inc. All rights reserved.
19 #
20
21 . $STF_SUITE/include/libtest.shlib
22
23 #
24 # DESCRIPTION:
25 # Scrubs and self-healing should be able to repair data from additional
26 # copies that may be stored.
27 #
28 #
29 # STRATEGY:
30 # 1. Create a dataset with copies=3
31 # 2. Write a file to the dataset
32 # 3. zinject errors into the first and second DVAs of that file
33 # 4. Scrub and verify the scrub repaired all errors
34 # 7. Read the file normally to check that self healing also works
35 # 8. Remove the zinject handler
36 # 9. Scrub again and confirm 0 bytes were scrubbed
37 #
38
39 verify_runnable "global"
40
41 function cleanup
42 {
43 destroy_dataset $TESTPOOL/$TESTFS2
44 log_must zinject -c all
45 }
46 log_onexit cleanup
47
48 log_assert "Scrubs and self healing must work with additional copies"
49
50 log_must zfs create -o copies=3 $TESTPOOL/$TESTFS2
51 typeset mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS2)
52 log_must mkfile 10m $mntpnt/file
53 log_must zpool sync $TESTPOOL
54
55 log_must zinject -a -t data -C 0,1 -e io $mntpnt/file
56
57 log_must zpool scrub $TESTPOOL
58 log_must wait_scrubbed $TESTPOOL
59
60 log_must check_pool_status $TESTPOOL "scan" "with 0 errors"
61 log_must check_pool_status $TESTPOOL "errors" "No known data errors"
62
63 log_must dd if=$mntpnt/file of=/dev/null bs=1M iflag=fullblock
64 log_must check_pool_status $TESTPOOL "errors" "No known data errors"
65
66 log_must zinject -c all
67
68 log_must zpool scrub $TESTPOOL
69 log_must wait_scrubbed $TESTPOOL
70
71 zpool status
72
73 log_must check_pool_status $TESTPOOL "errors" "No known data errors"
74 log_must check_pool_status $TESTPOOL "scan" "with 0 errors"
75 log_must check_pool_status $TESTPOOL "scan" "repaired 0B"
76
77 log_pass "Scrubs and self healing work with additional copies"