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 recovering them
8 # after a crash, 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 in a single
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
22 delay_knob="/sys/fs/xfs/debug/log_recovery_delay"
27 test -e "$delay_knob" && echo 0 > "$delay_knob"
31 # get standard environment, filters and checks
35 # real QA test starts here
37 _require_xfs_io_error_injection "iunlink_fallback"
38 _require_xfs_sysfs debug/log_recovery_delay
40 _require_test_program "t_open_tmpfiles"
43 _scratch_mkfs >> $seqres.full 2>&1
46 # Set ULIMIT_NOFILE to min(file-max / 2, 30000 files per LOAD_FACTOR)
47 # so that this test doesn't take forever or OOM the box
48 max_files=$((30000 * LOAD_FACTOR))
49 max_allowable_files=$(( $(cat /proc/sys/fs/file-max) / 2 ))
50 test $max_allowable_files -gt 0 && test $max_files -gt $max_allowable_files && \
51 max_files=$max_allowable_files
54 # Open a lot of unlinked files
55 echo create >> $seqres.full
56 $here/src/t_open_tmpfiles $SCRATCH_MNT $(_scratch_shutdown_handle) >> $seqres.full
58 # Unmount to prove that we can clean it all
59 echo umount >> $seqres.full
63 echo "Unmount took $((after - before))s." >> $seqres.full
65 # Force xfs to use the iunlinked fallback 50% of the time
67 # Slow down log recovery by 5s to give us enough time to set up
69 echo 5 > "$delay_knob"
71 # Try for 10s to set our knob.
72 knob="$(_find_xfs_mountdev_errortag_knob "${SCRATCH_DEV}" iunlink_fallback)"
74 while [ ! -e "$knob" ] && [ "$nr" -lt 20 ]; do
78 if [ -e "$knob" ]; then
81 echo "unable to set iunlink_fallback?"
85 # Mount so that we can run the usual checks
86 echo silence is golden