fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / generic / 455
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Facebook. All Rights Reserved.
4 #
5 # FS QA Test No. 455
6 #
7 # Run fsx with log writes to verify power fail safeness.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 status=1        # failure is the default!
15
16 _cleanup()
17 {
18         _log_writes_cleanup
19         _dmthin_cleanup
20 }
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 # get standard environment, filters and checks
24 . ./common/rc
25 . ./common/filter
26 . ./common/dmthin
27 . ./common/dmlogwrites
28
29 # real QA test starts here
30 _supported_fs generic
31 _require_test
32 _require_scratch_nocheck
33 _require_log_writes
34 _require_dm_target thin-pool
35
36 rm -f $seqres.full
37
38 check_files()
39 {
40         local name=$1
41
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 $DMTHIN_VOL_DEV
48                 _dmthin_mount
49                 local expected_md5=$(_md5_checksum $i)
50                 local md5=$(_md5_checksum $SCRATCH_MNT/$name)
51                 [ "${md5}" != "${expected_md5}" ] && _fail "$filename md5sum mismatched"
52                 _dmthin_check_fs
53         done
54 }
55
56 SANITY_DIR=$TEST_DIR/fsxtests
57 rm -rf $SANITY_DIR
58 mkdir $SANITY_DIR
59
60 devsize=$((1024*1024*200 / 512))        # 200m phys/virt size
61 csize=$((1024*64 / 512))                # 64k cluster size
62 lowspace=$((1024*1024 / 512))           # 1m low space threshold
63
64 # Use a thin device to provide deterministic discard behavior. Discards are used
65 # by the log replay tool for fast zeroing to prevent out-of-order replay issues.
66 _dmthin_init $devsize $devsize $csize $lowspace
67
68 # Create the log
69 _log_writes_init $DMTHIN_VOL_DEV
70
71 _log_writes_mkfs >> $seqres.full 2>&1
72
73 # Log writes emulates discard support, turn it on for maximum crying.
74 _log_writes_mount -o discard
75
76 NUM_FILES=4
77 NUM_OPS=200
78 FSX_OPTS="-N $NUM_OPS -d -P $SANITY_DIR -i $LOGWRITES_DMDEV"
79 # Set random seeds for fsx runs (0 for timestamp + pid)
80 # When test failure is detected, check the seed values printed
81 # by fsx processes to $seqres.full and set them in this array
82 # to repeat the same fsx runs
83 seeds=(0 0 0 0)
84 # Run fsx for a while
85 for j in `seq 0 $((NUM_FILES-1))`; do
86         run_check $here/ltp/fsx $FSX_OPTS -S ${seeds[$j]} -j $j $SCRATCH_MNT/testfile$j &
87 done
88 wait
89
90 test_md5=()
91 for j in `seq 0 $((NUM_FILES-1))`; do
92         test_md5[$j]=$(_md5_checksum $SCRATCH_MNT/testfile$j)
93 done
94
95 # Unmount the scratch dir and tear down the log writes target
96 _log_writes_mark last
97 _log_writes_unmount
98 _log_writes_mark end
99 _log_writes_remove
100 _dmthin_check_fs
101
102 # check pre umount
103 echo "checking pre umount" >> $seqres.full
104 _log_writes_replay_log last $DMTHIN_VOL_DEV
105 _dmthin_mount
106 _dmthin_check_fs
107
108 for j in `seq 0 $((NUM_FILES-1))`; do
109         check_files testfile$j
110 done
111
112 # Check the end
113 echo "checking post umount" >> $seqres.full
114 _log_writes_replay_log end $DMTHIN_VOL_DEV
115 _dmthin_mount
116 for j in `seq 0 $((NUM_FILES-1))`; do
117         md5=$(_md5_checksum $SCRATCH_MNT/testfile$j)
118         [ "${md5}" != "${test_md5[$j]}" ] && _fail "testfile$j end md5sum mismatched"
119 done
120 _dmthin_check_fs
121
122 echo "Silence is golden"
123 status=0
124 exit