generic/233,270: unlimit the max locked memory size for io_uring
[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 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 # real QA test starts here
34 _supported_fs ext4
35 _require_scratch
36 _require_command "$CHATTR_PROG" chattr
37
38 rm -f $seqres.full
39
40 echo "Silence is golden"
41
42 _scratch_mkfs >>$seqres.full 2>&1
43 _scratch_mount
44
45 testfile=$SCRATCH_MNT/$seq.attrtest
46 touch $testfile
47 $CHATTR_PROG -e $testfile >>$seqres.full 2>&1
48 if [ $? -ne 0 ]; then
49         _notrun "Clearing extent flag not supported, old chattr and/or kernel?"
50 fi
51
52 rm -f $testfile
53 # skip the first 4k and write to the second 4k, leave the first 4k as a hole
54 $XFS_IO_PROG -fc "pwrite 4k 4k" -c "fsync" $testfile >>$seqres.full 2>&1
55
56 # convert to non-extent based file format, buggy ext4 moves the data blocks to
57 # the beginning of the file, but extent status cache still marks that region as
58 # a hole
59 $CHATTR_PROG -e $testfile >>$seqres.full 2>&1
60
61 # delayed allocation writes to the "hole", reclaim the same data block again,
62 # results in i_blocks corruption
63 $XFS_IO_PROG -c "pwrite 0 4k" $testfile >>$seqres.full 2>&1
64
65 # success, all done
66 status=0
67 exit