2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat Inc. All Rights Reserved.
5 # FS QA Test generic/561
7 # Dedup & random I/O race test, do multi-threads fsstress and dedupe on
11 _begin_fstest auto stress dedupe
13 # Override the default cleanup function.
21 # Import common functions.
25 # real QA test starts here
27 _require_scratch_duperemove
28 _require_command "$KILLALL_PROG" killall
30 _scratch_mkfs > $seqres.full 2>&1
31 _scratch_mount >> $seqres.full 2>&1
37 # stop duperemove running
38 if [ -e $dupe_run ]; then
40 $KILLALL_PROG -q $DUPEREMOVE_PROG > /dev/null 2>&1
44 # Make sure all fsstress get killed
45 while [ $f -ne 0 ]; do
46 $KILLALL_PROG -q $FSSTRESS_PROG > /dev/null 2>&1
48 f=`ps -eLf | grep $FSSTRESS_PROG | grep -v "grep" | wc -l`
52 sleep_time=$((50 * TIME_FACTOR))
55 testdir="$SCRATCH_MNT/dir"
57 fsstress_opts="-r -n 1000 -p $((5 * LOAD_FACTOR))"
58 $FSSTRESS_PROG $fsstress_opts -d $testdir -l 0 >> $seqres.full 2>&1 &
60 dupe_run=$TEST_DIR/${seq}-running
61 # Start several dedupe processes on same directory
63 for ((i = 0; i < $((2 * LOAD_FACTOR)); i++)); do
64 while [ -e $dupe_run ]; do
65 # Run cmd in a subshell so that the golden output does not
66 # capture assertions that trigger when killall shoots down
67 # dupremove processes in an arbitrary order, which leaves the
68 # memory in an inconsistent state long enough for the assert
70 cmd="$DUPEREMOVE_PROG -dr --dedupe-options=same $testdir"
71 bash -c "$cmd" >> $seqres.full 2>&1
72 done 2>&1 | sed -e '/Terminated/d' &
73 dedup_pids="$! $dedup_pids"
76 # End the test after $sleep_time seconds
80 # umount and mount again, verify pagecache contents don't mutate and a fresh
81 # read from the disk also doesn't show mutations.
82 find $testdir -type f -exec md5sum {} \; > ${tmp}.md5sum
84 md5sum -c --quiet ${tmp}.md5sum
86 echo "Silence is golden"