2 # FS QA Test No. generic/324
4 # Sanity check for defrag utility.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2013 Red Hat, Inc. 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
21 #-----------------------------------------------------------------------
24 seqres=$RESULT_DIR/$seq
25 echo "QA output created by $seq"
29 status=1 # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
42 # real QA test starts here
47 _require_xfs_io_command "falloc"
54 echo "Defragment file with $nr * 2 fragments"
58 $XFS_IO_PROG -f -c "falloc $((409600*i)) 4k" \
59 $SCRATCH_MNT/test.$nr >> $seqres.full 2>&1
61 # Fill holes for half of range , as result file will contain nr*1.5 fragments
62 $XFS_IO_PROG -c "falloc 0 $((204800*nr))" \
63 $SCRATCH_MNT/test.$nr | _filter_xfs_io
64 # Data wrilte will convert extetns to inialized ones
67 patt=`printf "0x%x" $i`
68 $XFS_IO_PROG -c "pwrite -S $patt $((i*123400)) 1234" \
69 $SCRATCH_MNT/test.$nr | _filter_xfs_io
71 _defrag --min_before $nr --max_before $((nr*4)) \
72 --min_after 1 $SCRATCH_MNT/test.$nr
76 # Actual testing starting from here
77 _scratch_mkfs >> $seqres.full 2>&1