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 _begin_fstest auto log replay clone
12 # Override the default cleanup function.
19 # Import common functions.
23 . ./common/dmlogwrites
25 # real QA test starts here
28 _require_scratch_reflink
31 _require_dm_target thin-pool
37 # Now look for our files
38 for i in $(find $SANITY_DIR -type f | grep $name | grep mark); do
39 local filename=$(basename $i)
40 local mark="${filename##*.}"
41 echo "checking $filename" >> $seqres.full
42 _log_writes_replay_log $filename $DMTHIN_VOL_DEV
44 local expected_md5=$(_md5_checksum $i)
45 local md5=$(_md5_checksum $SCRATCH_MNT/$name)
46 [ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"
51 SANITY_DIR=$TEST_DIR/fsxtests
55 devsize=$((1024*1024*200 / 512)) # 200m phys/virt size
56 csize=$((1024*64 / 512)) # 64k cluster size
57 lowspace=$((1024*1024 / 512)) # 1m low space threshold
59 # Use a thin device to provide deterministic discard behavior. Discards are used
60 # by the log replay tool for fast zeroing to prevent out-of-order replay issues.
61 _dmthin_init $devsize $devsize $csize $lowspace
64 _log_writes_init $DMTHIN_VOL_DEV
66 _log_writes_mkfs >> $seqres.full 2>&1
68 # Log writes emulates discard support, turn it on for maximum crying.
69 _log_writes_mount -o discard
71 # write testfile index -1 to be cloned to testfile0
72 $XFS_IO_PROG -f -c "pwrite -S 0xff 0 256k" -c "fsync" \
73 $SCRATCH_MNT/testfile-1 > /dev/null 2>&1
77 FSX_OPTS="-N $NUM_OPS -d -k -P $SANITY_DIR -i $LOGWRITES_DMDEV"
79 # Set random seeds for fsx runs (0 for timestamp + pid)
80 for j in `seq 0 $((NUM_FILES-1))`; do
81 # clone the clone from prev iteration which may have already mutated
82 _cp_reflink $SCRATCH_MNT/testfile$((j-1)) $SCRATCH_MNT/testfile$j
83 run_check $here/ltp/fsx $FSX_OPTS -S 0 -j $j $SCRATCH_MNT/testfile$j &
88 for j in `seq 0 $((NUM_FILES-1))`; do
89 test_md5[$j]=$(_md5_checksum $SCRATCH_MNT/testfile$j)
92 # Unmount the scratch dir and tear down the log writes target
100 echo "checking pre umount" >> $seqres.full
101 _log_writes_replay_log last $DMTHIN_VOL_DEV
105 for j in `seq 0 $((NUM_FILES-1))`; do
106 check_files testfile$j
110 echo "checking post umount" >> $seqres.full
111 _log_writes_replay_log end $DMTHIN_VOL_DEV
113 for j in `seq 0 $((NUM_FILES-1))`; do
114 md5=$(_md5_checksum $SCRATCH_MNT/testfile$j)
115 [ "${md5}" != "${test_md5[$j]}" ] && _fail "testfile$j end md5sum mismatched"
118 echo "Silence is golden"