4 # This test verify if the reconstructed data on the RAID5 is good.
6 # Initialize RAID5 with some data
8 # Re-mount RAID5 degraded with dev3 missing and write data
9 # Save md5sum checkpoint1
11 # Re-mount healthy RAID5
13 # Let balance fix the RAID5.
14 # Save md5sum checkpoint2
16 # Re-mount RAID5 degraded with dev1 as missing.
17 # Save md5sum checkpoint3
19 # Verify if all three checkpoints match
21 #---------------------------------------------------------------------
22 # Copyright (c) 2016 Oracle. All Rights Reserved.
24 # This program is free software; you can redistribute it and/or
25 # modify it under the terms of the GNU General Public License as
26 # published by the Free Software Foundation.
28 # This program is distributed in the hope that it would be useful,
29 # but WITHOUT ANY WARRANTY; without even the implied warranty of
30 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 # GNU General Public License for more details.
33 # You should have received a copy of the GNU General Public License
34 # along with this program; if not, write the Free Software Foundation,
35 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
36 #---------------------------------------------------------------------
40 seqres=$RESULT_DIR/$seq
41 echo "QA output created by $seq"
45 status=1 # failure is the default!
46 trap "_cleanup; exit \$status" 0 1 2 3 15
54 # get standard environment, filters and checks
59 # remove previous $seqres.full before test
62 # real QA test starts here
66 _require_scratch_dev_pool 3
68 _require_loadable_fs_module "btrfs"
70 _scratch_dev_pool_get 3
72 dev1=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
73 dev2=`echo $SCRATCH_DEV_POOL | awk '{print $2}'`
74 dev3=`echo $SCRATCH_DEV_POOL | awk '{print $3}'`
76 echo dev1=$dev1 >> $seqres.full
77 echo dev2=$dev2 >> $seqres.full
78 echo dev3=$dev3 >> $seqres.full
80 # Balance won't be successful if filled too much
81 dev1_sz=`blockdev --getsize64 $dev1`
82 dev2_sz=`blockdev --getsize64 $dev2`
83 dev3_sz=`blockdev --getsize64 $dev3`
86 max_fs_sz=`echo -e "$dev1_sz\n$dev2_sz\n$dev3_sz" | sort | head -1`
87 # Need disks with more than 2G
88 if [ $max_fs_sz -lt 2000000000 ]; then
91 _notrun "Smallest dev size $max_fs_sz, Need at least 2G"
95 count=$(($max_fs_sz / 1000000))
97 #-------------normal init-------------------
99 echo "max_fs_sz=$max_fs_sz count=$count" >> $seqres.full
100 echo "-----Initialize -----" >> $seqres.full
101 _scratch_pool_mkfs "-mraid5 -draid5" >> $seqres.full 2>&1
102 _scratch_mount >> $seqres.full 2>&1
103 dd if=/dev/zero of="$SCRATCH_MNT"/tf1 bs=$bs count=1 \
105 _run_btrfs_util_prog filesystem show
106 _run_btrfs_util_prog filesystem df $SCRATCH_MNT
110 #-------------degraded-init-------------------
112 echo "-----Write degraded mount fill upto $max_fs_sz bytes-----" >> $seqres.full
114 echo "Write data with degraded mount"
116 echo "unmount" >> $seqres.full
118 echo "clean btrfs ko" >> $seqres.full
119 # un-scan the btrfs devices
120 _reload_fs_module "btrfs"
121 _mount -o degraded,device=$dev2 $dev1 $SCRATCH_MNT >>$seqres.full 2>&1
122 dd if=/dev/zero of="$SCRATCH_MNT"/tf2 bs=$bs count=$count \
124 _run_btrfs_util_prog filesystem show
125 _run_btrfs_util_prog filesystem df $SCRATCH_MNT
126 checkpoint1=`md5sum $SCRATCH_MNT/tf2`
127 echo $checkpoint1 >> $seqres.full 2>&1
129 #-------------balance-------------------
131 echo "-----Mount normal-----" >> $seqres.full
133 echo "Mount normal and balance"
136 _run_btrfs_util_prog device scan
137 _scratch_mount >> $seqres.full 2>&1
140 _run_btrfs_util_prog balance start ${SCRATCH_MNT}
142 _run_btrfs_util_prog filesystem show
143 _run_btrfs_util_prog filesystem df ${SCRATCH_MNT}
145 checkpoint2=`md5sum $SCRATCH_MNT/tf2`
146 echo $checkpoint2 >> $seqres.full 2>&1
148 #-------------degraded-mount-------------------
150 echo "-----Mount degraded with dev1 missing-----" >> $seqres.full
152 echo "Mount degraded but with other dev"
155 # un-scan the btrfs devices
156 _reload_fs_module "btrfs"
158 _mount -o degraded,device=${dev2} $dev3 $SCRATCH_MNT >>$seqres.full 2>&1
160 _run_btrfs_util_prog filesystem show
161 _run_btrfs_util_prog filesystem df $SCRATCH_MNT
162 checkpoint3=`md5sum $SCRATCH_MNT/tf2`
163 echo $checkpoint3 >> $seqres.full 2>&1
165 if [ "$checkpoint1" != "$checkpoint2" ]; then
168 echo "Inital sum does not match with after balance"
171 if [ "$checkpoint1" != "$checkpoint3" ]; then
174 echo "Inital sum does not match with data on dev2 written by balance"
178 _scratch_dev_pool_put