2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Red Hat, Inc. All Rights Reserved.
7 # Basic unwritten extent sanity checks
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
22 status=1 # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
29 # real QA test starts here
30 # generic, but xfs_io's fallocate must work
32 # only Linux supports fallocate
36 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
41 _require_xfs_io_command "falloc"
46 # We don't remove files after they are written to check
47 # for subsequent fs corruption at the end
48 rm -f $TEST_DIR/test214-*
50 # Super-trivial; preallocate a region and read it; get 0s.
51 echo "=== falloc & read ==="
54 -c 'pread -v 0 4096' \
55 $TEST_DIR/test214-1 | _filter_xfs_io_unique
57 # Preallocate a chunk, write 1 byte, read it all back.
58 # Should get no stale data. Early ext4 bug.
60 echo "=== falloc, write beginning, read ==="
65 $TEST_DIR/test214-2 | _filter_xfs_io_unique
67 # Same but write in the middle of the region
68 echo "=== falloc, write middle, read ==="
73 $TEST_DIR/test214-3 | _filter_xfs_io_unique
75 # Same but write the end of the region
76 echo "=== falloc, write end, read ==="
81 $TEST_DIR/test214-4 | _filter_xfs_io_unique
83 # Reported by IBM on ext4.
85 # Fixed by commit a41f20716975910d9beb90b7efc61107901492b8
87 # The file was previously preallocated, and then initialized the middle of
88 # the preallocation area using Direct IO write, then overwrite part of
89 # initialized area. Later after truncate the file (to the middle of the
90 # initialized data), the initialized data *before* the new file size was
91 # gone after remount the filesystem.
93 echo "=== falloc, write, sync, truncate, read ==="
94 # Allocate, write, sync, truncate (buffered)
96 -c 'falloc 0x0 0x65C00' \
97 -c 'pwrite -S 0xAA 0x12000 0x10000' \
99 -c 'truncate 0x16000' \
100 $TEST_DIR/test214-5 | _filter_xfs_io_unique
102 # now do a direct read and see what's on-disk
104 -c 'pread -v 0 0x16000' \
105 $TEST_DIR/test214-5 | _filter_xfs_io_unique
107 # Reported by Ted Ts'o on linux-ext4, 12/31/2009
108 # double-allocation on ext4 when fallocating over delalloc blocks
109 # Regression due to d21cd8f163ac44b15c465aab7306db931c606908
111 echo "=== delalloc write 16k; fallocate same range ==="
112 # delalloc write 16k, fallocate same range.
113 # Should get caught on fsck when we're done.
119 $TEST_DIR/test214-6 | _filter_xfs_io_unique
121 # Another ext4 failure
123 echo "=== ext4 testcase 2 ==="
127 -c "pwrite 551917 41182" \
128 -c "falloc 917633 392230" \
129 -c "pwrite 285771 77718" \
130 -c "pwrite 1136718 104115" \
131 $TEST_DIR/test214-7 | _filter_xfs_io_unique