]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - debian/tests/kernel-smoke-test-scrub
3 # Copyright (C) 2016 Canonical
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 echo -n "kernel smoke test, corrupt data and clean with a scrub: "
21 VDEV0
=${TMP}/pool0-$$.img
22 VDEV1
=${TMP}/pool1-$$.img
23 VDEV2
=${TMP}/pool2-$$.img
24 VDEV3
=${TMP}/pool3-$$.img
27 DATA
=/${POOL}/random.dat
28 ZFSFS
="test tmp example data1 data2 data3"
30 dd if=/dev
/zero of
=${VDEV0} bs
=1M count
=${VDEV_SZ} > /dev
/null
2>&1
31 dd if=/dev
/zero of
=${VDEV1} bs
=1M count
=${VDEV_SZ} > /dev
/null
2>&1
32 dd if=/dev
/zero of
=${VDEV2} bs
=1M count
=${VDEV_SZ} > /dev
/null
2>&1
33 dd if=/dev
/zero of
=${VDEV3} bs
=1M count
=${VDEV_SZ} > /dev
/null
2>&1
35 zpool create
${POOL} mirror ${VDEV0} ${VDEV1} mirror ${VDEV2} ${VDEV3}
37 if [ $ret -ne 0 ]; then
38 echo "FAILED: zpool create failed, exit code=$ret"
39 rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3}
46 dd if=/dev
/urandom of
=$DATA bs
=1M count
=64 > /dev
/null
2>&1
47 sum1
=$
(md5sum ${DATA} |
awk '{print $1}')
52 dd if=/dev
/zero of
=${VDEV0} bs
=1M count
=${VDEV_SZ} > /dev
/null
2>&1
56 # Offline "corrupted" VDEV
58 zpool detach
${POOL} ${VDEV0}
60 if [ $ret -ne 0 ]; then
61 echo "FAILED: zpool detach failed, exit code=$ret"
63 rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3}
68 # Zero corrupted VDEV and re-attach
70 dd if=/dev
/zero of
=${VDEV0} bs
=1M count
=${VDEV_SZ} > /dev
/null
2>&1
71 zpool attach
${POOL} ${VDEV1} ${VDEV0} -f
73 if [ $ret -ne 0 ]; then
74 echo "FAILED: zpool attach failed, exit code=$ret"
76 rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3}
82 if [ $ret -ne 0 ]; then
83 echo "FAILED: zpool scrub failed, exit code=$ret"
85 rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3}
89 sum2
=$
(md5sum ${DATA} |
awk '{print $1}')
91 # Checksums must agree
93 if [ x
"$sum1" != x
"$sum2" ]; then
94 echo "FAILED: corrupted data on scrubbed pool"
96 rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3}
100 zpool destroy
${POOL}
102 if [ $ret -ne 0 ]; then
103 echo "FAILED: zpool destroy failed, exit code=$ret"
105 # destroy failed, try to clean up, but this
108 rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3}
112 rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3}