summaryrefslogtreecommitdiff
path: root/tests/generic/561
blob: 44f078022f965afb31276c1f33721a9a3c8affc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Red Hat Inc.  All Rights Reserved.
#
# FS QA Test generic/561
#
# Dedup & random I/O race test, do multi-threads fsstress and dedupe on
# same directory/files
#
. ./common/preamble
_begin_fstest auto stress dedupe

# Override the default cleanup function.
_cleanup()
{
	cd /
	rm -f $tmp.*
	end_test
}

# Import common functions.
. ./common/filter
. ./common/reflink

# real QA test starts here
_supported_fs generic
_require_scratch_duperemove
_require_command "$KILLALL_PROG" killall

_scratch_mkfs > $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1

function end_test()
{
	local f=1

	# stop duperemove running
	if [ -e $dupe_run ]; then
		rm -f $dupe_run
		$KILLALL_PROG -q $DUPEREMOVE_PROG > /dev/null 2>&1
		wait $dedup_pids
	fi

	# Make sure all fsstress get killed
	while [ $f -ne 0 ]; do
		$KILLALL_PROG -q $FSSTRESS_PROG > /dev/null 2>&1
		sleep 1
		f=`ps -eLf | grep $FSSTRESS_PROG | grep -v "grep" | wc -l`
	done
}

sleep_time=$((50 * TIME_FACTOR))

# Start fsstress
testdir="$SCRATCH_MNT/dir"
mkdir $testdir
fsstress_opts="-r -n 1000 -p $((5 * LOAD_FACTOR))"
$FSSTRESS_PROG $fsstress_opts -d $testdir -l 0 >> $seqres.full 2>&1 &
dedup_pids=""
dupe_run=$TEST_DIR/${seq}-running
# Start several dedupe processes on same directory
touch $dupe_run
for ((i = 0; i < $((2 * LOAD_FACTOR)); i++)); do
	while [ -e $dupe_run ]; do
		# Run cmd in a subshell so that the golden output does not
		# capture assertions that trigger when killall shoots down
		# dupremove processes in an arbitrary order, which leaves the
		# memory in an inconsistent state long enough for the assert
		# to trip.
		cmd="$DUPEREMOVE_PROG -dr --dedupe-options=same $testdir"
		bash -c "$cmd" >> $seqres.full 2>&1
	done 2>&1 | sed -e '/Terminated/d' &
	dedup_pids="$! $dedup_pids"
done

# End the test after $sleep_time seconds
sleep $sleep_time
end_test

# umount and mount again, verify pagecache contents don't mutate and a fresh
# read from the disk also doesn't show mutations.
find $testdir -type f -exec md5sum {} \; > ${tmp}.md5sum
_scratch_cycle_mount
md5sum -c --quiet ${tmp}.md5sum

echo "Silence is golden"
status=0
exit