2 # SPDX-License-Identifier: GPL-2.0+
3 # Copyright (c) 2019 Oracle, Inc. All Rights Reserved.
7 # Stress test creating a lot of unlinked O_TMPFILE files and closing them
8 # all at once, checking that we don't blow up the filesystem. This is sort
9 # of a performance test for the xfs unlinked inode backref patchset.
11 # Here we force the use of the slow iunlink bucket walk code, using every
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 testfile=$TEST_DIR/$seq.txt
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
33 # real QA test starts here
35 _require_xfs_io_error_injection "iunlink_fallback"
37 _require_test_program "t_open_tmpfiles"
41 _scratch_mkfs | _filter_mkfs 2> $tmp.mkfs > /dev/null
42 cat $tmp.mkfs >> $seqres.full
47 # Load up all the CPUs, two threads per CPU.
48 nr_cpus=$(( $(getconf _NPROCESSORS_ONLN) * 2 ))
50 # Set ULIMIT_NOFILE to min(file-max / $nr_cpus / 2, 50000 files per AG per LOAD_FACTOR)
51 # so that this test doesn't take forever or OOM the box
52 max_files=$((50000 * agcount * LOAD_FACTOR))
53 max_files=$((max_files / $nr_cpus))
55 max_allowable_files=$(( $(cat /proc/sys/fs/file-max) / $nr_cpus / 2 ))
56 test $max_allowable_files -gt 0 && test $max_files -gt $max_allowable_files && \
57 max_files=$max_allowable_files
60 # Force xfs to use the iunlinked fallback 50% of the time
61 _scratch_inject_error "iunlink_fallback" "2"
63 # Open a lot of unlinked files
64 echo create >> $seqres.full
65 for i in $(seq 1 $nr_cpus); do
67 $here/src/t_open_tmpfiles $SCRATCH_MNT/$i >> $seqres.full &
71 # Unmount to prove that we can clean it all
72 echo umount >> $seqres.full
76 echo "Unmount took $((after - before))s." >> $seqres.full
78 # Mount so that we can run the usual checks
79 echo silence is golden