4 # This test was created in order to verify filesystem FITRIM implementation.
5 # By many concurrent copy and remove operations and checking that files
6 # does not change after copied into SCRATCH_MNT test if FITRIM implementation
7 # corrupts the filesystem (data/metadata).
9 #-----------------------------------------------------------------------
10 # Copyright 2010 (C) Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 3
34 trap "_destroy; exit \$status" 2 15
38 # get standard environment, filters and checks
42 # real QA test starts here
46 _scratch_mkfs >/dev/null 2>&1
48 _require_batched_discard $SCRATCH_MNT
57 kill $pids $fstrim_pid 2> /dev/null
58 wait $pids $fstrim_pid 2> /dev/null
64 kill $fpid 2> /dev/null
65 wait $fpid 2> /dev/null
71 kill $mypid 2> /dev/null
77 while [ $mmlen -gt 1 ]; do
78 $FSTRIM_PROG -l $(($mmlen*2))k -m ${mmlen}k $SCRATCH_MNT &> /dev/null && break
85 # Background FSTRIM loop. We are trimming the device in the loop and for
86 # test coverage, we are doing whole device trim followed by several smaller
91 trap "_destroy_fstrim; exit \$status" 2 15
92 fsize=$($DF_PROG | grep $SCRATCH_MNT | grep $SCRATCH_DEV | awk '{print $3}')
93 mmlen=$(_guess_max_minlen)
96 step=$((RANDOM*$RANDOM+4))
97 minlen=$(((RANDOM*($RANDOM%2+1))%$mmlen))
99 if [ $((RANDOM%10)) -gt 7 ]; then
100 $FSTRIM_PROG $SCRATCH_MNT &
104 while [ $start -lt $fsize ] ; do
105 $FSTRIM_PROG -m ${minlen}k -o ${start}k -l ${step}k $SCRATCH_MNT &
108 start=$(( $start + $step ))
113 function check_sums() {
116 find -P . -xdev -type f -print0 | xargs -0 md5sum | sort -o $tmp/stress.$$.$p
119 diff $tmp/content.sums $tmp/stress.$$.$p
120 if [ $? -ne 0 ]; then
121 _fail "!!!Checksums has changed - Filesystem possibly corrupted!!!\n"
123 rm -f $tmp/stress.$$.$p
126 function run_process() {
131 export chpid=$! && wait $chpid &> /dev/null
134 while [ $repeat -gt 0 ]; do
136 # Remove old directories.
137 rm -rf $SCRATCH_MNT/$p
138 export chpid=$! && wait $chpid &> /dev/null
140 # Copy content -> partition.
141 mkdir $SCRATCH_MNT/$p
142 cp -axT $content/ $SCRATCH_MNT/$p/
143 export chpid=$! && wait $chpid &> /dev/null
146 repeat=$(( $repeat - 1 ))
157 find -P . -xdev -type f -print0 | xargs -0 md5sum | sort -o $tmp/content.sums
160 echo -n "Running the test: "
165 while [ $p -le $nproc ]; do