2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
7 # Run fsx with log writes on cloned files to verify power fail safeness.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
14 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
22 # get standard environment, filters and checks
26 . ./common/dmlogwrites
28 # real QA test starts here
32 _require_scratch_reflink
42 # Now look for our files
43 for i in $(find $SANITY_DIR -type f | grep $name | grep mark); do
44 local filename=$(basename $i)
45 local mark="${filename##*.}"
46 echo "checking $filename" >> $seqres.full
47 _log_writes_replay_log $filename $SCRATCH_DEV
49 local expected_md5=$(_md5_checksum $i)
50 local md5=$(_md5_checksum $SCRATCH_MNT/$name)
51 [ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"
57 SANITY_DIR=$TEST_DIR/fsxtests
62 _log_writes_init $SCRATCH_DEV
64 _log_writes_mkfs >> $seqres.full 2>&1
66 # Log writes emulates discard support, turn it on for maximum crying.
67 _log_writes_mount -o discard
69 # write testfile index -1 to be cloned to testfile0
70 $XFS_IO_PROG -f -c "pwrite -S 0xff 0 256k" -c "fsync" \
71 $SCRATCH_MNT/testfile-1 > /dev/null 2>&1
75 FSX_OPTS="-N $NUM_OPS -d -k -P $SANITY_DIR -i $LOGWRITES_DMDEV"
77 # Set random seeds for fsx runs (0 for timestamp + pid)
78 for j in `seq 0 $((NUM_FILES-1))`; do
79 # clone the clone from prev iteration which may have already mutated
80 _cp_reflink $SCRATCH_MNT/testfile$((j-1)) $SCRATCH_MNT/testfile$j
81 run_check $here/ltp/fsx $FSX_OPTS -S 0 -j $j $SCRATCH_MNT/testfile$j &
86 for j in `seq 0 $((NUM_FILES-1))`; do
87 test_md5[$j]=$(_md5_checksum $SCRATCH_MNT/testfile$j)
90 # Unmount the scratch dir and tear down the log writes target
98 echo "checking pre umount" >> $seqres.full
99 _log_writes_replay_log last $SCRATCH_DEV
104 for j in `seq 0 $((NUM_FILES-1))`; do
105 check_files testfile$j
109 echo "checking post umount" >> $seqres.full
110 _log_writes_replay_log end $SCRATCH_DEV
112 for j in `seq 0 $((NUM_FILES-1))`; do
113 md5=$(_md5_checksum $SCRATCH_MNT/testfile$j)
114 [ "${md5}" != "${test_md5[$j]}" ] && _fail "testfile$j end md5sum mismatched"
117 echo "Silence is golden"