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
35 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
40 _require_xfs_io_command "falloc"
45 # We don't remove files after they are written to check
46 # for subsequent fs corruption at the end
47 rm -f $TEST_DIR/test214-*
49 # Super-trivial; preallocate a region and read it; get 0s.
50 echo "=== falloc & read ==="
53 -c 'pread -v 0 4096' \
54 $TEST_DIR/test214-1 | _filter_xfs_io_unique
56 # Preallocate a chunk, write 1 byte, read it all back.
57 # Should get no stale data. Early ext4 bug.
59 echo "=== falloc, write beginning, read ==="
64 $TEST_DIR/test214-2 | _filter_xfs_io_unique
66 # Same but write in the middle of the region
67 echo "=== falloc, write middle, read ==="
72 $TEST_DIR/test214-3 | _filter_xfs_io_unique
74 # Same but write the end of the region
75 echo "=== falloc, write end, read ==="
80 $TEST_DIR/test214-4 | _filter_xfs_io_unique
82 # Reported by IBM on ext4.
84 # Fixed by commit a41f20716975910d9beb90b7efc61107901492b8
86 # The file was previously preallocated, and then initialized the middle of
87 # the preallocation area using Direct IO write, then overwrite part of
88 # initialized area. Later after truncate the file (to the middle of the
89 # initialized data), the initialized data *before* the new file size was
90 # gone after remount the filesystem.
92 echo "=== falloc, write, sync, truncate, read ==="
93 # Allocate, write, sync, truncate (buffered)
95 -c 'falloc 0x0 0x65C00' \
96 -c 'pwrite -S 0xAA 0x12000 0x10000' \
98 -c 'truncate 0x16000' \
99 $TEST_DIR/test214-5 | _filter_xfs_io_unique
101 # now do a direct read and see what's on-disk
103 -c 'pread -v 0 0x16000' \
104 $TEST_DIR/test214-5 | _filter_xfs_io_unique
106 # Reported by Ted Ts'o on linux-ext4, 12/31/2009
107 # double-allocation on ext4 when fallocating over delalloc blocks
108 # Regression due to d21cd8f163ac44b15c465aab7306db931c606908
110 echo "=== delalloc write 16k; fallocate same range ==="
111 # delalloc write 16k, fallocate same range.
112 # Should get caught on fsck when we're done.
118 $TEST_DIR/test214-6 | _filter_xfs_io_unique
120 # Another ext4 failure
122 echo "=== ext4 testcase 2 ==="
126 -c "pwrite 551917 41182" \
127 -c "falloc 917633 392230" \
128 -c "pwrite 285771 77718" \
129 -c "pwrite 1136718 104115" \
130 $TEST_DIR/test214-7 | _filter_xfs_io_unique