generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 579
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright 2019 Google LLC
4 #
5 # FS QA Test generic/579
6 #
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.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         # Stop all subprocesses.
24         $KILLALL_PROG -q $FSSTRESS_PROG
25         touch $tmp.done
26         wait
27
28         _restore_fsverity_signatures
29         rm -f $tmp.*
30 }
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/filter
35 . ./common/verity
36
37 # remove previous $seqres.full before test
38 rm -f $seqres.full
39
40 # real QA test starts here
41 _supported_fs generic
42 _supported_os Linux
43 _require_scratch_verity
44 _require_command "$KILLALL_PROG" killall
45 _disable_fsverity_signatures
46
47 _scratch_mkfs_verity &>> $seqres.full
48 _scratch_mount
49
50 fsv_file_size=10000000
51 nproc_enabler=$((4 * LOAD_FACTOR))
52 nproc_reader=$((6 * LOAD_FACTOR))
53 nproc_stress=$((3 * LOAD_FACTOR))
54 runtime=$((20 * TIME_FACTOR))
55
56 # Create the test files and start the fs-verity enabler processes.
57 for ((proc = 0; proc < nproc_enabler; proc++)); do
58         orig_file=$SCRATCH_MNT/orig$proc
59         fsv_file=$SCRATCH_MNT/fsv$proc
60         head -c $fsv_file_size /dev/urandom > $orig_file
61         (
62                 while [ ! -e $tmp.done ]; do
63                         rm -f $fsv_file
64                         cp $orig_file $fsv_file
65                         _fsv_enable $fsv_file
66                         # Give the readers some time to read from the file.
67                         sleep 0.$((RANDOM % 100))
68                 done
69         ) &
70 done
71
72 # Start the reader processes.
73 for ((proc = 0; proc < nproc_reader; proc++)); do
74         (
75                 while [ ! -e $tmp.done ]; do
76                         # Choose a random file for each iteration, so that
77                         # sometimes multiple processes read from the same file.
78                         i=$((RANDOM % nproc_enabler))
79                         orig_file=$SCRATCH_MNT/orig$i
80                         fsv_file=$SCRATCH_MNT/fsv$i
81
82                         # After the copy from $orig_file to $fsv_file has
83                         # completed, the contents of these two files should
84                         # match, regardless of whether verity has been enabled
85                         # or not yet (or is currently being enabled).
86                         cmp $orig_file $fsv_file |& _filter_scratch | \
87                                 grep -v "SCRATCH_MNT/fsv$i: No such file or directory" | \
88                                 grep -v "EOF on SCRATCH_MNT/fsv$i"
89
90                         _fsv_measure $fsv_file 2>&1 >/dev/null | \
91                                 grep -v "No such file or directory" | \
92                                 grep -v "No data available"
93                 done
94         ) &
95 done
96
97 # Start a process that occasionally runs 'sync && drop_caches'.  This makes more
98 # reads go through fs-verity for real, rather than just returning pagecache.
99 (
100         while [ ! -e $tmp.done ]; do
101                 sleep 2.$((RANDOM % 100))
102                 sync && echo 3 > /proc/sys/vm/drop_caches
103         done
104 ) &
105
106 # Start the fsstress processes.
107 $FSSTRESS_PROG $FSSTRESS_AVOID -p $nproc_stress -l 0 -d $SCRATCH_MNT/stressdir \
108         >> $seqres.full 2>&1 &
109
110 # Run for a while.
111 sleep $runtime
112
113 echo "Silence is golden"
114
115 # success, all done
116 status=0
117 exit