2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Red Hat, Inc. All Rights Reserved.
7 # Basic unwritten extent sanity checks
10 _begin_fstest rw auto prealloc quick
12 # Override the default cleanup function.
22 # Import common functions.
25 # real QA test starts here
26 # generic, but xfs_io's fallocate must work
28 # only Linux supports fallocate
31 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
35 _require_xfs_io_command "falloc"
40 # We don't remove files after they are written to check
41 # for subsequent fs corruption at the end
42 rm -f $TEST_DIR/test214-*
44 # Super-trivial; preallocate a region and read it; get 0s.
45 echo "=== falloc & read ==="
48 -c 'pread -v 0 4096' \
49 $TEST_DIR/test214-1 | _filter_xfs_io_unique
51 # Preallocate a chunk, write 1 byte, read it all back.
52 # Should get no stale data. Early ext4 bug.
54 echo "=== falloc, write beginning, read ==="
59 $TEST_DIR/test214-2 | _filter_xfs_io_unique
61 # Same but write in the middle of the region
62 echo "=== falloc, write middle, read ==="
67 $TEST_DIR/test214-3 | _filter_xfs_io_unique
69 # Same but write the end of the region
70 echo "=== falloc, write end, read ==="
75 $TEST_DIR/test214-4 | _filter_xfs_io_unique
77 # Reported by IBM on ext4.
79 # Fixed by commit a41f20716975910d9beb90b7efc61107901492b8
81 # The file was previously preallocated, and then initialized the middle of
82 # the preallocation area using Direct IO write, then overwrite part of
83 # initialized area. Later after truncate the file (to the middle of the
84 # initialized data), the initialized data *before* the new file size was
85 # gone after remount the filesystem.
87 echo "=== falloc, write, sync, truncate, read ==="
88 # Allocate, write, sync, truncate (buffered)
90 -c 'falloc 0x0 0x65C00' \
91 -c 'pwrite -S 0xAA 0x12000 0x10000' \
93 -c 'truncate 0x16000' \
94 $TEST_DIR/test214-5 | _filter_xfs_io_unique
96 # now do a direct read and see what's on-disk
98 -c 'pread -v 0 0x16000' \
99 $TEST_DIR/test214-5 | _filter_xfs_io_unique
101 # Reported by Ted Ts'o on linux-ext4, 12/31/2009
102 # double-allocation on ext4 when fallocating over delalloc blocks
103 # Regression due to d21cd8f163ac44b15c465aab7306db931c606908
105 echo "=== delalloc write 16k; fallocate same range ==="
106 # delalloc write 16k, fallocate same range.
107 # Should get caught on fsck when we're done.
113 $TEST_DIR/test214-6 | _filter_xfs_io_unique
115 # Another ext4 failure
117 echo "=== ext4 testcase 2 ==="
121 -c "pwrite 551917 41182" \
122 -c "falloc 917633 392230" \
123 -c "pwrite 285771 77718" \
124 -c "pwrite 1136718 104115" \
125 $TEST_DIR/test214-7 | _filter_xfs_io_unique