fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 214
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Red Hat, Inc. All Rights Reserved.
4 #
5 # FS QA Test No. 214
6 #
7 # Basic unwritten extent sanity checks
8 #
9 . ./common/preamble
10 _begin_fstest rw auto prealloc quick
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15         rm -f $TEST_DIR/ouch*
16         cd /
17         rm -f $tmp.*
18 }
19
20 tmp=$TEST_DIR/$$
21
22 # Import common functions.
23 . ./common/filter
24
25 # real QA test starts here
26 # generic, but xfs_io's fallocate must work
27 _supported_fs generic
28 # only Linux supports fallocate
29 _require_test
30
31 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
32
33 rm -f $TEST_DIR/ouch*
34
35 _require_xfs_io_command "falloc"
36 _require_odirect
37
38 # Ok, off we go.
39
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-*
43
44 # Super-trivial; preallocate a region and read it; get 0s.
45 echo "=== falloc & read  ==="
46 $XFS_IO_PROG -f                 \
47         -c 'falloc 0 4096'      \
48         -c 'pread -v 0 4096'    \
49         $TEST_DIR/test214-1 | _filter_xfs_io_unique
50
51 # Preallocate a chunk, write 1 byte, read it all back.
52 # Should get no stale data.  Early ext4 bug.
53
54 echo "=== falloc, write beginning, read ==="
55 $XFS_IO_PROG -f                 \
56         -c 'falloc 0 512'       \
57         -c 'pwrite 0 1'         \
58         -c 'pread -v 0 512'     \
59         $TEST_DIR/test214-2 | _filter_xfs_io_unique
60
61 # Same but write in the middle of the region
62 echo "=== falloc, write middle, read ==="
63 $XFS_IO_PROG -f                 \
64         -c 'falloc 0 512'       \
65         -c 'pwrite 256 1'       \
66         -c 'pread -v 0 512'     \
67         $TEST_DIR/test214-3 | _filter_xfs_io_unique
68
69 # Same but write the end of the region
70 echo "=== falloc, write end, read ==="
71 $XFS_IO_PROG -f                 \
72         -c 'falloc 0 512'       \
73         -c 'pwrite 511 1'       \
74         -c 'pread -v 0 512'     \
75         $TEST_DIR/test214-4 | _filter_xfs_io_unique
76
77 # Reported by IBM on ext4.
78 #
79 # Fixed by commit a41f20716975910d9beb90b7efc61107901492b8
80 #
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.
86
87 echo "=== falloc, write, sync, truncate, read ==="
88 # Allocate, write, sync, truncate (buffered)
89 $XFS_IO_PROG -f                                 \
90         -c 'falloc         0x0     0x65C00'     \
91         -c 'pwrite -S 0xAA 0x12000 0x10000'     \
92         -c 'fsync'                              \
93         -c 'truncate 0x16000'                   \
94         $TEST_DIR/test214-5 | _filter_xfs_io_unique
95
96 # now do a direct read and see what's on-disk
97 $XFS_IO_PROG -f -d                              \
98         -c 'pread -v 0 0x16000'                 \
99         $TEST_DIR/test214-5 | _filter_xfs_io_unique
100
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
104
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.
108
109 $XFS_IO_PROG -f                                 \
110         -c "pwrite 0 16k"                       \
111         -c "falloc 0 16k"                       \
112         -c "fsync"                              \
113         $TEST_DIR/test214-6 | _filter_xfs_io_unique
114
115 # Another ext4 failure
116
117 echo "=== ext4 testcase 2 ==="
118
119 $XFS_IO_PROG -f \
120         -c "fsync"                      \
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
126
127 # success, all done
128 status=0
129 exit