generic/402: Drop useless fail message
[xfstests-dev.git] / tests / generic / 536
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 536
6 #
7 # Test a some write patterns for stale data exposure after a crash.  XFS is
8 # historically susceptible to this problem in the window between delalloc to
9 # physical extent conversion and writeback completion.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # real QA test starts here
33
34 # Modify as appropriate.
35 _supported_fs generic
36 _require_scratch
37 _require_scratch_shutdown
38
39 # create a small fs and initialize free blocks with a unique pattern
40 _scratch_mkfs_sized $((1024 * 1024 * 100)) >> $seqres.full 2>&1
41 _scratch_mount
42 $XFS_IO_PROG -f -c "pwrite -S 0xab 0 100m" -c fsync $SCRATCH_MNT/spc \
43         >> $seqres.full 2>&1
44 rm -f $SCRATCH_MNT/spc
45 $XFS_IO_PROG -c fsync $SCRATCH_MNT
46
47 # Write a couple files with particular writeback sequences. The first writes a
48 # delalloc extent and triggers writeback on the last page. The second triggers
49 # post-eof preallocation (on XFS), write extends into the preallocation and
50 # triggers writeback of the last written page.
51 $XFS_IO_PROG -fc "pwrite 0 256k" -c "sync_range -w 252k 4k" \
52         -c "sync_range -a 252k 4k" $SCRATCH_MNT/file.1 >> $seqres.full 2>&1
53 $XFS_IO_PROG -fc "pwrite 0 260k" -c fsync -c "pwrite 1536k 4k" \
54         -c "sync_range -w 1536k 4k" -c "sync_range -a 1536k 4k" \
55         $SCRATCH_MNT/file.2 >> $seqres.full 2>&1
56
57 # Shut down before any other writeback completes. Flush the log to persist inode
58 # size updates.
59 _scratch_shutdown -f
60
61 # Now search both files for stale bytes. The region prior to the last page in
62 # the first file should be zero filled. The region between the two writes to the
63 # second file should also be zero filled.
64 _scratch_cycle_mount
65 echo file.1 | tee -a $seqres.full
66 hexdump $SCRATCH_MNT/file.1 | tee -a $seqres.full | grep ab
67 echo file.2 | tee -a $seqres.full
68 hexdump $SCRATCH_MNT/file.2 | tee -a $seqres.full | grep ab
69
70 status=0
71 exit