4 # Extented btrfs snapshot test cases
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2011 Oracle All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
34 status=1 # failure is the default!
41 trap "_cleanup ; exit \$status" 0 1 2 3 15
43 # get standard environment, filters and checks
52 _scratch_mkfs $SCRATCH_DEV_POOL > /dev/null 2>&1 || _fail "mkfs failed"
55 # Create and save sha256sum
56 # arg1 FS to generate sha256
57 # arg2 File name to save the sha256 output
63 for i in `find . -type f`; do sha256sum $i >> $2; done
67 # Verify the sha256sum for a FS
68 # arg1 FS to be tested
73 [ -f $2 ] || _fail "checksum file $2 not found"
74 sha256sum -c $2 | grep "FAILED"
80 # Return snapshot name in the SNAPNAME
84 [ -d $1 ] || _fail "Destination dir $1 not present"
85 SNAPNAME=`mktemp -u $SCRATCH_MNT/snap.XXXXXX`
86 $BTRFS_UTIL_PROG subvolume snapshot $1 $SNAPNAME > /dev/null || _fail "snapshot create failed"
89 # Reads and writes new data but does not allocate new blocks
90 # arg1 FS to be modified
95 for i in `find $1 -type f`
97 FSIZE=`stat -t $i | cut -d" " -f2`
98 dd if=$i of=/dev/null obs=$FSIZE count=1 status=noxfer 2>/dev/null &
99 dd if=/dev/urandom of=$i obs=$FSIZE count=1 status=noxfer 2>/dev/null &
104 # Fills the allocated blocks
105 # arg1 FS in question
114 for i in `find /$1 -type f`
116 FSIZE=`stat -t $i | cut -d" " -f2`
117 BLKS=`stat -c "%B" $i`
118 NBLK=`stat -c "%b" $i`
119 FALLOC=$(($BLKS * $NBLK))
120 WS=$(($FALLOC - $FSIZE))
121 dd if=/dev/urandom of=$i oseek=$FSIZE obs=$WS count=1 status=noxfer 2>/dev/null &
127 # Append a random size to the files
128 # arg1 : FS in question
136 for i in `find $1 -type f`
140 FSIZE=`stat -t $X | cut -d" " -f2`
141 dd if=$X of=$X seek=1 bs=$FSIZE obs=$FSIZE count=1 status=noxfer 2>/dev/null &
145 FSIZE=`stat -t $i | cut -d" " -f2`
146 dd if=$X of=$i seek=1 bs=$FSIZE obs=$FSIZE count=1 status=noxfer 2>/dev/null &
152 ##################### real QA test starts here###################################
153 # sv1 - is just a name nothing spl
154 firstvol="$SCRATCH_MNT/sv1"
155 $BTRFS_UTIL_PROG subvolume create $firstvol > /dev/null || _fail "btrfs subvolume create $firstvol failed"
156 dirp=`mktemp -duq $firstvol/dir.XXXXXX`
157 _populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10 -x
159 _create_snap $firstvol
160 _save_checksum $firstvol $tmp.sv1.sum
161 _verify_checksum $SNAPNAME $tmp.sv1.sum
165 _verify_checksum $firstvol $tmp.sv1.sum
168 _append_file $SNAPNAME
169 _verify_checksum $firstvol $tmp.sv1.sum
172 _read_modify_write $SNAPNAME
173 _verify_checksum $firstvol $tmp.sv1.sum
175 #nested snapshot test
177 for i in `seq 1 7`; do
179 _create_snap $src_vol
180 _verify_checksum $SNAPNAME $tmp.sv1.sum
186 _create_snap $firstvol
187 tname=`echo $SNAPNAME | rev | cut -d"/" -f1 | rev`
188 _save_checksum $SNAPNAME $tmp.$tname.sum
190 _verify_checksum $SNAPNAME $tmp.$tname.sum
192 umount $SCRATCH_DEV || _fail "unmount failed"
194 echo "Silence is golden"