2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
7 # Test corruption issue in converting file with a hole at the beginning to
8 # non-extent based format
10 # These two commits fixed the corruption:
11 # ext4: be more strict when migrating to non-extent based file
12 # ext4: correctly migrate a file with a hole at the beginning
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
29 # get standard environment, filters and checks
33 # real QA test starts here
37 _require_command "$CHATTR_PROG" chattr
41 echo "Silence is golden"
43 _scratch_mkfs >>$seqres.full 2>&1
46 testfile=$SCRATCH_MNT/$seq.attrtest
48 $CHATTR_PROG -e $testfile >>$seqres.full 2>&1
50 _notrun "Clearing extent flag not supported, old chattr and/or kernel?"
54 # skip the first 4k and write to the second 4k, leave the first 4k as a hole
55 $XFS_IO_PROG -fc "pwrite 4k 4k" -c "fsync" $testfile >>$seqres.full 2>&1
57 # convert to non-extent based file format, buggy ext4 moves the data blocks to
58 # the beginning of the file, but extent status cache still marks that region as
60 $CHATTR_PROG -e $testfile >>$seqres.full 2>&1
62 # delayed allocation writes to the "hole", reclaim the same data block again,
63 # results in i_blocks corruption
64 $XFS_IO_PROG -c "pwrite 0 4k" $testfile >>$seqres.full 2>&1