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, but it
10 # applies to most other filesystems.
12 # Use only a single CPU to test the single threaded situation.
15 _begin_fstest auto quick shutdown unlink
16 testfile=$TEST_DIR/$seq.txt
18 # Import common functions.
20 # real QA test starts here
23 _require_scratch_shutdown
24 _require_metadata_journaling
25 _require_test_program "t_open_tmpfiles"
27 _scratch_mkfs >> $seqres.full 2>&1
30 # Set ULIMIT_NOFILE to min(file-max / 2, 50000 files per LOAD_FACTOR)
31 # so that this test doesn't take forever or OOM the box
32 max_files=$((50000 * LOAD_FACTOR))
33 max_allowable_files=$(( $(cat /proc/sys/fs/file-max) / 2 ))
34 test $max_allowable_files -gt 0 && test $max_files -gt $max_allowable_files && \
35 max_files=$max_allowable_files
38 # Open a lot of unlinked files
39 echo create >> $seqres.full
40 $here/src/t_open_tmpfiles $SCRATCH_MNT $(_scratch_shutdown_handle) >> $seqres.full
42 # Unmount to prove that we can clean it all
43 echo umount >> $seqres.full
47 echo "Unmount took $((after - before))s." >> $seqres.full
49 # Mount so that we can run the usual checks
50 echo silence is golden