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 #-----------------------------------------------------------------------
25 owner=anand.jain@oracle.com
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
39 trap "_cleanup ; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
50 _scratch_mkfs $SCRATCH_DEV_POOL > /dev/null 2>&1 || _fail "mkfs failed"
53 # Create and save sha256sum
54 # arg1 FS to generate sha256
55 # arg2 File name to save the sha256 output
61 for i in `find . -type f`; do sha256sum $i >> $2; done
65 # Verify the sha256sum for a FS
66 # arg1 FS to be tested
71 [ -f $2 ] || _fail "checksum file $2 not found"
72 sha256sum -c $2 | grep "FAILED"
78 # Return snapshot name in the SNAPNAME
82 [ -d $1 ] || _fail "Destination dir $1 not present"
83 SNAPNAME=`mktemp -u $SCRATCH_MNT/snap.XXXXXX`
84 btrfs subvolume snapshot $1 $SNAPNAME > /dev/null || _fail "snapshot create failed"
87 # Reads and writes new data but does not allocate new blocks
88 # arg1 FS to be modified
93 for i in `find $1 -type f`
95 FSIZE=`stat -t $i | cut -d" " -f2`
96 dd if=$i of=/dev/null obs=$FSIZE count=1 status=noxfer 2>/dev/null &
97 dd if=/dev/urandom of=$i obs=$FSIZE count=1 status=noxfer 2>/dev/null &
102 # Fills the allocated blocks
103 # arg1 FS in question
112 for i in `find /$1 -type f`
114 FSIZE=`stat -t $i | cut -d" " -f2`
115 BLKS=`stat -c "%B" $i`
116 NBLK=`stat -c "%b" $i`
117 FALLOC=$(($BLKS * $NBLK))
118 WS=$(($FALLOC - $FSIZE))
119 dd if=/dev/urandom of=$i oseek=$FSIZE obs=$WS count=1 status=noxfer 2>/dev/null &
125 # Append a random size to the files
126 # arg1 : FS in question
134 for i in `find $1 -type f`
138 FSIZE=`stat -t $X | cut -d" " -f2`
139 dd if=$X of=$X seek=1 bs=$FSIZE obs=$FSIZE count=1 status=noxfer 2>/dev/null &
143 FSIZE=`stat -t $i | cut -d" " -f2`
144 dd if=$X of=$i seek=1 bs=$FSIZE obs=$FSIZE count=1 status=noxfer 2>/dev/null &
150 ##################### real QA test starts here###################################
151 # sv1 - is just a name nothing spl
152 firstvol="$SCRATCH_MNT/sv1"
153 btrfs subvolume create $firstvol > /dev/null || _fail "btrfs subvolume create $firstvol failed"
154 dirp=`mktemp -duq $firstvol/dir.XXXXXX`
155 _populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10 -x
157 _create_snap $firstvol
158 _save_checksum $firstvol $tmp.sv1.sum
159 _verify_checksum $SNAPNAME $tmp.sv1.sum
163 _verify_checksum $firstvol $tmp.sv1.sum
166 _append_file $SNAPNAME
167 _verify_checksum $firstvol $tmp.sv1.sum
170 _read_modify_write $SNAPNAME
171 _verify_checksum $firstvol $tmp.sv1.sum
173 #nested snapshot test
175 for i in `seq 1 7`; do
177 _create_snap $src_vol
178 _verify_checksum $SNAPNAME $tmp.sv1.sum
184 _create_snap $firstvol
185 tname=`echo $SNAPNAME | rev | cut -d"/" -f1 | rev`
186 _save_checksum $SNAPNAME $tmp.$tname.sum
188 _verify_checksum $SNAPNAME $tmp.$tname.sum
190 umount $SCRATCH_DEV || _fail "unmount failed"
192 echo "Silence is golden"