4 # Basic unwritten extent sanity checks
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2009 Red Hat, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
40 status=1 # failure is the default!
41 trap "_cleanup; exit \$status" 0 1 2 3 15
43 # get standard environment, filters and checks
47 # real QA test starts here
48 # generic, but xfs_io's fallocate must work
50 # only Linux supports fallocate
53 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
58 _require_xfs_io_falloc
62 # We don't remove files after they are written to check
63 # for subsequent fs corruption at the end
64 rm -f $TEST_DIR/test214-*
66 # Super-trivial; preallocate a region and read it; get 0s.
67 echo "=== falloc & read ==="
70 -c 'pread -v 0 4096' \
71 $TEST_DIR/test214-1 | _filter_xfs_io_unique
73 # Preallocate a chunk, write 1 byte, read it all back.
74 # Should get no stale data. Early ext4 bug.
76 echo "=== falloc, write beginning, read ==="
81 $TEST_DIR/test214-2 | _filter_xfs_io_unique
83 # Same but write in the middle of the region
84 echo "=== falloc, write middle, read ==="
89 $TEST_DIR/test214-3 | _filter_xfs_io_unique
91 # Same but write the end of the region
92 echo "=== falloc, write end, read ==="
97 $TEST_DIR/test214-4 | _filter_xfs_io_unique
99 # Reported by IBM on ext4.
101 # Fixed by commit a41f20716975910d9beb90b7efc61107901492b8
103 # The file was previously preallocated, and then initialized the middle of
104 # the preallocation area using Direct IO write, then overwrite part of
105 # initialized area. Later after truncate the file (to the middle of the
106 # initialized data), the initialized data *before* the new file size was
107 # gone after remount the filesystem.
109 echo "=== falloc, write, sync, truncate, read ==="
110 # Allocate, write, sync, truncate (buffered)
112 -c 'falloc 0x0 0x65C00' \
113 -c 'pwrite -S 0xAA 0x12000 0x10000' \
115 -c 'truncate 0x16000' \
116 $TEST_DIR/test214-5 | _filter_xfs_io_unique
118 # now do a direct read and see what's on-disk
119 $XFS_IO_PROG -F -f -d \
120 -c 'pread -v 0 0x16000' \
121 $TEST_DIR/test214-5 | _filter_xfs_io_unique
123 # Reported by Ted Ts'o on linux-ext4, 12/31/2009
124 # double-allocation on ext4 when fallocating over delalloc blocks
125 # Regression due to d21cd8f163ac44b15c465aab7306db931c606908
127 echo "=== delalloc write 16k; fallocate same range ==="
128 # delalloc write 16k, fallocate same range.
129 # Should get caught on fsck when we're done.
135 $TEST_DIR/test214-6 | _filter_xfs_io_unique
137 # Another ext4 failure
139 echo "=== ext4 testcase 2 ==="
143 -c "pwrite 551917 41182" \
144 -c "falloc 917633 392230" \
145 -c "pwrite 285771 77718" \
146 -c "pwrite 1136718 104115" \
147 $TEST_DIR/test214-7 | _filter_xfs_io_unique