check: use generated group files
[xfstests-dev.git] / tests / ext4 / 005
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 005
6 #
7 # Test corruption issue in converting file with a hole at the beginning to
8 # non-extent based format
9 #
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
13 #
14 . ./common/preamble
15 _begin_fstest auto quick metadata ioctl rw
16
17 # Import common functions.
18 . ./common/filter
19
20 # real QA test starts here
21 _supported_fs ext4
22 _require_scratch
23 _require_command "$CHATTR_PROG" chattr
24
25 echo "Silence is golden"
26
27 _scratch_mkfs >>$seqres.full 2>&1
28 _scratch_mount
29
30 testfile=$SCRATCH_MNT/$seq.attrtest
31 touch $testfile
32 $CHATTR_PROG -e $testfile >>$seqres.full 2>&1
33 if [ $? -ne 0 ]; then
34         _notrun "Clearing extent flag not supported, old chattr and/or kernel?"
35 fi
36
37 rm -f $testfile
38 # skip the first 4k and write to the second 4k, leave the first 4k as a hole
39 $XFS_IO_PROG -fc "pwrite 4k 4k" -c "fsync" $testfile >>$seqres.full 2>&1
40
41 # convert to non-extent based file format, buggy ext4 moves the data blocks to
42 # the beginning of the file, but extent status cache still marks that region as
43 # a hole
44 $CHATTR_PROG -e $testfile >>$seqres.full 2>&1
45
46 # delayed allocation writes to the "hole", reclaim the same data block again,
47 # results in i_blocks corruption
48 $XFS_IO_PROG -c "pwrite 0 4k" $testfile >>$seqres.full 2>&1
49
50 # success, all done
51 status=0
52 exit