4 # Run fsx with log writes on cloned files to verify power fail safeness.
6 #-----------------------------------------------------------------------
7 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
8 # Author: Amir Goldstein <amir73il@gmail.com>
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
30 status=1 # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
42 . ./common/dmlogwrites
44 # real QA test starts here
48 _require_scratch_reflink
58 # Now look for our files
59 for i in $(find $SANITY_DIR -type f | grep $name | grep mark); do
60 local filename=$(basename $i)
61 local mark="${filename##*.}"
62 echo "checking $filename" >> $seqres.full
63 _log_writes_replay_log $filename
65 local expected_md5=$(_md5_checksum $i)
66 local md5=$(_md5_checksum $SCRATCH_MNT/$name)
67 [ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"
73 SANITY_DIR=$TEST_DIR/fsxtests
80 _log_writes_mkfs >> $seqres.full 2>&1
82 # Log writes emulates discard support, turn it on for maximum crying.
83 _log_writes_mount -o discard
85 # write testfile index -1 to be cloned to testfile0
86 $XFS_IO_PROG -f -c "pwrite -S 0xff 0 256k" -c "fsync" \
87 $SCRATCH_MNT/testfile-1 > /dev/null 2>&1
91 FSX_OPTS="-N $NUM_OPS -d -k -P $SANITY_DIR -i $LOGWRITES_DMDEV"
93 # Set random seeds for fsx runs (0 for timestamp + pid)
94 for j in `seq 0 $((NUM_FILES-1))`; do
95 # clone the clone from prev iteration which may have already mutated
96 _cp_reflink $SCRATCH_MNT/testfile$((j-1)) $SCRATCH_MNT/testfile$j
97 run_check $here/ltp/fsx $FSX_OPTS -S 0 -j $j $SCRATCH_MNT/testfile$j &
102 for j in `seq 0 $((NUM_FILES-1))`; do
103 test_md5[$j]=$(_md5_checksum $SCRATCH_MNT/testfile$j)
106 # Unmount the scratch dir and tear down the log writes target
107 _log_writes_mark last
114 echo "checking pre umount" >> $seqres.full
115 _log_writes_replay_log last
120 for j in `seq 0 $((NUM_FILES-1))`; do
121 check_files testfile$j
125 echo "checking post umount" >> $seqres.full
126 _log_writes_replay_log end
128 for j in `seq 0 $((NUM_FILES-1))`; do
129 md5=$(_md5_checksum $SCRATCH_MNT/testfile$j)
130 [ "${md5}" != "${test_md5[$j]}" ] && _fail "testfile$j end md5sum mismatched"
133 echo "Silence is golden"