4 # Test stale data exposure via writeback using various file allocation
5 # modification commands. The presumption is that such commands result in partial
6 # writeback and can convert a delayed allocation extent, that might be larger
7 # than the ranged affected by fallocate, to a normal extent. If the fs happens
8 # to crash sometime between when the extent modification is logged and writeback
9 # occurs for dirty pages within the extent but outside of the fallocated range,
10 # stale data exposure can occur.
12 #-----------------------------------------------------------------------
13 # Copyright (c) 2014 Red Hat, Inc. All Rights Reserved.
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #-----------------------------------------------------------------------
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
36 status=1 # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
45 # get standard environment, filters and checks
50 # real QA test starts here
56 img=$SCRATCH_MNT/$seq.img
57 mnt=$SCRATCH_MNT/$seq.mnt
60 # Create an fs on a small, initialized image. The pattern is written to
61 # the image to detect stale data exposure.
62 $XFS_IO_PROG -f -c "truncate 0" -c "pwrite 0 25M" $img \
64 _mkfs_dev $img >> $seqres.full 2>&1
71 # write, run the test command and shutdown the fs
72 $XFS_IO_PROG -f -c "pwrite -S 1 0 64k" -c "$cmd 60k 4k" $file | \
79 # we generally expect a zero-sized file (this should be silent)
85 # Modify as appropriate.
89 _require_scratch_shutdown
90 _require_xfs_io_command "falloc"
91 _require_xfs_io_command "fpunch"
92 _require_xfs_io_command "fzero"
94 _scratch_mkfs >/dev/null 2>&1
95 _require_metadata_journaling $SCRATCH_DEV
98 _crashtest "falloc -k"
100 _crashtest "fzero -k"