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 #-----------------------------------------------------------------------
26 owner=lczerner@redhat.com
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 3
35 trap "_destroy; exit \$status" 2 15
39 # get standard environment, filters and checks
43 # real QA test starts here
47 _scratch_mkfs >/dev/null 2>&1
57 kill $pids $fstrim_pid
58 wait $pids $fstrim_pid
74 _check_fstrim_support()
76 $here/src/fstrim -l 10M $SCRATCH_MNT &> /dev/null
80 # Background FSTRIM loop. We are trimming the device in the loop and for
81 # test coverage, we are doing whole device trim followed by several smaller
86 trap "_destroy_fstrim; exit \$status" 2 15
87 fsize=$(df | grep $SCRATCH_MNT | grep $SCRATCH_DEV | awk '{print $2}')
92 $here/src/fstrim $SCRATCH_MNT &
95 while [ $start -lt $fsize ] ; do
96 $here/src/fstrim -s ${start}k -l ${step}k $SCRATCH_MNT &
99 start=$(( $start + $step ))
104 function check_sums() {
107 find -P . -xdev -type f -print0 | xargs -0 md5sum | sort -o $tmp/stress.$$.$p
110 diff $tmp/content.sums $tmp/stress.$$.$p
111 if [ $? -ne 0 ]; then
112 _fail "!!!Checksums has changed - Filesystem possibly corrupted!!!\n"
114 rm -f $tmp/stress.$$.$p
117 function run_process() {
122 export chpid=$! && wait $chpid &> /dev/null
125 while [ $repeat -gt 0 ]; do
127 # Remove old directories.
128 rm -rf $SCRATCH_MNT/$p
129 export chpid=$! && wait $chpid &> /dev/null
131 # Copy content -> partition.
132 mkdir $SCRATCH_MNT/$p
133 cp -axT $content $SCRATCH_MNT/$p
134 export chpid=$! && wait $chpid &> /dev/null
137 repeat=$(( $repeat - 1 ))
144 # Check for FITRIM support
145 echo -n "Checking FITRIM support: "
146 _check_fstrim_support || _notrun "FSTRIM is not supported"
153 find -P . -xdev -type f -print0 | xargs -0 md5sum | sort -o $tmp/content.sums
156 echo -n "Running the test: "
161 while [ $p -le $nproc ]; do