2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc. All Rights Reserved.
5 # FS QA Test No. generic/324
7 # Sanity check for defrag utility.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
23 # get standard environment, filters and checks
28 # real QA test starts here
31 _require_xfs_io_command "falloc"
38 echo "Defragment file with $nr * 2 fragments"
42 $XFS_IO_PROG -f -c "falloc $((409600*i)) 4k" \
43 $SCRATCH_MNT/test.$nr >> $seqres.full 2>&1
45 # Fill holes for half of range , as result file will contain nr*1.5 fragments
46 $XFS_IO_PROG -c "falloc 0 $((204800*nr))" \
47 $SCRATCH_MNT/test.$nr | _filter_xfs_io
48 # Data wrilte will convert extetns to inialized ones
51 patt=`printf "0x%x" $i`
52 $XFS_IO_PROG -c "pwrite -S $patt $((i*123400)) 1234" \
53 $SCRATCH_MNT/test.$nr | _filter_xfs_io
55 _defrag --min_before $nr --max_before $((nr*4)) \
56 --min_after 1 $SCRATCH_MNT/test.$nr
60 # Actual testing starting from here
61 _scratch_mkfs >> $seqres.full 2>&1