4 # Check data integrity and layout stability during defrag compacting
5 # EXT4_IOC_MOVE_EXT simply swap extents between target and donor inode.
6 # So if ioctl was performed twice then inode's layout should not change.
8 #-----------------------------------------------------------------------
9 # (c) 2014 Dmitry Monakhov
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
44 # real QA test starts here
48 _require_xfs_io_command "falloc"
55 echo "Create file with $nr * 2 fragments"
59 $XFS_IO_PROG -f -c "falloc $((409600*i)) 4k" \
60 $SCRATCH_MNT/test.$nr >> $seqres.full 2>&1
62 # Fill holes for half of range , as result file will contain nr*1.5 fragments
63 $XFS_IO_PROG -c "falloc 0 $((204800*nr))" \
64 $SCRATCH_MNT/test.$nr | _filter_xfs_io
65 # Data wrilte will convert extetns to inialized ones
68 patt=`printf "0x%x" $i`
69 $XFS_IO_PROG -c "pwrite -S $patt $((i*123400)) 1234" \
70 $SCRATCH_MNT/test.$nr | _filter_xfs_io
72 md5sum $SCRATCH_MNT/test.* | _filter_scratch
73 $XFS_IO_PROG -c "fiemap" -f $SCRATCH_MNT/test.* > $tmp.fiemap.before
75 echo "Perform compacting"
76 $XFS_IO_PROG -c "falloc 0 246M" -f $SCRATCH_MNT/donor | _filter_xfs_io
77 ls $SCRATCH_MNT/test.* | run_check $here/src/e4compact \
78 -v -i -f $SCRATCH_MNT/donor >> $seqres.full 2>&1
79 md5sum $SCRATCH_MNT/test.* | _filter_scratch
80 $XFS_IO_PROG -c "fiemap" -f $SCRATCH_MNT/test.* > $tmp.fiemap.pass1
81 diff $tmp.fiemap.before $tmp.fiemap.pass1 > /dev/null && \
82 _fail "Pass1: Extent's layout not changed"
84 echo "Perform compacting, second pass"
85 # Second pass should restore original layout
86 ls $SCRATCH_MNT/test.* | run_check $here/src/e4compact \
87 -v -f $SCRATCH_MNT/donor >> $seqres.full 2>&1
88 md5sum $SCRATCH_MNT/test.* | _filter_scratch
89 $XFS_IO_PROG -c "fiemap" -f $SCRATCH_MNT/test.* > $tmp.fiemap.pass2
90 diff -up $tmp.fiemap.before $tmp.fiemap.pass2 || \
91 _fail "Pass2: Extent's layout changed."
92 unlink $SCRATCH_MNT/donor
95 # Actual testing starting from here
96 _scratch_mkfs >> $seqres.full 2>&1