2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Red Hat, Inc. All Rights Reserved.
7 # Test stale data exposure via writeback using various file allocation
8 # modification commands. The presumption is that such commands result in partial
9 # writeback and can convert a delayed allocation extent, that might be larger
10 # than the ranged affected by fallocate, to a normal extent. If the fs happens
11 # to crash sometime between when the extent modification is logged and writeback
12 # occurs for dirty pages within the extent but outside of the fallocated range,
13 # stale data exposure can occur.
16 _begin_fstest shutdown rw punch zero
18 # Import common functions.
22 # real QA test starts here
27 img=$SCRATCH_MNT/$seq.img
28 mnt=$SCRATCH_MNT/$seq.mnt
32 # 25M is too small for f2fs.
33 if [ $FSTYP == "f2fs" ]; then
37 # Create an fs on a small, initialized image. The pattern is written to
38 # the image to detect stale data exposure.
39 $XFS_IO_PROG -f -c "truncate 0" -c "pwrite -S 0xCD 0 $size" $img \
41 _mkfs_dev $img >> $seqres.full 2>&1
48 # write, run the test command and shutdown the fs
49 $XFS_IO_PROG -f -c "pwrite -S 1 0 64k" -c "$cmd 60k 4k" $file | \
51 $here/src/godown -f $mnt
56 # We should /never/ see 0xCD in the file, because we wrote that pattern
57 # to the filesystem image to expose stale data.
58 if hexdump -v -e '/1 "%02X "' $file | grep -q "CD"; then
59 echo "Saw stale data!!!"
66 # Modify as appropriate.
69 _require_scratch_shutdown
70 _require_xfs_io_command "falloc"
71 _require_xfs_io_command "fpunch"
72 _require_xfs_io_command "fzero"
74 _scratch_mkfs >/dev/null 2>&1
75 _require_local_device $SCRATCH_DEV
76 _require_metadata_journaling $SCRATCH_DEV
79 _crashtest "falloc -k"