summaryrefslogtreecommitdiff
path: root/tests/xfs/502
blob: fb9a82c15997a6484d8c3b3e7a73fb6913502b1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2019 Oracle, Inc.  All Rights Reserved.
#
# FS QA Test No. 502
#
# Stress test creating a lot of unlinked O_TMPFILE files and closing them
# all at once, checking that we don't blow up the filesystem.  This is sort
# of a performance test for the xfs unlinked inode backref patchset.
#
# Here we force the use of the slow iunlink bucket walk code, using every
# CPU possible.
#
. ./common/preamble
_begin_fstest auto quick unlink
testfile=$TEST_DIR/$seq.txt

# Import common functions.
. ./common/inject
. ./common/filter

# real QA test starts here
_supported_fs xfs
_require_xfs_io_error_injection "iunlink_fallback"
_require_scratch
_require_test_program "t_open_tmpfiles"

_scratch_mkfs | _filter_mkfs 2> $tmp.mkfs > /dev/null
cat $tmp.mkfs >> $seqres.full
. $tmp.mkfs

_scratch_mount

# Load up all the CPUs, two threads per CPU.
nr_cpus=$(( $(getconf _NPROCESSORS_ONLN) * 2 ))

# Set ULIMIT_NOFILE to min(file-max / $nr_cpus / 2, 50000 files per AG per LOAD_FACTOR)
# so that this test doesn't take forever or OOM the box
max_files=$((50000 * agcount * LOAD_FACTOR))
max_files=$((max_files / $nr_cpus))

max_allowable_files=$(( $(cat /proc/sys/fs/file-max) / $nr_cpus / 2 ))
test $max_allowable_files -gt 0 && test $max_files -gt $max_allowable_files && \
	max_files=$max_allowable_files
ulimit -n $max_files

# Force xfs to use the iunlinked fallback 50% of the time
_scratch_inject_error "iunlink_fallback" "2"

# Open a lot of unlinked files
echo create >> $seqres.full
for i in $(seq 1 $nr_cpus); do
	mkdir $SCRATCH_MNT/$i
	$here/src/t_open_tmpfiles $SCRATCH_MNT/$i >> $seqres.full &
done
wait

# Unmount to prove that we can clean it all
echo umount >> $seqres.full
before=$(date +%s)
_scratch_unmount
after=$(date +%s)
echo "Unmount took $((after - before))s." >> $seqres.full

# Mount so that we can run the usual checks
echo silence is golden
_scratch_mount
status=0
exit