2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright 2019 Google LLC
5 # FS QA Test generic/579
7 # Stress test for fs-verity. This tests enabling fs-verity on multiple files
8 # concurrently with concurrent readers on those files (with reads occurring
9 # before, during, and after the fs-verity enablement), while fsstress is also
10 # running on the same filesystem.
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
23 # Stop all subprocesses.
24 $KILLALL_PROG -q $FSSTRESS_PROG
31 # get standard environment, filters and checks
36 # remove previous $seqres.full before test
39 # real QA test starts here
42 _require_scratch_verity
43 _require_command "$KILLALL_PROG" killall
45 _scratch_mkfs_verity &>> $seqres.full
48 fsv_file_size=10000000
49 nproc_enabler=$((4 * LOAD_FACTOR))
50 nproc_reader=$((6 * LOAD_FACTOR))
51 nproc_stress=$((3 * LOAD_FACTOR))
52 runtime=$((20 * TIME_FACTOR))
54 # Create the test files and start the fs-verity enabler processes.
55 for ((proc = 0; proc < nproc_enabler; proc++)); do
56 orig_file=$SCRATCH_MNT/orig$proc
57 fsv_file=$SCRATCH_MNT/fsv$proc
58 head -c $fsv_file_size /dev/urandom > $orig_file
60 while [ ! -e $tmp.done ]; do
62 cp $orig_file $fsv_file
64 # Give the readers some time to read from the file.
65 sleep 0.$((RANDOM % 100))
70 # Start the reader processes.
71 for ((proc = 0; proc < nproc_reader; proc++)); do
73 while [ ! -e $tmp.done ]; do
74 # Choose a random file for each iteration, so that
75 # sometimes multiple processes read from the same file.
76 i=$((RANDOM % nproc_enabler))
77 orig_file=$SCRATCH_MNT/orig$i
78 fsv_file=$SCRATCH_MNT/fsv$i
80 # After the copy from $orig_file to $fsv_file has
81 # completed, the contents of these two files should
82 # match, regardless of whether verity has been enabled
83 # or not yet (or is currently being enabled).
84 cmp $orig_file $fsv_file |& _filter_scratch | \
85 grep -v "SCRATCH_MNT/fsv$i: No such file or directory" | \
86 grep -v "EOF on SCRATCH_MNT/fsv$i"
88 _fsv_measure $fsv_file 2>&1 >/dev/null | \
89 grep -v "No such file or directory" | \
90 grep -v "No data available"
95 # Start a process that occasionally runs 'sync && drop_caches'. This makes more
96 # reads go through fs-verity for real, rather than just returning pagecache.
98 while [ ! -e $tmp.done ]; do
99 sleep 2.$((RANDOM % 100))
100 sync && echo 3 > /proc/sys/vm/drop_caches
104 # Start the fsstress processes.
105 $FSSTRESS_PROG $FSSTRESS_AVOID -p $nproc_stress -l 0 -d $SCRATCH_MNT/stressdir \
106 >> $seqres.full 2>&1 &
111 echo "Silence is golden"