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 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 3
37 trap "_destroy; exit \$status" 2 15
41 # get standard environment, filters and checks
45 # real QA test starts here
50 _scratch_mkfs >/dev/null 2>&1
60 kill $pids $fstrim_pid 2> /dev/null
61 wait $pids $fstrim_pid 2> /dev/null
67 kill $fpid 2> /dev/null
68 wait $fpid 2> /dev/null
74 kill $mypid 2> /dev/null
80 while [ $mmlen -gt 1 ]; do
81 $FSTRIM_PROG -l $(($mmlen*2))k -m ${mmlen}k $SCRATCH_MNT &> /dev/null && break
88 # Background FSTRIM loop. We are trimming the device in the loop and for
89 # test coverage, we are doing whole device trim followed by several smaller
94 trap "_destroy_fstrim; exit \$status" 2 15
95 fsize=$(df | grep $SCRATCH_MNT | grep $SCRATCH_DEV | awk '{print $2}')
96 mmlen=$(_guess_max_minlen)
99 step=$((RANDOM*$RANDOM+4))
100 minlen=$(((RANDOM*($RANDOM%2+1))%$mmlen))
102 if [ $((RANDOM%10)) -gt 7 ]; then
103 $FSTRIM_PROG $SCRATCH_MNT &
107 while [ $start -lt $fsize ] ; do
108 $FSTRIM_PROG -m ${minlen}k -o ${start}k -l ${step}k $SCRATCH_MNT &
111 start=$(( $start + $step ))
116 function check_sums() {
119 find -P . -xdev -type f -print0 | xargs -0 md5sum | sort -o $tmp/stress.$$.$p
122 diff $tmp/content.sums $tmp/stress.$$.$p
123 if [ $? -ne 0 ]; then
124 _fail "!!!Checksums has changed - Filesystem possibly corrupted!!!\n"
126 rm -f $tmp/stress.$$.$p
129 function run_process() {
134 export chpid=$! && wait $chpid &> /dev/null
137 while [ $repeat -gt 0 ]; do
139 # Remove old directories.
140 rm -rf $SCRATCH_MNT/$p
141 export chpid=$! && wait $chpid &> /dev/null
143 # Copy content -> partition.
144 mkdir $SCRATCH_MNT/$p
145 cp -axT $content/ $SCRATCH_MNT/$p/
146 export chpid=$! && wait $chpid &> /dev/null
149 repeat=$(( $repeat - 1 ))
156 # Check for FITRIM support
157 echo -n "Checking FITRIM support: "
158 _test_batched_discard $SCRATCH_MNT || _notrun "FITRIM not supported on $SCRATCH_DEV"
165 find -P . -xdev -type f -print0 | xargs -0 md5sum | sort -o $tmp/content.sums
168 echo -n "Running the test: "
173 while [ $p -le $nproc ]; do