2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc. All Rights Reserved.
7 # Run delalloc writes & append writes & non-data-integrity syncs concurrently
8 # to test the race between block map change vs writeback.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
38 # get a random file to work on
41 echo $SCRATCH_MNT/$((RANDOM % MAXFILES))
44 # delalloc write a relative big file to get enough dirty pages to be written
45 # back, and XFS needs big enough file to trigger speculative preallocations, so
46 # freeing these eofblocks could change the extent record
49 local blockcount=$((RANDOM % 100))
50 local filesize=$((blockcount * BLOCK_SZ))
51 $XFS_IO_PROG -ftc "pwrite -b $BLOCK_SZ 0 $filesize" `getfile` \
55 # append another dirty page to the file, the writeback might pick it up too if
56 # the file is already under writeback
59 echo "test string" >> `getfile`
62 # issue WB_SYNC_NONE writeback with the '-w' option of sync_range xfs_io
63 # command, so that the last dirty page from append write can be picked up in
64 # this writeback cycle. This is not mandatory but could help reproduce XFS
65 # corruption more easily.
68 $XFS_IO_PROG -c "sync_range -w 0 0" `getfile` >/dev/null 2>&1
71 # remove previous $seqres.full before test
74 # real QA test starts here
76 # do fsck after each iteration in test
77 _require_scratch_nocheck
78 _require_xfs_io_command "sync_range"
80 _scratch_mkfs >>$seqres.full 2>&1
83 # loop for $LOOP_CNT iterations, and each iteration starts $PROC_CNT processes
84 # for each operation and runs for $LOOP_TIME seconds, and check filesystem
85 # consistency after each iteration
86 for i in `seq 1 $LOOP_CNT`; do
88 for j in `seq 1 $PROC_CNT`; do
89 while [ ! -e $stop ]; do
93 while [ ! -e $stop ]; do
97 while [ ! -e $stop ]; do
106 # test exits here if fs is inconsistent
111 echo "Silence is golden"