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 _begin_fstest auto fsr quick defrag
14 # Import common functions.
18 # real QA test starts here
21 _require_xfs_io_command "falloc"
26 echo "Defragment file with $nr * 2 fragments"
30 $XFS_IO_PROG -f -c "falloc $((409600*i)) 4k" \
31 $SCRATCH_MNT/test.$nr >> $seqres.full 2>&1
33 # Fill holes for half of range , as result file will contain nr*1.5 fragments
34 $XFS_IO_PROG -c "falloc 0 $((204800*nr))" \
35 $SCRATCH_MNT/test.$nr | _filter_xfs_io
36 # Data wrilte will convert extetns to inialized ones
39 patt=`printf "0x%x" $i`
40 $XFS_IO_PROG -c "pwrite -S $patt $((i*123400)) 1234" \
41 $SCRATCH_MNT/test.$nr | _filter_xfs_io
43 _defrag --min_before $nr --max_before $((nr*4)) \
44 --min_after 1 $SCRATCH_MNT/test.$nr
47 # Actual testing starting from here
48 _scratch_mkfs >> $seqres.full 2>&1