stress2: Initial import
Discussed with: kib
This commit is contained in:
parent
3adf72a36b
commit
8a272653d9
@ -21,5 +21,6 @@ ppsapi Test 1 Pulse Per Second (1PPS) input for time control.
|
|||||||
pthread_vfork Check that vfork and pthreads work together.
|
pthread_vfork Check that vfork and pthreads work together.
|
||||||
ptrace Verify that ptrace works with syscalls, vfork etc.
|
ptrace Verify that ptrace works with syscalls, vfork etc.
|
||||||
sort Tests for the sort command, including a full regression.
|
sort Tests for the sort command, including a full regression.
|
||||||
|
stress2 Kernel stress tool.
|
||||||
testfloat Programs to test floating-point implementations
|
testfloat Programs to test floating-point implementations
|
||||||
upsdl Test of mmap functionality.
|
upsdl Test of mmap functionality.
|
||||||
|
11
tools/test/stress2/Makefile
Normal file
11
tools/test/stress2/Makefile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
SUBDIR= lib testcases
|
||||||
|
MK_AUTO_OBJ= no
|
||||||
|
|
||||||
|
.include <bsd.subdir.mk>
|
||||||
|
|
||||||
|
all: setup
|
||||||
|
|
||||||
|
setup:
|
||||||
|
@cd ${.CURDIR}; ./tools/setup.sh
|
||||||
|
test:
|
||||||
|
cd ${.CURDIR}/misc; pwd; ./all.sh -onc
|
20
tools/test/stress2/README
Normal file
20
tools/test/stress2/README
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
stress2 is a tool for finding problems in the kernel.
|
||||||
|
|
||||||
|
It is composed of a large number of regression tests, tests that
|
||||||
|
stress various components of the kernel and a few validation tests.
|
||||||
|
There are currently some 700 different tests.
|
||||||
|
|
||||||
|
The key idea behind stress2 is to randomize as much as possible in
|
||||||
|
a test, as a way of achieving better coverage. For example, varying
|
||||||
|
VM pressure, varying numbers of threads, varying delays, etc.
|
||||||
|
stress2 has found a large number of problems:
|
||||||
|
https://people.freebsd.org/~pho/stress/log/
|
||||||
|
|
||||||
|
To run the full test suite type "make test" in the stress2 directory.
|
||||||
|
|
||||||
|
To run a subset of tests, go to the stress2/misc directory.
|
||||||
|
To run for example all tmpfs tests, type ./all.sh -o $(grep -l tmpfs *.sh)
|
||||||
|
To run fdatasync.sh for one hour, type ./all.sh -m 60 fdatasync.sh"
|
||||||
|
To run dup2.sh three times, type ./all.sh -l 3 dup2.sh
|
||||||
|
|
||||||
|
Peter Holm <pho@FreeBSD.org>
|
8
tools/test/stress2/all.cfg
Normal file
8
tools/test/stress2/all.cfg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Stress Test Suite Configuration: run all test programs
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
. ./default.cfg
|
||||||
|
|
||||||
|
export TESTPROGS=""
|
||||||
|
export swapHOG=1
|
||||||
|
export swapLOAD=100
|
8
tools/test/stress2/creat.cfg
Normal file
8
tools/test/stress2/creat.cfg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Stress Test Suite Configuration
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
. ./default.cfg
|
||||||
|
|
||||||
|
export TESTPROGS="testcases/creat/creat"
|
||||||
|
export creatNODELAY=1
|
||||||
|
export creatLOAD=100
|
6
tools/test/stress2/ddb.conf
Normal file
6
tools/test/stress2/ddb.conf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# ddb commands used for stress2 crash reports
|
||||||
|
#
|
||||||
|
|
||||||
|
script pho1=bt; show allpcpu; show alllocks; show lockedvnods; show allchains; show mount; show bufqueues; show page; show pageq
|
||||||
|
script pho=set $lines 20000; run pho1; show freepages; acttrace; ps; allt; dump
|
||||||
|
|
122
tools/test/stress2/default.cfg
Normal file
122
tools/test/stress2/default.cfg
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
# Stress Test Suite Configuration.
|
||||||
|
|
||||||
|
# Changes should be added to a `hostname` file in this directory.
|
||||||
|
# As a minimum you must updated "testuser".
|
||||||
|
|
||||||
|
export SHELL=/bin/sh
|
||||||
|
: ${allconfig:=/tmp/stress2.d/`hostname`}
|
||||||
|
[ -f "$allconfig" ] && . $allconfig # Source in local configuration
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
export RUNDIR=${RUNDIR:-/tmp/stressX}
|
||||||
|
export RUNTIME=${RUNTIME:-2m}
|
||||||
|
export VERBOSE=${VERBOSE:-1}
|
||||||
|
export LOAD=${LOAD:-20}
|
||||||
|
|
||||||
|
# The INCARNATIONS variable may be set to match the number of CPUs and
|
||||||
|
# the amount of RAM in the test box.
|
||||||
|
export INCARNATIONS=${INCARNATIONS:-20}
|
||||||
|
|
||||||
|
export BLASTHOST=${BLASTHOST:-192.168.1.1} # host with udp discard enabled in inetd.conf
|
||||||
|
#export nfs_export=somehost:mount # Used by the NFS tests
|
||||||
|
|
||||||
|
# Run all test cases:
|
||||||
|
export runRUNTIME=${runRUNTIME:-3d} # Run tests for three days
|
||||||
|
export runINCARNATIONS=1
|
||||||
|
export runLOAD=100
|
||||||
|
|
||||||
|
export swapINCARNATIONS=${swapINCARNATIONS:-$((2 * INCARNATIONS))}
|
||||||
|
export swapLOAD=${swapLOAD:-80}
|
||||||
|
|
||||||
|
export syscallKILL=1
|
||||||
|
export swapKILL=1 # May takes a long time to stop
|
||||||
|
|
||||||
|
export rwLOAD=${rwLOAD:-70}
|
||||||
|
export mkdirLOAD=${mkdirLOAD:-80}
|
||||||
|
export creatLOAD=${creatLOAD:-80}
|
||||||
|
|
||||||
|
export symlinkLOAD=${symlinkLOAD:-20}
|
||||||
|
|
||||||
|
export tcpKILL=1
|
||||||
|
export shmINCARNATIONS=${shmINCARNATIONS:-5}
|
||||||
|
|
||||||
|
[ -z "$TESTPROGS" ] && export TESTPROGS="
|
||||||
|
testcases/rw/rw
|
||||||
|
testcases/swap/swap
|
||||||
|
testcases/creat/creat
|
||||||
|
testcases/mkdir/mkdir
|
||||||
|
testcases/thr1/thr1
|
||||||
|
testcases/udp/udp
|
||||||
|
testcases/tcp/tcp
|
||||||
|
"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Defaults for ./misc tests
|
||||||
|
#
|
||||||
|
|
||||||
|
export diskimage=${diskimage:-/tmp/diskimage} # Location of 1G disk image
|
||||||
|
export mntpoint=${mntpoint:-/mnt} # Disk image mount point
|
||||||
|
export testuser=${testuser:-TBD} # Name of non root test user
|
||||||
|
export mdstart=${mdstart:-10} # Start of free md units
|
||||||
|
export part=${part:-a} # Partition to use on a md FS
|
||||||
|
export newfs_flags=${newfs_flags:-"-U"} # Default file system flags
|
||||||
|
export stress2origin=${stress2origin:-`pwd`}
|
||||||
|
export stress2tools=`dirname $stress2origin`/tools
|
||||||
|
|
||||||
|
# fsck wrapper
|
||||||
|
checkfs () {
|
||||||
|
local s
|
||||||
|
|
||||||
|
fsck -t ufs -fy $1 > /tmp/fsck.log 2>&1
|
||||||
|
if grep -v "IS CLEAN" /tmp/fsck.log | \
|
||||||
|
LANG=C egrep -q "[A-Z][A-Z]"; then
|
||||||
|
echo "fsck -t ufs -fy $1"
|
||||||
|
cat /tmp/fsck.log
|
||||||
|
s=1
|
||||||
|
else
|
||||||
|
rm -f /tmp/fsck.log
|
||||||
|
s=0
|
||||||
|
fi
|
||||||
|
return $s
|
||||||
|
}
|
||||||
|
|
||||||
|
# Support for pre-build binaries for stress2/misc tests
|
||||||
|
# Build modes:
|
||||||
|
# 1 Build and copy binary to $STRESS2BIN
|
||||||
|
# 2 Do not compile; use binary from $STRESS2BIN
|
||||||
|
|
||||||
|
# Examples:
|
||||||
|
# BMODE=1 ./all.sh -on `grep -lw mycc *.sh`
|
||||||
|
# BMODE=2 STRESS2BIN=/home/pho/stress2/bin.i386.r276368 ./all.sh
|
||||||
|
|
||||||
|
CC=${CC:-cc}
|
||||||
|
top=`dirname $(pwd)` # cwd for the all.sh script
|
||||||
|
STRESS2BIN=${STRESS2BIN:-$top/bin}
|
||||||
|
mycc () { # "-o" must be first argument
|
||||||
|
local file
|
||||||
|
|
||||||
|
[ "$1" = "-o" ] && file=`basename $2`
|
||||||
|
if [ "$BMODE" = "1" ]; then
|
||||||
|
$CC $@ || return
|
||||||
|
[ -z "$file" ] && return # "-c"
|
||||||
|
[ -d $STRESS2BIN ] || mkdir $STRESS2BIN
|
||||||
|
[ -x $STRESS2BIN/$file ] &&
|
||||||
|
echo "Overwriting $STRESS2BIN/$file"
|
||||||
|
echo "cp $2 $STRESS2BIN"
|
||||||
|
cp $2 $STRESS2BIN
|
||||||
|
exit 0 # Build but do not run the test
|
||||||
|
elif [ "$BMODE" = "2" ]; then
|
||||||
|
[ -z "$file" ] && return
|
||||||
|
if [ ! -x $STRESS2BIN/$file ]; then
|
||||||
|
echo "$STRESS2BIN/$file not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Using binary $STRESS2BIN/$file"
|
||||||
|
cp $STRESS2BIN/$file /tmp
|
||||||
|
else
|
||||||
|
$CC $@ # default "build and run" mode
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
id $testuser > /dev/null 2>&1 ||
|
||||||
|
{ echo "Non-root \$testuser \"$testuser\" not found."; exit 1; }
|
8
tools/test/stress2/df.cfg
Normal file
8
tools/test/stress2/df.cfg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Stress Test Suite Configuration
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
. ./default.cfg
|
||||||
|
|
||||||
|
# Only run these two test programs for VFS tests
|
||||||
|
|
||||||
|
export TESTPROGS="testcases/creat/creat testcases/rw/rw"
|
8
tools/test/stress2/disk.cfg
Normal file
8
tools/test/stress2/disk.cfg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Stress Test Suite Configuration
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
. ./default.cfg
|
||||||
|
|
||||||
|
export TESTPROGS="testcases/rw/rw testcases/creat/creat testcases/mkdir/mkdir"
|
||||||
|
export rwNODELAY=1
|
||||||
|
export rwLOAD=100
|
3
tools/test/stress2/doc/README
Normal file
3
tools/test/stress2/doc/README
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
stress.pdf An old (and out of date) document describing the first
|
||||||
|
generation of the test suite.
|
||||||
|
linuxforum06.pdf The slides from a presentation at Linux Forum 2006
|
BIN
tools/test/stress2/doc/linuxforum06.pdf
Normal file
BIN
tools/test/stress2/doc/linuxforum06.pdf
Normal file
Binary file not shown.
BIN
tools/test/stress2/doc/stress.pdf
Normal file
BIN
tools/test/stress2/doc/stress.pdf
Normal file
Binary file not shown.
64
tools/test/stress2/include/stress.h
Normal file
64
tools/test/stress2/include/stress.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _STRESS_H_
|
||||||
|
#define _STRESS_H_
|
||||||
|
extern int setup(int);
|
||||||
|
extern int test(void);
|
||||||
|
extern void cleanup(void);
|
||||||
|
extern void options(int, char **);
|
||||||
|
extern int random_int(int, int);
|
||||||
|
/*extern void limits(void);*/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
|
int run_time;
|
||||||
|
int load;
|
||||||
|
char *wd;
|
||||||
|
char *cd;
|
||||||
|
int verbose;
|
||||||
|
int incarnations;
|
||||||
|
int hog;
|
||||||
|
int nodelay;
|
||||||
|
int kill;
|
||||||
|
int64_t kblocks;
|
||||||
|
int64_t inodes;
|
||||||
|
} opt_t;
|
||||||
|
|
||||||
|
extern opt_t *op;
|
||||||
|
|
||||||
|
extern volatile int done_testing;
|
||||||
|
extern char *home;
|
||||||
|
extern void rmval(void);
|
||||||
|
extern void putval(unsigned long);
|
||||||
|
extern unsigned long getval(void);
|
||||||
|
extern void getdf(int64_t *, int64_t *);
|
||||||
|
extern void reservedf(int64_t, int64_t);
|
||||||
|
extern void show_status(void);
|
||||||
|
extern int64_t swap(void);
|
||||||
|
extern unsigned long usermem(void);
|
||||||
|
#endif
|
9
tools/test/stress2/io.cfg
Normal file
9
tools/test/stress2/io.cfg
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Stress Test Suite Configuration
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
. ./default.cfg
|
||||||
|
|
||||||
|
# Only run these three test programs for VFS tests
|
||||||
|
|
||||||
|
export TESTPROGS="testcases/swap/swap testcases/creat/creat testcases/mkdir/mkdir testcases/rw/rw"
|
||||||
|
export swapLOAD=10
|
8
tools/test/stress2/jeff.cfg
Normal file
8
tools/test/stress2/jeff.cfg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Stress Test Suite Configuration
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
. ./default.cfg
|
||||||
|
|
||||||
|
# Only run these two test programs for VFS tests
|
||||||
|
|
||||||
|
export TESTPROGS="testcases/creat/creat testcases/mkdir/mkdir"
|
9
tools/test/stress2/lib/Makefile
Normal file
9
tools/test/stress2/lib/Makefile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
LIB= stress
|
||||||
|
SRCS= main.c options.c random_int.c resources.c
|
||||||
|
INTERNALLIB= true
|
||||||
|
MK_AUTO_OBJ= no
|
||||||
|
|
||||||
|
.include "../testcases/Makefile.inc"
|
||||||
|
CFLAGS+=-fPIE
|
||||||
|
|
||||||
|
.include <bsd.lib.mk>
|
212
tools/test/stress2/lib/main.c
Normal file
212
tools/test/stress2/lib/main.c
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Main program for all test programs */
|
||||||
|
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "stress.h"
|
||||||
|
|
||||||
|
volatile int done_testing;
|
||||||
|
static int cleanupcalled = 0;
|
||||||
|
char *home;
|
||||||
|
|
||||||
|
static pid_t *r;
|
||||||
|
|
||||||
|
static void
|
||||||
|
handler(int i __unused)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
|
||||||
|
done_testing = 1;
|
||||||
|
for (j = 0; j < op->incarnations; j++) {
|
||||||
|
if (op->verbose > 2)
|
||||||
|
printf("handler: kill -HUP %d\n", r[j]);
|
||||||
|
if (r[j] != 0 && kill(r[j], SIGHUP) == -1)
|
||||||
|
if (errno != ESRCH)
|
||||||
|
warn("kill(%d, SIGHUP), %s:%d", r[j], __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
if (op->kill == 1) {
|
||||||
|
sleep(5);
|
||||||
|
/* test programs may have blocked for the SIGHUP, so try harder */
|
||||||
|
for (j = 0; j < op->incarnations; j++) {
|
||||||
|
if (op->verbose > 2)
|
||||||
|
printf("handler: kill -KILL %d\n", r[j]);
|
||||||
|
if (r[j] != 0)
|
||||||
|
(void) kill(r[j], SIGKILL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
run_test_handler(int i __unused)
|
||||||
|
{
|
||||||
|
|
||||||
|
done_testing = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
exit_handler(int i __unused)
|
||||||
|
{
|
||||||
|
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
callcleanup(void)
|
||||||
|
{
|
||||||
|
if (cleanupcalled == 0)
|
||||||
|
cleanup();
|
||||||
|
cleanupcalled = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
run_tests(int i)
|
||||||
|
{
|
||||||
|
time_t start;
|
||||||
|
int e;
|
||||||
|
|
||||||
|
signal(SIGHUP, run_test_handler);
|
||||||
|
signal(SIGINT, exit_handler);
|
||||||
|
atexit(callcleanup);
|
||||||
|
setup(i);
|
||||||
|
if ((strcmp(getprogname(), "run") != 0) && (op->nodelay == 0))
|
||||||
|
sleep(random_int(1,10));
|
||||||
|
e = 0;
|
||||||
|
start = time(NULL);
|
||||||
|
while (done_testing == 0 && e == 0 &&
|
||||||
|
(time(NULL) - start) < op->run_time) {
|
||||||
|
e = test();
|
||||||
|
}
|
||||||
|
callcleanup();
|
||||||
|
exit(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
run_incarnations(void)
|
||||||
|
{
|
||||||
|
int e, i, s;
|
||||||
|
|
||||||
|
e = 0;
|
||||||
|
signal(SIGHUP, handler);
|
||||||
|
for (i = 0; i < op->incarnations && done_testing == 0; i++) {
|
||||||
|
if ((r[i] = fork()) == 0) {
|
||||||
|
run_tests(i);
|
||||||
|
}
|
||||||
|
if (r[i] < 0) {
|
||||||
|
warn("fork(), %s:%d", __FILE__, __LINE__);
|
||||||
|
r[i] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = 0; i < op->incarnations; i++) {
|
||||||
|
if (r[i] != 0 && waitpid(r[i], &s, 0) == -1)
|
||||||
|
warn("waitpid(%d), %s:%d", r[i], __FILE__, __LINE__);
|
||||||
|
if (s != 0)
|
||||||
|
e = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
run_test(void)
|
||||||
|
{
|
||||||
|
pid_t p;
|
||||||
|
time_t start;
|
||||||
|
int status = 0;
|
||||||
|
|
||||||
|
if (random_int(1,100) > op->load)
|
||||||
|
return (status);
|
||||||
|
|
||||||
|
show_status();
|
||||||
|
|
||||||
|
start = time(NULL);
|
||||||
|
done_testing = 0;
|
||||||
|
fflush(stdout);
|
||||||
|
rmval();
|
||||||
|
p = fork();
|
||||||
|
if (p == 0)
|
||||||
|
run_incarnations();
|
||||||
|
if (p < 0)
|
||||||
|
err(1, "fork() in %s:%d", __FILE__, __LINE__);
|
||||||
|
while (done_testing != 1 &&
|
||||||
|
(time(NULL) - start) < op->run_time) {
|
||||||
|
sleep(1);
|
||||||
|
if (waitpid(p, &status, WNOHANG) == p)
|
||||||
|
return (status != 0);
|
||||||
|
}
|
||||||
|
if (kill(p, SIGHUP) == -1)
|
||||||
|
warn("kill(%d, SIGHUP), %s:%d", p, __FILE__, __LINE__);
|
||||||
|
|
||||||
|
if (waitpid(p, &status, 0) == -1)
|
||||||
|
err(1, "waitpid(%d), %s:%d", p, __FILE__, __LINE__);
|
||||||
|
|
||||||
|
return (status != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
struct stat sb;
|
||||||
|
int status = 0;
|
||||||
|
|
||||||
|
options(argc, argv);
|
||||||
|
|
||||||
|
umask(0);
|
||||||
|
if (stat(op->wd, &sb) == -1) {
|
||||||
|
if (mkdir(op->wd, 0770) == -1)
|
||||||
|
if (errno != EEXIST)
|
||||||
|
err(1, "mkdir(%s) %s:%d", op->wd, __FILE__, __LINE__);
|
||||||
|
} else if ((sb.st_mode & S_IRWXU) == 0)
|
||||||
|
errx(1, "No RWX access to %s", op->wd);
|
||||||
|
if (stat(op->cd, &sb) == -1) {
|
||||||
|
if (mkdir(op->cd, 0770) == -1)
|
||||||
|
if (errno != EEXIST)
|
||||||
|
err(1, "mkdir(%s) %s:%d", op->cd, __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
if ((home = getcwd(NULL, 0)) == NULL)
|
||||||
|
err(1, "getcwd(), %s:%d", __FILE__, __LINE__);
|
||||||
|
if (chdir(op->wd) == -1)
|
||||||
|
err(1, "chdir(%s) %s:%d", op->wd, __FILE__, __LINE__);
|
||||||
|
|
||||||
|
r = (pid_t *)calloc(1, op->incarnations * sizeof(pid_t));
|
||||||
|
|
||||||
|
status = run_test();
|
||||||
|
|
||||||
|
return (status);
|
||||||
|
}
|
268
tools/test/stress2/lib/options.c
Normal file
268
tools/test/stress2/lib/options.c
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sysexits.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <err.h>
|
||||||
|
|
||||||
|
#include "stress.h"
|
||||||
|
|
||||||
|
static opt_t opt;
|
||||||
|
opt_t *op;
|
||||||
|
|
||||||
|
static char path[64];
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(const char *where)
|
||||||
|
{
|
||||||
|
const char *help;
|
||||||
|
|
||||||
|
if (where != NULL)
|
||||||
|
printf("Error in \"%s\"\n", where);
|
||||||
|
fprintf(stderr, "Usage: %s [-t | -l | -i | -d | -h | -k | -v]\n", getprogname());
|
||||||
|
help = " t <number><s|m|h|d> : time to run test\n"
|
||||||
|
" l <pct> : load factor 0 - 100%\n"
|
||||||
|
" i <number> : max # of parallel incarnations\n"
|
||||||
|
" d <path> : working directory\n"
|
||||||
|
" h : hog resources\n"
|
||||||
|
" k : terminate with SIGHUP + SIGKILL\n"
|
||||||
|
" n : no startup delay\n"
|
||||||
|
" v : verbose\n";
|
||||||
|
printf("%s", help);
|
||||||
|
exit(EX_USAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
time2sec(const char *string)
|
||||||
|
{
|
||||||
|
int r, s = 0;
|
||||||
|
char modifier;
|
||||||
|
r = sscanf(string, "%d%c", &s, &modifier);
|
||||||
|
if (r == 2)
|
||||||
|
switch(modifier) {
|
||||||
|
case 's': break;
|
||||||
|
case 'm': s = s * 60; break;
|
||||||
|
case 'h': s = s * 60 * 60; break;
|
||||||
|
case 'd': s = s * 60 * 60 * 24; break;
|
||||||
|
default:
|
||||||
|
usage("-t");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
usage("-t");
|
||||||
|
return (s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *gete(const char *name)
|
||||||
|
{
|
||||||
|
char *cp;
|
||||||
|
char help[128];
|
||||||
|
|
||||||
|
snprintf(help, sizeof(help), "%s%s", getprogname(), name);
|
||||||
|
cp = getenv(help);
|
||||||
|
if (cp == NULL)
|
||||||
|
cp = getenv(name);
|
||||||
|
return (cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
environment(void)
|
||||||
|
{
|
||||||
|
char *cp;
|
||||||
|
|
||||||
|
if ((cp = gete("INCARNATIONS")) != NULL) {
|
||||||
|
if (sscanf(cp, "%d", &op->incarnations) != 1)
|
||||||
|
usage("INCARNATIONS");
|
||||||
|
}
|
||||||
|
if ((cp = gete("LOAD")) != NULL) {
|
||||||
|
if (sscanf(cp, "%d", &op->load) != 1)
|
||||||
|
usage("LOAD");
|
||||||
|
}
|
||||||
|
if ((cp = gete("RUNTIME")) != NULL) {
|
||||||
|
op->run_time = time2sec(cp);
|
||||||
|
}
|
||||||
|
if ((cp = gete("RUNDIR")) != NULL) {
|
||||||
|
op->wd = cp;
|
||||||
|
}
|
||||||
|
if ((cp = gete("CTRLDIR")) != NULL) {
|
||||||
|
op->cd = cp;
|
||||||
|
}
|
||||||
|
if ((cp = gete("HOG")) != NULL) {
|
||||||
|
op->hog = 1;
|
||||||
|
}
|
||||||
|
if ((cp = gete("KILL")) != NULL) {
|
||||||
|
op->kill = 1;
|
||||||
|
}
|
||||||
|
if ((cp = gete("NODELAY")) != NULL) {
|
||||||
|
op->nodelay = 1;
|
||||||
|
}
|
||||||
|
if ((cp = gete("VERBOSE")) != NULL) {
|
||||||
|
if (sscanf(cp, "%d", &op->verbose) != 1)
|
||||||
|
usage("VERBOSE");
|
||||||
|
}
|
||||||
|
if ((cp = gete("KBLOCKS")) != NULL) {
|
||||||
|
if (sscanf(cp, "%jd", &op->kblocks) != 1)
|
||||||
|
usage("KBLOCKS");
|
||||||
|
}
|
||||||
|
if ((cp = gete("INODES")) != NULL) {
|
||||||
|
if (sscanf(cp, "%jd", &op->inodes) != 1)
|
||||||
|
usage("INODES");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
options(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
|
||||||
|
op = &opt;
|
||||||
|
|
||||||
|
op->run_time = 60;
|
||||||
|
op->load = 100;
|
||||||
|
op->wd = strdup("/tmp/stressX");
|
||||||
|
op->cd = strdup("/tmp/stressX.control");
|
||||||
|
op->incarnations = 1;
|
||||||
|
op->hog = 0;
|
||||||
|
op->kill = 0;
|
||||||
|
op->nodelay = 0;
|
||||||
|
op->verbose = 0;
|
||||||
|
op->kblocks = 0;
|
||||||
|
op->inodes = 0;
|
||||||
|
|
||||||
|
environment();
|
||||||
|
|
||||||
|
while ((ch = getopt(argc, argv, "t:l:i:d:hknv")) != -1)
|
||||||
|
switch(ch) {
|
||||||
|
case 't': /* run time */
|
||||||
|
op->run_time = time2sec(optarg);
|
||||||
|
break;
|
||||||
|
case 'l': /* load factor in pct */
|
||||||
|
if (sscanf(optarg, "%d", &op->load) != 1)
|
||||||
|
usage("-l");
|
||||||
|
break;
|
||||||
|
case 'i': /* max incarnations */
|
||||||
|
if (sscanf(optarg, "%d", &op->incarnations) != 1)
|
||||||
|
usage("-i");
|
||||||
|
break;
|
||||||
|
case 'd': /* working directory */
|
||||||
|
op->wd = strdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'h': /* hog flag */
|
||||||
|
op->hog += 1;
|
||||||
|
break;
|
||||||
|
case 'k': /* kill flag */
|
||||||
|
op->kill = 1;
|
||||||
|
break;
|
||||||
|
case 'n': /* no delay flag */
|
||||||
|
op->nodelay = 1;
|
||||||
|
break;
|
||||||
|
case 'v': /* verbose flag */
|
||||||
|
op->verbose += 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage(NULL);
|
||||||
|
}
|
||||||
|
op->argc = argc -= optind;
|
||||||
|
op->argv = argv += optind;
|
||||||
|
|
||||||
|
if (op->incarnations < 1)
|
||||||
|
op->incarnations = 1;
|
||||||
|
if (op->hog == 0)
|
||||||
|
op->incarnations = random_int(1, op->incarnations);
|
||||||
|
if (op->run_time < 15)
|
||||||
|
op->run_time = 15;
|
||||||
|
if (op->load < 0 || op->load > 100)
|
||||||
|
op->load = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
show_status(void)
|
||||||
|
{
|
||||||
|
char buf[80], pgname[9];
|
||||||
|
int days;
|
||||||
|
time_t t;
|
||||||
|
|
||||||
|
if (op->verbose > 0) {
|
||||||
|
strncpy(pgname, getprogname(), sizeof(pgname));
|
||||||
|
pgname[8] = 0;
|
||||||
|
t = op->run_time;
|
||||||
|
days = t / (60 * 60 * 24);
|
||||||
|
t = t % (60 * 60 * 24);
|
||||||
|
strftime(buf, sizeof(buf), "%T", gmtime(&t));
|
||||||
|
printf("%8s: run time %2d+%s, incarnations %3d, load %3d, "
|
||||||
|
"verbose %d\n",
|
||||||
|
pgname, days, buf, op->incarnations, op->load,
|
||||||
|
op->verbose);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rmval(void)
|
||||||
|
{
|
||||||
|
if (snprintf(path, sizeof(path), "%s/%s.conf", op->cd,
|
||||||
|
getprogname()) < 0)
|
||||||
|
err(1, "snprintf path");
|
||||||
|
(void) unlink(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
putval(unsigned long v)
|
||||||
|
{
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
|
rmval();
|
||||||
|
snprintf(buf, sizeof(buf), "%lu", v);
|
||||||
|
if (symlink(buf, path) < 0)
|
||||||
|
err(1, "symlink(%s, %s)", path, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long
|
||||||
|
getval(void)
|
||||||
|
{
|
||||||
|
int i, n;
|
||||||
|
unsigned long val;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
|
if ((n = readlink(path, buf, sizeof(buf) -1)) < 0) {
|
||||||
|
for (i = 0; i < 60; i++) {
|
||||||
|
sleep(1);
|
||||||
|
if ((n = readlink(path, buf, sizeof(buf) -1)) > 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (n < 0)
|
||||||
|
err(1, "readlink(%s). %s:%d", path, __FILE__,
|
||||||
|
__LINE__);
|
||||||
|
}
|
||||||
|
buf[n] = '\0';
|
||||||
|
if (sscanf(buf, "%ld", &val) != 1)
|
||||||
|
err(1, "sscanf(%s)", buf);
|
||||||
|
return val;
|
||||||
|
}
|
56
tools/test/stress2/lib/random_int.c
Normal file
56
tools/test/stress2/lib/random_int.c
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "stress.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
random_int(int mi, int ma)
|
||||||
|
{
|
||||||
|
return (arc4random() % (ma - mi + 1) + mi);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TEST
|
||||||
|
#include <stdio.h>
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
int i, j, min, max, r;
|
||||||
|
min = 100;
|
||||||
|
max = 1;
|
||||||
|
for (i = 0; i < 10000; i++) {
|
||||||
|
j += (r = random_int(1,100));
|
||||||
|
if (max < r)
|
||||||
|
max = r;
|
||||||
|
if (min > r)
|
||||||
|
min = r;
|
||||||
|
}
|
||||||
|
printf("Average is %d, min = %d, max = %d\n", j / 10000, min, max);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
#endif
|
248
tools/test/stress2/lib/resources.c
Normal file
248
tools/test/stress2/lib/resources.c
Normal file
@ -0,0 +1,248 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Get various resource limits for the tests */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <kvm.h>
|
||||||
|
#include <vm/vm_param.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <libutil.h>
|
||||||
|
|
||||||
|
#include "stress.h"
|
||||||
|
|
||||||
|
static int lockfd;
|
||||||
|
static int dffd;
|
||||||
|
static int flags;
|
||||||
|
static char lockpath[128];
|
||||||
|
static char dfpath[128];
|
||||||
|
|
||||||
|
static int64_t
|
||||||
|
inodes(void)
|
||||||
|
{
|
||||||
|
char path[MAXPATHLEN+1];
|
||||||
|
struct statfs buf;
|
||||||
|
|
||||||
|
if (op->inodes != 0)
|
||||||
|
return (op->inodes);
|
||||||
|
if (getcwd(path, sizeof(path)) == NULL)
|
||||||
|
err(1, "getcwd()");
|
||||||
|
|
||||||
|
if (statfs(path, &buf) < 0)
|
||||||
|
err(1, "statfs(%s)", path);
|
||||||
|
if (!strcmp(buf.f_fstypename, "msdosfs"))
|
||||||
|
buf.f_ffree = 9999;
|
||||||
|
flags = buf.f_flags & MNT_VISFLAGMASK;
|
||||||
|
if (op->verbose > 2)
|
||||||
|
printf("Free inodes on %s (%s): %jd\n", path,
|
||||||
|
buf.f_mntonname, buf.f_ffree);
|
||||||
|
return (buf.f_ffree);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64_t
|
||||||
|
df(void)
|
||||||
|
{
|
||||||
|
char path[MAXPATHLEN+1];
|
||||||
|
struct statfs buf;
|
||||||
|
|
||||||
|
if (op->kblocks != 0)
|
||||||
|
return (op->kblocks * (uint64_t)1024);
|
||||||
|
|
||||||
|
if (getcwd(path, sizeof(path)) == NULL)
|
||||||
|
err(1, "getcwd()");
|
||||||
|
|
||||||
|
if (statfs(path, &buf) < 0)
|
||||||
|
err(1, "statfs(%s)", path);
|
||||||
|
if (buf.f_bavail > (int64_t)buf.f_blocks || buf.f_bavail < 0) {
|
||||||
|
warnx("Corrupt statfs(%s). f_bavail = %jd!", path,
|
||||||
|
buf.f_bavail);
|
||||||
|
buf.f_bavail = 100;
|
||||||
|
}
|
||||||
|
if (op->verbose > 2)
|
||||||
|
printf("Free space on %s: %jd Mb\n", path, buf.f_bavail *
|
||||||
|
buf.f_bsize / 1024 / 1024);
|
||||||
|
return (buf.f_bavail * buf.f_bsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t
|
||||||
|
swap(void)
|
||||||
|
{
|
||||||
|
struct xswdev xsw;
|
||||||
|
size_t mibsize, size;
|
||||||
|
int mib[16], n;
|
||||||
|
int64_t sz;
|
||||||
|
|
||||||
|
mibsize = sizeof mib / sizeof mib[0];
|
||||||
|
sz = 0;
|
||||||
|
|
||||||
|
if (sysctlnametomib("vm.swap_info", mib, &mibsize) == -1)
|
||||||
|
err(1, "sysctlnametomib()");
|
||||||
|
|
||||||
|
for (n = 0; ; ++n) {
|
||||||
|
mib[mibsize] = n;
|
||||||
|
size = sizeof xsw;
|
||||||
|
if (sysctl(mib, mibsize + 1, &xsw, &size, NULL, 0) == -1)
|
||||||
|
break;
|
||||||
|
if (xsw.xsw_version != XSWDEV_VERSION)
|
||||||
|
errx(1, "xswdev version mismatch");
|
||||||
|
sz = sz + xsw.xsw_nblks - xsw.xsw_used;
|
||||||
|
}
|
||||||
|
if (errno != ENOENT)
|
||||||
|
err(1, "sysctl()");
|
||||||
|
|
||||||
|
if (op->verbose > 2)
|
||||||
|
printf("Total free swap space %jd Mb\n",
|
||||||
|
sz * getpagesize() / 1024 / 1024);
|
||||||
|
|
||||||
|
return (sz * getpagesize());
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long
|
||||||
|
usermem(void)
|
||||||
|
{
|
||||||
|
unsigned long mem;
|
||||||
|
size_t nlen = sizeof(mem);
|
||||||
|
|
||||||
|
if (sysctlbyname("hw.usermem", &mem, &nlen, NULL, 0) == -1)
|
||||||
|
err(1, "sysctlbyname() %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
if (op->verbose > 2)
|
||||||
|
printf("Total free user memory %lu Mb\n",
|
||||||
|
mem / 1024 / 1024);
|
||||||
|
|
||||||
|
return (mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cleanupdf()
|
||||||
|
{
|
||||||
|
unlink(dfpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
getdf(int64_t *block, int64_t *inode)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
char buf[128];
|
||||||
|
|
||||||
|
snprintf(lockpath, sizeof(lockpath), "%s/lock", op->cd);
|
||||||
|
for (j = 0; j < 2; j++) {
|
||||||
|
for (i = 0; i < 10000; i++) {
|
||||||
|
if ((lockfd = open(lockpath,
|
||||||
|
O_CREAT | O_TRUNC | O_WRONLY |
|
||||||
|
O_EXCL, 0644)) != -1)
|
||||||
|
break;
|
||||||
|
usleep(10000); /* sleep 1/100 sec */
|
||||||
|
if (i > 0 && i % 1000 == 0)
|
||||||
|
fprintf(stderr, "%s is waiting for lock file"
|
||||||
|
" %s\n",
|
||||||
|
getprogname(), lockpath);
|
||||||
|
}
|
||||||
|
if (lockfd != -1)
|
||||||
|
break;
|
||||||
|
fprintf(stderr, "%s. Removing stale %s\n", getprogname(),
|
||||||
|
lockpath);
|
||||||
|
unlink(lockpath);
|
||||||
|
}
|
||||||
|
if (lockfd == -1)
|
||||||
|
errx(1, "%s. Can not create %s\n", getprogname(), lockpath);
|
||||||
|
snprintf(dfpath, sizeof(dfpath), "%s/df", op->cd);
|
||||||
|
if ((dffd = open(dfpath, O_RDWR, 0644)) == -1) {
|
||||||
|
if ((dffd = open(dfpath,
|
||||||
|
O_CREAT | O_TRUNC | O_WRONLY, 0644)) == -1) {
|
||||||
|
unlink(lockpath);
|
||||||
|
err(1, "creat(%s) %s:%d", dfpath, __FILE__,
|
||||||
|
__LINE__);
|
||||||
|
}
|
||||||
|
atexit(cleanupdf);
|
||||||
|
*block = df();
|
||||||
|
*inode = inodes();
|
||||||
|
snprintf(buf, sizeof(buf), "%jd %jd", *block, *inode);
|
||||||
|
|
||||||
|
if (write(dffd, buf, strlen(buf) + 1) !=
|
||||||
|
(ssize_t)strlen(buf) +1)
|
||||||
|
err(1, "write df. %s:%d", __FILE__, __LINE__);
|
||||||
|
} else {
|
||||||
|
if (read(dffd, buf, sizeof(buf)) < 1) {
|
||||||
|
system("ls -l /tmp/stressX.control");
|
||||||
|
unlink(lockpath);
|
||||||
|
err(1, "read df. %s:%d", __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
sscanf(buf, "%jd %jd", block, inode);
|
||||||
|
}
|
||||||
|
close(dffd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
reservedf(int64_t blks, int64_t inos)
|
||||||
|
{
|
||||||
|
char buf[128];
|
||||||
|
int64_t blocks, inodes;
|
||||||
|
|
||||||
|
if ((dffd = open(dfpath, O_RDWR, 0644)) == -1) {
|
||||||
|
warn("open(%s) %s:%d. %s", dfpath, __FILE__, __LINE__,
|
||||||
|
getprogname());
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if (read(dffd, buf, sizeof(buf)) < 1) {
|
||||||
|
warn("read df. %s:%d", __FILE__, __LINE__);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
sscanf(buf, "%jd %jd", &blocks, &inodes);
|
||||||
|
|
||||||
|
if (op->verbose > 2)
|
||||||
|
printf("%-8s: reservefd(%9jdK, %6jd) out of (%9jdK, %6jd)\n",
|
||||||
|
getprogname(), blks/1024, inos, blocks/1024,
|
||||||
|
inodes);
|
||||||
|
blocks -= blks;
|
||||||
|
inodes -= inos;
|
||||||
|
|
||||||
|
snprintf(buf, sizeof(buf), "%jd %jd", blocks, inodes);
|
||||||
|
if (blocks < 0 || inodes < 0)
|
||||||
|
printf("******************************** %s: %s\n",
|
||||||
|
getprogname(), buf);
|
||||||
|
if (lseek(dffd, 0, 0) == -1)
|
||||||
|
err(1, "lseek. %s:%d", __FILE__, __LINE__);
|
||||||
|
if (write(dffd, buf, strlen(buf) + 1) != (ssize_t)strlen(buf) +1)
|
||||||
|
warn("write df. %s:%d", __FILE__, __LINE__);
|
||||||
|
err:
|
||||||
|
close(dffd);
|
||||||
|
close(lockfd);
|
||||||
|
if (unlink(lockpath) == -1)
|
||||||
|
err(1, "unlink(%s)", lockpath);
|
||||||
|
}
|
9
tools/test/stress2/link.cfg
Normal file
9
tools/test/stress2/link.cfg
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Stress Test Suite Configuration
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
. ./default.cfg
|
||||||
|
|
||||||
|
export TESTPROGS="testcases/link/link testcases/swap/swap"
|
||||||
|
export linkHOG=1
|
||||||
|
export linkLOAD=100
|
||||||
|
export linkINCARNATIONS=100
|
18
tools/test/stress2/load.cfg
Normal file
18
tools/test/stress2/load.cfg
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Just a test of the EXCLUDETESTS feature
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
. ./default.cfg
|
||||||
|
|
||||||
|
###export TESTPROGS="" # Remove comments for test
|
||||||
|
###export HOG=1 # Remove comments for test
|
||||||
|
|
||||||
|
###export LOAD=100 # Remove comments for test
|
||||||
|
###export swapLOAD=100 # Remove comments for test
|
||||||
|
###export rwLOAD=100 # Remove comments for test
|
||||||
|
###export mkdirLOAD=100 # Remove comments for test
|
||||||
|
###export creatLOAD=100 # Remove comments for test
|
||||||
|
###export symlinkLOAD=100 # Remove comments for test
|
||||||
|
###export swapLOAD=100 # Remove comments for test
|
||||||
|
###export linkLOAD=100 # Remove comments for test
|
||||||
|
|
||||||
|
EXCLUDETESTS="sysctl|swap|tcp|udp|syscall|mmap|socket|thr|thr1|thr2|shm|badcode"
|
9
tools/test/stress2/lockf.cfg
Normal file
9
tools/test/stress2/lockf.cfg
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Stress Test Suite Configuration
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
. ./default.cfg
|
||||||
|
|
||||||
|
export TESTPROGS="testcases/lockf2/lockf2 testcases/lockf/lockf testcases/swap/swap"
|
||||||
|
export lockf2HOG=1
|
||||||
|
export lockf2LOAD=100
|
||||||
|
export lockf2INCARNATIONS=100
|
24
tools/test/stress2/marcus.cfg
Normal file
24
tools/test/stress2/marcus.cfg
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Stress Test Suite Configuration
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
. ./default.cfg
|
||||||
|
|
||||||
|
# Test configuration for the vop_stdvptocnp implementation
|
||||||
|
|
||||||
|
export LOAD=80
|
||||||
|
export symlinkLOAD=80
|
||||||
|
export rwLOAD=80
|
||||||
|
export TESTPROGS="
|
||||||
|
testcases/lockf2/lockf2
|
||||||
|
testcases/symlink/symlink
|
||||||
|
testcases/openat/openat
|
||||||
|
testcases/rw/rw
|
||||||
|
testcases/fts/fts
|
||||||
|
testcases/link/link
|
||||||
|
testcases/lockf/lockf
|
||||||
|
testcases/creat/creat
|
||||||
|
testcases/mkdir/mkdir
|
||||||
|
testcases/rename/rename
|
||||||
|
testcases/swap/swap
|
||||||
|
testcases/mkfifo/mkfifo
|
||||||
|
"
|
73
tools/test/stress2/misc/1st.sh
Executable file
73
tools/test/stress2/misc/1st.sh
Executable file
@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2021 Peter Holm <pho@FreeBSD.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# stress2 config test:
|
||||||
|
# Check that diskimage and RUNDIR has not been clobbered in `hostname`.
|
||||||
|
# Variables must be set like this: var=${var:-value}
|
||||||
|
|
||||||
|
export diskimage=dummy
|
||||||
|
export RUNDIR=dummy
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
[ "`sysctl -in debug.vmem_check`" = "1" ] &&
|
||||||
|
echo "debug.vmem_check must be set to 0"
|
||||||
|
[ "`sysctl -in debug.vmmap_check`" = "0" ] &&
|
||||||
|
echo "debug.vmmap_check must be set to 1"
|
||||||
|
|
||||||
|
if [ "$diskimage" != "dummy" ]; then
|
||||||
|
echo "FATAL: diskimage was overwritten with \"$diskimage\""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$RUNDIR" != "dummy" ]; then
|
||||||
|
echo "FATAL: RUNDIR was overwritten with \"$RUNDIR\""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "`dirname $mntpoint`" != "/" ]; then
|
||||||
|
echo "FATAL: mntpoint \"$mntpoint\" must be a root directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
[ -z "`which ruby 2>/dev/null`" ] && echo "Consider installing ruby"
|
||||||
|
[ -z "`type mke2fs 2>/dev/null`" ] && echo "Consider installing e2fsprogs"
|
||||||
|
[ -z "`type mkisofs 2>/dev/null`" ] && echo "Consider installing cdrtools"
|
||||||
|
[ -z "`type mDNSNetMonitor 2>/dev/null`" ] && echo "Consider installing mDNSResponder"
|
||||||
|
[ ! -x /usr/local/lib/libmill.so ] && echo "Consider installing libmill"
|
||||||
|
|
||||||
|
# Random sanity checks
|
||||||
|
|
||||||
|
df -k $(dirname $diskimage) | tail -1 | awk '{print $4}' |
|
||||||
|
grep -Eq '^[0-9]+$' || { echo FATAL; df -k $(dirname $diskimage); }
|
||||||
|
|
||||||
|
grep -Eq "^discard" /etc/inetd.conf ||
|
||||||
|
echo "Discard is not enabled in /etc/inetd.conf"
|
||||||
|
pgrep -Sq inetd || echo "inetd is not running"
|
||||||
|
|
||||||
|
[ `sysctl -n kern.maxvnodes` -le 2000 ] &&
|
||||||
|
echo "FATAL kern.maxvnodes is too small"
|
||||||
|
|
||||||
|
exit 0
|
45
tools/test/stress2/misc/256m.sh
Executable file
45
tools/test/stress2/misc/256m.sh
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Test scenario with 256MB RAM on a single CPU i386.
|
||||||
|
|
||||||
|
# "panic: ffs_checkblk: bad block -1" seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/256m.txt
|
||||||
|
# Fixed by r291743.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
[ `uname -m` = "i386" ] || exit 0
|
||||||
|
[ `sysctl -n hw.ncpu` -eq 1 ] || { echo "Single CPU test."; exit 0; }
|
||||||
|
[ `sysctl -n hw.physmem` -gt $((256 * 1024 * 1024)) ] &&
|
||||||
|
{ echo "RAM must be clamped to 256MB for this test."; exit 0; }
|
||||||
|
[ -f /usr/src/sys/i386/conf/GENERIC ] || exit 0
|
||||||
|
|
||||||
|
cd /usr/src
|
||||||
|
make -j 2 buildkernel KERNCONF=GENERIC
|
||||||
|
rm -rf /usr/obj/usr/src/sys/GENERIC
|
4
tools/test/stress2/misc/README
Normal file
4
tools/test/stress2/misc/README
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
This directory contains various test scenarios. Most are regression
|
||||||
|
tests for problems fixed.
|
||||||
|
|
||||||
|
The script "all.sh" will run all the test scenarios forever.
|
245
tools/test/stress2/misc/advlock.sh
Executable file
245
tools/test/stress2/misc/advlock.sh
Executable file
@ -0,0 +1,245 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# From r238952's commit log:
|
||||||
|
# The first change closes a race where an open() that will block with O_SHLOCK
|
||||||
|
# or O_EXLOCK can increase the write count while it waits. If the process
|
||||||
|
# holding the current lock on the file then tries to call exec() on the file
|
||||||
|
# it has locked, it can fail with ETXTBUSY even though the advisory lock is
|
||||||
|
# preventing other threads from successfully completing a writable open().
|
||||||
|
#
|
||||||
|
# The second change closes a race where a read-only open() with O_SHLOCK or
|
||||||
|
# O_EXLOCK may return successfully while the write count is non-zero due to
|
||||||
|
# another descriptor that had the advisory lock and was blocking the open()
|
||||||
|
# still being in the process of closing. If the process that completed the
|
||||||
|
# open() then attempts to call exec() on the file it locked, it can fail with
|
||||||
|
# ETXTBUSY even though the other process that held a write lock has closed
|
||||||
|
# the file and released the lock.
|
||||||
|
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik859.txt
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik860.txt
|
||||||
|
|
||||||
|
# Fixed by r294204.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
dir=/tmp
|
||||||
|
odir=`pwd`
|
||||||
|
cd $dir
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > $dir/advlock.c
|
||||||
|
mycc -o advlock -Wall -Wextra -O0 -g advlock.c || exit 1
|
||||||
|
rm -f advlock.c
|
||||||
|
|
||||||
|
mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 512m -u $mdstart || exit 1
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
|
||||||
|
cp /usr/bin/true $mntpoint
|
||||||
|
cd $mntpoint
|
||||||
|
/tmp/advlock
|
||||||
|
r=$?
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
while mount | grep "on $mntpoint " | grep -q /dev/md; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
rm -f /tmp/advlock
|
||||||
|
exit $r
|
||||||
|
|
||||||
|
EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <machine/atomic.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
volatile u_int *share;
|
||||||
|
char *cmdline[] = { "./true", NULL };
|
||||||
|
const char *tp;
|
||||||
|
|
||||||
|
#define SYNC 0
|
||||||
|
#define PARALLEL 2
|
||||||
|
|
||||||
|
#define RUNTIME (1 * 60)
|
||||||
|
|
||||||
|
void
|
||||||
|
handler(int i __unused) {
|
||||||
|
|
||||||
|
fprintf(stderr, "ALARM from %s.\n", tp);
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
slock(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
setproctitle("%s", __func__);
|
||||||
|
atomic_add_int(&share[SYNC], 1);
|
||||||
|
while (share[SYNC] != PARALLEL)
|
||||||
|
;
|
||||||
|
|
||||||
|
tp = __func__;
|
||||||
|
alarm(2);
|
||||||
|
if ((fd = open(cmdline[0], O_RDONLY | O_SHLOCK)) == -1)
|
||||||
|
err(1, "open(%s). %d", cmdline[0], __LINE__);
|
||||||
|
usleep(500);
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
elock(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
setproctitle("%s", __func__);
|
||||||
|
atomic_add_int(&share[SYNC], 1);
|
||||||
|
while (share[SYNC] != PARALLEL)
|
||||||
|
;
|
||||||
|
|
||||||
|
tp = __func__;
|
||||||
|
alarm(2);
|
||||||
|
if ((fd = open(cmdline[0], O_WRONLY | O_EXLOCK)) == -1) {
|
||||||
|
if (errno != ETXTBSY)
|
||||||
|
err(1, "open(%s). %d", cmdline[0], __LINE__);
|
||||||
|
} else {
|
||||||
|
usleep(500);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
stest(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
setproctitle("%s", __func__);
|
||||||
|
atomic_add_int(&share[SYNC], 1);
|
||||||
|
while (share[SYNC] != PARALLEL)
|
||||||
|
;
|
||||||
|
|
||||||
|
tp = __func__;
|
||||||
|
alarm(2);
|
||||||
|
if ((fd = open(cmdline[0], O_RDONLY | O_SHLOCK)) == -1)
|
||||||
|
err(1, "open(%s). %d", cmdline[0], __LINE__);
|
||||||
|
|
||||||
|
if (execve(cmdline[0], cmdline, NULL) == -1)
|
||||||
|
err(1, "execve(%s) @ %d", cmdline[0], __LINE__);
|
||||||
|
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
etest(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
setproctitle("%s", __func__);
|
||||||
|
atomic_add_int(&share[SYNC], 1);
|
||||||
|
while (share[SYNC] != PARALLEL)
|
||||||
|
;
|
||||||
|
|
||||||
|
tp = __func__;
|
||||||
|
alarm(2);
|
||||||
|
if ((fd = open(cmdline[0], O_RDONLY | O_EXLOCK)) == -1)
|
||||||
|
err(1, "open(%s). %d", cmdline[0], __LINE__);
|
||||||
|
|
||||||
|
if (execve(cmdline[0], cmdline, NULL) == -1)
|
||||||
|
err(1, "execve(%s) @ %d", cmdline[0], __LINE__);
|
||||||
|
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
time_t start;
|
||||||
|
int i, n, r, s;
|
||||||
|
|
||||||
|
len = PAGE_SIZE;
|
||||||
|
if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED,
|
||||||
|
-1, 0)) == MAP_FAILED)
|
||||||
|
err(1, "mmap");
|
||||||
|
|
||||||
|
signal(SIGALRM, handler);
|
||||||
|
n = r = 0;
|
||||||
|
start = time(NULL);
|
||||||
|
while ((time(NULL) - start) < RUNTIME) {
|
||||||
|
n++;
|
||||||
|
share[SYNC] = 0;
|
||||||
|
if (fork() == 0)
|
||||||
|
slock();
|
||||||
|
if (fork() == 0)
|
||||||
|
stest();
|
||||||
|
|
||||||
|
for (i = 0; i < PARALLEL; i++) {
|
||||||
|
wait(&s);
|
||||||
|
r += s == 0 ? 0 : 1;
|
||||||
|
}
|
||||||
|
if (r != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
share[SYNC] = 0;
|
||||||
|
if (fork() == 0)
|
||||||
|
elock();
|
||||||
|
if (fork() == 0)
|
||||||
|
etest();
|
||||||
|
|
||||||
|
for (i = 0; i < PARALLEL; i++) {
|
||||||
|
wait(&s);
|
||||||
|
r += s == 0 ? 0 : 1;
|
||||||
|
}
|
||||||
|
if (r != 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (r != 0)
|
||||||
|
fprintf(stderr, "FAIL @ %d\n", n);
|
||||||
|
|
||||||
|
return (r);
|
||||||
|
}
|
38
tools/test/stress2/misc/aesni.sh
Executable file
38
tools/test/stress2/misc/aesni.sh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Simple AESNI(4) test.
|
||||||
|
|
||||||
|
kldstat -v | grep -qw aesni || { kldload aesni.ko; loaded=1; }
|
||||||
|
|
||||||
|
../misc/geli.sh
|
||||||
|
|
||||||
|
[ $loaded ] && kldunload aesni.ko
|
||||||
|
|
||||||
|
exit 0
|
95
tools/test/stress2/misc/all.debug.inc
Normal file
95
tools/test/stress2/misc/all.debug.inc
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 Peter Holm <pho@FreeBSD.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
# $FreeBSD$
|
||||||
|
#
|
||||||
|
|
||||||
|
# Example debug include file for misc/all.sh
|
||||||
|
|
||||||
|
pre_debug() {
|
||||||
|
debug_statfs=`vmstat -m | grep -w statfs | awk '{print $2}'`
|
||||||
|
debug_freework=`vmstat -m | grep -w freework | awk '{print $2}'`
|
||||||
|
debug_newblk=`vmstat -m | grep -w newblk | awk '{print $2}'`
|
||||||
|
debug_pts=`vmstat -m | grep -w pts | awk '{print $2}'`
|
||||||
|
debug_routetbl=`vmstat -m | grep -w routetbl | awk '{print $2}'`
|
||||||
|
debug_mount=`vmstat -m | awk '/ mount/{print $2}'`
|
||||||
|
debug_geom=`vmstat -m | grep -w GEOM | awk '{print $2}'`
|
||||||
|
# debug_indirdep=`vmstat -m | grep -w indirdep | awk '{print $2}'`
|
||||||
|
}
|
||||||
|
|
||||||
|
post_debug() {
|
||||||
|
local debug_new
|
||||||
|
|
||||||
|
debug_new=`vmstat -m | grep -w statfs | awk '{print $2}'`
|
||||||
|
[ $((debug_new - debug_statfs)) -gt 0 ] &&
|
||||||
|
{ printf "stress2: statfs leak: %d/%d.\r\n" \
|
||||||
|
$((debug_new - debug_statfs)) $debug_new > $console
|
||||||
|
debug_statfs=$debug_new; }
|
||||||
|
|
||||||
|
debug_new=`vmstat -m | grep -w freework | awk '{print $2}'`
|
||||||
|
[ $((debug_new - debug_freework)) -gt 0 -a $debug_new -gt 100 ] &&
|
||||||
|
{ printf "stress2: freework leak: %d/%d.\r\n" \
|
||||||
|
$((debug_new - debug_freework)) $debug_new > $console
|
||||||
|
debug_freework=$debug_new; }
|
||||||
|
|
||||||
|
debug_new=`vmstat -m | grep -w newblk | awk '{print $2}'`
|
||||||
|
[ $((debug_new - debug_newblk)) -gt 0 -a $debug_new -gt 100 ] &&
|
||||||
|
{ printf "stress2: newblk leak: %d/%d.\r\n" \
|
||||||
|
$((debug_new - debug_newblk)) $debug_new > $console
|
||||||
|
debug_newblk=$debug_new; }
|
||||||
|
|
||||||
|
debug_new=`vmstat -m | grep -w pts | awk '{print $2}'`
|
||||||
|
[ $((debug_new - debug_pts)) -gt 0 ] &&
|
||||||
|
{ printf "stress2: pts leak: %d/%d\r\n" \
|
||||||
|
$((debug_new - debug_pts)) $debug_new > $console
|
||||||
|
debug_pts=$debug_new; }
|
||||||
|
|
||||||
|
debug_new=`vmstat -m | grep -w routetbl | awk '{print $2}'`
|
||||||
|
[ $((debug_new - debug_routetbl)) -gt 0 ] &&
|
||||||
|
{ printf "stress2: routetbl leak: %d/%d\r\n" \
|
||||||
|
$((debug_new - debug_routetbl)) $debug_new > $console
|
||||||
|
debug_routetbl=$debug_new; }
|
||||||
|
|
||||||
|
debug_new=`vmstat -m | awk '/ mount/{print $2}'`
|
||||||
|
[ $((debug_new - debug_mount)) -gt 0 ] &&
|
||||||
|
{ printf "stress2: mount leak: %d/%d\r\n" \
|
||||||
|
$((debug_new - debug_mount)) $debug_new > $console
|
||||||
|
debug_mount=$debug_new; }
|
||||||
|
|
||||||
|
debug_new=`vmstat -m | awk '/GEOM/{print $2}'`
|
||||||
|
[ $((debug_new - debug_geom)) -gt 0 ] &&
|
||||||
|
{ printf "stress2: GEOM leak: %d/%d\r\n" \
|
||||||
|
$((debug_new - debug_geom)) $debug_new > $console
|
||||||
|
debug_geom=$debug_new; }
|
||||||
|
|
||||||
|
# debug_new=`vmstat -m | awk '/indirdep/{print $2}'`
|
||||||
|
# [ $((debug_new - debug_indirdep)) -gt 100 -a $debug_new -gt 100 ] &&
|
||||||
|
# { printf "stress2: indirdep leak: %d/%d\r\n" \
|
||||||
|
# $((debug_new - debug_indirdep)) $debug_new > $console
|
||||||
|
# debug_indirdep=$debug_new; }
|
||||||
|
}
|
||||||
|
|
||||||
|
all_debug=1
|
111
tools/test/stress2/misc/all.exclude
Normal file
111
tools/test/stress2/misc/all.exclude
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
# List of tests not to run, unless the '-a' option is used with run.sh
|
||||||
|
# Exclude names must start in column 1
|
||||||
|
|
||||||
|
backingstore.sh g_vfs_done():md6a[WRITE(offset=...)]error = 28 20111220
|
||||||
|
backingstore2.sh panic: 43 vncache entries remaining 20111220
|
||||||
|
backingstore3.sh g_vfs_done():md6a[WRITE(offset=...)]error = 28 20111230
|
||||||
|
collapse.sh panic: freeing mapped page 0xfffffe0028ed1d50 20200106
|
||||||
|
dd.sh CAM stuck in vmwait 20200116
|
||||||
|
devfs4.sh Hang seen 20210210
|
||||||
|
fsync.sh panic: Journal overflow 20190208
|
||||||
|
fuse.sh Memory corruption seen in log file kostik734.txt 20141114
|
||||||
|
fuse2.sh Deadlock seen 20121129
|
||||||
|
fuse3.sh Deadlock seen 20141120
|
||||||
|
getrandom.sh Known DoS issue 20201107
|
||||||
|
getrandom2.sh Known DoS issue 20200302
|
||||||
|
gjournal.sh panic: Journal overflow 20190626
|
||||||
|
gjournal2.sh panic: Journal overflow 20180125
|
||||||
|
gjournal3.sh panic: Bio not on queue 20171225
|
||||||
|
gjournal4.sh CAM stuck in vmwait 20180517
|
||||||
|
gnop7.sh Waiting for patch commit 20190820
|
||||||
|
gnop8.sh Waiting for patch commit 20201214
|
||||||
|
gnop9.sh Waiting for patch commit 20201214
|
||||||
|
gnop10.sh Waiting for patch commit 20210105
|
||||||
|
graid1_8.sh Known issue 20170909
|
||||||
|
graid1_9.sh panic: Bad effnlink 20180212
|
||||||
|
lockf5.sh Spinning threads seen 20160718
|
||||||
|
ifconfig2.sh https://people.freebsd.org/~pho/stress/log/log0051.txt 20210210
|
||||||
|
maxvnodes.sh Only supposed to work in single user mode 20190412
|
||||||
|
maxvnodes2.sh Only supposed to work in single user mode 20190412
|
||||||
|
memguard.sh Waiting for fix commit
|
||||||
|
memguard2.sh Waiting for fix commit
|
||||||
|
memguard3.sh Waiting for fix commit
|
||||||
|
memsetdomain.sh May change policy for random threads to to domainset_fixed 20210104
|
||||||
|
mlockall2.sh Unrecoverable OOM killing seen 20190203
|
||||||
|
mlockall7.sh Needs further investigation 20210123
|
||||||
|
nfs15lockd.sh panic: Assertion td->td_realucred == td->td_ucred failed ... 20210211
|
||||||
|
Xnfs15lockd2.sh WiP 20200805
|
||||||
|
Xnfs15lockd3.sh WiP 20200805
|
||||||
|
newfs4.sh watchdog fired. newbuf 20190225
|
||||||
|
nfs10.sh Double fault 20151013
|
||||||
|
nfs13.sh mount_nfs hangs in mntref 20191007
|
||||||
|
nfs16.sh panic: Failed to register NFS lock locally - error=11 20160608
|
||||||
|
oom2.sh Hang in pfault 20180324
|
||||||
|
overcommit2.sh CAM stuck in vmwait seen 20200112
|
||||||
|
pageout.sh panic: handle_written_filepage: not started 20190218
|
||||||
|
pmc4.sh ld: error: /usr/lib/libpmc.so: undefined reference 20210124
|
||||||
|
pmc5.sh ld: error: /usr/lib/libpmc.so: undefined reference 20210124
|
||||||
|
pmc6.sh ld: error: /usr/lib/libpmc.so: undefined reference 20210124
|
||||||
|
quota10.sh people.freebsd.org/~pho/stress/log/quota10-2.txt 20200525
|
||||||
|
quota2.sh panic: dqflush: stray dquot 20120221
|
||||||
|
quota3.sh panic: softdep_deallocate_dependencies: unrecovered ... 20111222
|
||||||
|
quota7.sh panic: dqflush: stray dquot 20120221
|
||||||
|
Xrename14.sh mark136.txt 20200525
|
||||||
|
sctp.sh panic: Queues are not empty when handling ... i386 20201104
|
||||||
|
sctp2.sh panic: soclose: SS_NOFDREF on enter 20200307
|
||||||
|
sctp3.sh panic: Queues are not empty when handling SHUTDOWN-COMPLETE 20210211
|
||||||
|
sendfile25.sh WiP 20200611
|
||||||
|
signal.sh Timing issues. Needs fixing 20171116
|
||||||
|
snap8.sh https://people.freebsd.org/~pho/stress/log/log0049.txt 20210216
|
||||||
|
snap9.sh panic: handle_written_filepage: not started 20170722
|
||||||
|
snap11.sh panic: handle_written_filepage: not started 20200928
|
||||||
|
suj13.sh Stuck with suspfs 20210105
|
||||||
|
suj31.sh Stuck with suspfs 20210105
|
||||||
|
suj34.sh Various hangs and panics (SUJ + NULLFS issue) 20131210
|
||||||
|
Xswap4.sh WiP 20171208
|
||||||
|
swapoff2.sh swap_pager_force_pagein: read from swap failed 20171223
|
||||||
|
swapoff5.sh log0005.txt, known issue 20210111
|
||||||
|
systrace.sh WiP 20200227
|
||||||
|
systrace2.sh WiP 20200227
|
||||||
|
syzkaller11.sh WiP 20200721
|
||||||
|
syzkaller15.sh WiP 20200712
|
||||||
|
syzkaller16.sh WiP 20200620
|
||||||
|
syzkaller17.sh WiP 20200630
|
||||||
|
syzkaller19.sh WiP 20200712
|
||||||
|
syzkaller25.sh WiP 20201116
|
||||||
|
syzkaller28.sh WiP 20201120
|
||||||
|
syzkaller29.sh May change policy for random threads to to domainset_fixed 20210104
|
||||||
|
syzkaller30.sh May change policy for random threads to to domainset_fixed 20210104
|
||||||
|
truss3.sh WiP 20200915
|
||||||
|
unionfs.sh insmntque: non-locked vp: xx is not exclusive locked... 20130909
|
||||||
|
unionfs2.sh insmntque: mp-safe fs and non-locked vp is not ... 20111219
|
||||||
|
unionfs3.sh insmntque: mp-safe fs and non-locked vp is not ... 20111216
|
||||||
|
|
||||||
|
# Test not to run for other reasons:
|
||||||
|
|
||||||
|
fuzz.sh A know issue
|
||||||
|
marcus3.sh OK, but runs for a long time
|
||||||
|
statfs.sh Not very interesting
|
||||||
|
vunref.sh No problems ever seen
|
||||||
|
vunref2.sh No problems ever seen
|
||||||
|
|
||||||
|
# Snapshots has been disabled on SU+J
|
||||||
|
suj15.sh
|
||||||
|
suj16.sh
|
||||||
|
suj19.sh
|
||||||
|
suj20.sh
|
||||||
|
suj21.sh
|
||||||
|
suj22.sh
|
||||||
|
suj24.sh
|
||||||
|
suj25.sh
|
||||||
|
suj26.sh
|
||||||
|
suj27.sh
|
||||||
|
suj28.sh
|
||||||
|
|
||||||
|
# Exclude NFS loopback tests
|
||||||
|
nfs2.sh panic: wrong diroffset 20140219
|
||||||
|
nfs5.sh
|
||||||
|
nfs6.sh
|
||||||
|
nfs11.sh vmwait deadlock 20151004
|
||||||
|
nullfs8.sh
|
||||||
|
tmpfs18.sh mntref hang seen 20191019
|
11
tools/test/stress2/misc/all.exclude.pae
Normal file
11
tools/test/stress2/misc/all.exclude.pae
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
PAE tests
|
||||||
|
|
||||||
|
# crossmp7.sh
|
||||||
|
# zfs.sh
|
||||||
|
# zfs2.sh
|
||||||
|
# zfs3.sh
|
||||||
|
# zfs4.sh
|
||||||
|
# zfs5.sh
|
||||||
|
# zfs6.sh
|
||||||
|
# zfs7.sh
|
||||||
|
# zfs8.sh
|
255
tools/test/stress2/misc/all.sh
Executable file
255
tools/test/stress2/misc/all.sh
Executable file
@ -0,0 +1,255 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008-2009, 2012-13 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Run all the scripts in stress2/misc.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
# Log and config files:
|
||||||
|
sdir=/tmp/stress2.d
|
||||||
|
mkdir -p $sdir
|
||||||
|
allconfig=$sdir/`hostname` # config file
|
||||||
|
allfaillog=$sdir/fail # Tests that failed
|
||||||
|
alllast=$sdir/last # Last test run
|
||||||
|
alllist=$sdir/list # -o list
|
||||||
|
alllog=$sdir/log # Tests run
|
||||||
|
alloutput=$sdir/output # Output from current test
|
||||||
|
allexcess=$sdir/excessive # Tests with excessive runtime
|
||||||
|
allelapsed=$sdir/elapsed # Test runtime
|
||||||
|
alllocal=$sdir/all.exclude # Local exclude list
|
||||||
|
loops=0 # Times to run the tests
|
||||||
|
# Get kernel config + revision
|
||||||
|
rev=`uname -a | awk '{print $7}' | sed 's/://'`
|
||||||
|
rev="`uname -a | sed 's#.*/compile/##; s/ .*//'` $rev"
|
||||||
|
|
||||||
|
args=`getopt acl:m:no "$@"`
|
||||||
|
[ $? -ne 0 ] &&
|
||||||
|
echo "Usage $0 [-a] [-c] [-l <val>] [-m <min.>] [-n] [-o] [<tests>]" &&
|
||||||
|
exit 1
|
||||||
|
set -- $args
|
||||||
|
for i; do
|
||||||
|
case "$i" in
|
||||||
|
-a) all=1 # Run all tests
|
||||||
|
echo "Note: including known problem tests."
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-c) rm -f $alllast # Clear last know test
|
||||||
|
rm -f $alllist
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-l) loops=$2 # Number of time to run
|
||||||
|
shift; shift
|
||||||
|
;;
|
||||||
|
-m) minutes=$(($2 * 60)) # Run for minutes
|
||||||
|
shift; shift
|
||||||
|
;;
|
||||||
|
-n) noshuffle=1 # Do not shuffle the list of tests
|
||||||
|
shift # Resume test after last test
|
||||||
|
;;
|
||||||
|
-o) loops=1 # Only run once
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
export allconfig
|
||||||
|
if [ ! -f $allconfig ]; then
|
||||||
|
echo "Creating local configuration file: $allconfig."
|
||||||
|
../tools/setup.sh || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
# Sanity checks
|
||||||
|
minspace=$((1024 * 1024)) # in k
|
||||||
|
[ -d `dirname "$diskimage"` ] ||
|
||||||
|
{ echo "diskimage dir: $diskimage not found"; exit 1; }
|
||||||
|
[ `df -k $(dirname $diskimage) | tail -1 | awk '{print $4}'` -lt \
|
||||||
|
$minspace ] &&
|
||||||
|
echo "Warn: Not enough disk space on `dirname $diskimage` " \
|
||||||
|
"for \$diskimage"
|
||||||
|
[ ! -d $(dirname $RUNDIR) ] &&
|
||||||
|
echo "No such \$RUNDIR \"`dirname $RUNDIR`\"" &&
|
||||||
|
exit 1
|
||||||
|
[ `sysctl -n hw.physmem` -le $((3 * 1024 * 1024 * 1024)) ] &&
|
||||||
|
echo "Warn: Small RAM size for stress tests `sysctl -n hw.physmem`"
|
||||||
|
[ `df -k $(dirname $RUNDIR) | tail -1 | awk '{print $4}'` -lt \
|
||||||
|
$minspace ] &&
|
||||||
|
echo "Warn: Not enough disk space on `dirname $RUNDIR` for \$RUNDIR"
|
||||||
|
id $testuser > /dev/null 2>&1 ||
|
||||||
|
{ echo "\$testuser \"$testuser\" not found."; exit 1; }
|
||||||
|
probe=`dirname $RUNDIR`/probe
|
||||||
|
su $testuser -c "touch $probe" > /dev/null 2>&1
|
||||||
|
[ -f $probe ] && rm $probe ||
|
||||||
|
{ echo "No write access to `dirname $RUNDIR`."; exit 1; }
|
||||||
|
[ `swapinfo | wc -l` -eq 1 ] &&
|
||||||
|
echo "Consider adding a swap disk. Many tests rely on this."
|
||||||
|
mount | grep -wq $mntpoint &&
|
||||||
|
echo "\$mntpoint ($mntpoint) is already in use" && exit 1
|
||||||
|
[ -x ../testcases/run/run ] ||
|
||||||
|
(cd ..; make)
|
||||||
|
ping -c 2 -t 2 $BLASTHOST > /dev/null 2>&1 ||
|
||||||
|
{ echo "Note: Can not ping \$BLASTHOST: $BLASTHOST"; }
|
||||||
|
echo "$loops" | grep -Eq "^[0-9]+$" ||
|
||||||
|
{ echo "The -l argument must be a positive number"; exit 1; }
|
||||||
|
[ `grep "^[a-zA-Z].*\.sh" $alllocal 2>/dev/null | wc -l` -ne 0 ] &&
|
||||||
|
echo "Using $alllocal"
|
||||||
|
|
||||||
|
find `dirname $alllast` -maxdepth 1 -name $alllast -mtime +12h -delete
|
||||||
|
touch $alllast $alllog
|
||||||
|
chmod 640 $alllast $alllog
|
||||||
|
find ../testcases -perm -1 \( -name "*.debug" -o -name "*.full" \) -delete
|
||||||
|
tail -2000 $alllog > ${alllog}.new; mv ${alllog}.new $alllog
|
||||||
|
touch $allelapsed
|
||||||
|
tail -20000 $allelapsed > ${allelapsed}.new; mv ${allelapsed}.new $allelapsed
|
||||||
|
|
||||||
|
console=/dev/console
|
||||||
|
printf "\r\n" > $console &
|
||||||
|
pid=$!
|
||||||
|
sleep 1
|
||||||
|
kill -0 $pid > /dev/null 2>&1 &&
|
||||||
|
{ console=/dev/null; kill -9 $pid; }
|
||||||
|
while pgrep -q fsck; do sleep 10; done
|
||||||
|
|
||||||
|
status() {
|
||||||
|
local s2 r
|
||||||
|
|
||||||
|
s2=`date +%s`
|
||||||
|
r=$(echo "elapsed $(((s2 - s1) / 86400)) day(s)," \
|
||||||
|
"`date -u -j -f '%s' '+%H:%M.%S' $((s2 - s1))`")
|
||||||
|
printf "`date '+%Y%m%d %T'` all.sh done, $r\n"
|
||||||
|
printf "`date '+%Y%m%d %T'` all.sh done, $r\r\n" > $console
|
||||||
|
}
|
||||||
|
|
||||||
|
intr() {
|
||||||
|
printf "\nExit all.sh\n"
|
||||||
|
./cleanup.sh
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
trap status EXIT
|
||||||
|
trap intr INT
|
||||||
|
|
||||||
|
[ -f all.debug.inc ] && . all.debug.inc
|
||||||
|
s1=`date +%s`
|
||||||
|
while true; do
|
||||||
|
exclude=`cat all.exclude $alllocal 2>/dev/null | sed '/^#/d' |
|
||||||
|
grep "^[a-zA-Z].*\.sh" | awk '{print $1}'`
|
||||||
|
list=`echo *.sh`
|
||||||
|
[ $# -ne 0 ] && list=$*
|
||||||
|
list=`echo $list |
|
||||||
|
sed "s/[[:<:]]all\.sh[[:>:]]//g;\
|
||||||
|
s/[[:<:]]cleanup\.sh[[:>:]]//g"`
|
||||||
|
|
||||||
|
if [ -n "$noshuffle" -a $# -eq 0 ]; then
|
||||||
|
last=`cat $alllast`
|
||||||
|
if [ -n "$last" ]; then
|
||||||
|
last=`basename $last`
|
||||||
|
l=`cat "$alllist" | sed "s/.*$last//"`
|
||||||
|
[ -z "$l" ] && l=$list # start over
|
||||||
|
list=$l
|
||||||
|
echo "Last test was $last,"\
|
||||||
|
"resuming test at" \
|
||||||
|
"`echo "$list" | awk '{print $1}'`"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
[ -n "$noshuffle" ] ||
|
||||||
|
list=`echo $list | tr ' ' '\n' | sort -R |
|
||||||
|
tr '\n' ' '`
|
||||||
|
|
||||||
|
lst=""
|
||||||
|
for i in $list; do
|
||||||
|
[ -z "$all" ] && echo $exclude | grep -qw `basename $i` &&
|
||||||
|
continue
|
||||||
|
lst="$lst $i"
|
||||||
|
done
|
||||||
|
[ -z "$lst" ] && exit
|
||||||
|
echo "$lst" > $alllist
|
||||||
|
|
||||||
|
pgrep -fq vmstat.sh ||
|
||||||
|
daemon ../tools/vmstat.sh > /tmp/stress2.d/vmstat 2>&1
|
||||||
|
|
||||||
|
n1=0
|
||||||
|
n2=`echo $lst | wc -w | sed 's/ //g'`
|
||||||
|
for i in $lst; do
|
||||||
|
i=`basename $i`
|
||||||
|
[ ! -f ./$i ] && { echo "No such file ./$i"; continue; }
|
||||||
|
n1=$((n1 + 1))
|
||||||
|
echo $i > $alllast
|
||||||
|
./cleanup.sh || exit 1
|
||||||
|
ts=`date '+%Y%m%d %T'`
|
||||||
|
echo "$ts all: $i"
|
||||||
|
printf "$ts all ($n1/$n2): $i\n" >> $alllog
|
||||||
|
printf "$ts all ($n1/$n2): $i\r\n" > $console
|
||||||
|
logger "Starting stress2 test all.sh: $i"
|
||||||
|
[ $all_debug ] && pre_debug
|
||||||
|
[ -f $i ] || loops=1 # break
|
||||||
|
sync; sleep .5; sync; sleep .5
|
||||||
|
grep -E "^USE_TIMEOUT=1" $i && TIMEOUT_ONE=1 ||
|
||||||
|
unset TIMEOUT_ONE
|
||||||
|
start=`date '+%s'`
|
||||||
|
(
|
||||||
|
if [ $USE_TIMEOUT ] || [ $TIMEOUT_ONE ]; then
|
||||||
|
timeout -k 1m 1h ./$i
|
||||||
|
else
|
||||||
|
./$i
|
||||||
|
fi
|
||||||
|
e=$?
|
||||||
|
[ $e -ne 0 ] &&
|
||||||
|
echo "FAIL $i exit code $e"
|
||||||
|
) 2>&1 | tee $alloutput
|
||||||
|
ts=`date '+%Y%m%d %T'`
|
||||||
|
grep -qw FAIL $alloutput &&
|
||||||
|
echo "$ts $rev $i" >> $allfaillog &&
|
||||||
|
logger "stress2 test $i failed"
|
||||||
|
grep -qw FATAL $alloutput && exit $e
|
||||||
|
rm -f $alloutput
|
||||||
|
printf "$ts $rev $i $((`date '+%s'` - start))\n" >> \
|
||||||
|
$allelapsed
|
||||||
|
[ -f ../tools/ministat.sh ] &&
|
||||||
|
../tools/ministat.sh $allelapsed $i
|
||||||
|
[ $((`date '+%s'` - start)) -gt 1980 ] &&
|
||||||
|
printf "$ts *** Excessive run time: %s %d min\r\n" $i, \
|
||||||
|
$(((`date '+%s'` - start) / 60)) |
|
||||||
|
tee $console >> $allexcess
|
||||||
|
while pgrep -q "^swap$"; do
|
||||||
|
echo "swap still running"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
[ $USE_SWAPOFF ] && { swapoff -a; swapon -a; }
|
||||||
|
[ $all_debug ] && post_debug
|
||||||
|
[ $minutes ] && [ $((`date +%s` - s1)) -ge $minutes ] &&
|
||||||
|
break 2
|
||||||
|
done
|
||||||
|
[ $((loops -= 1)) -eq 0 ] && break
|
||||||
|
done
|
||||||
|
[ -x ../tools/fail.sh ] && ../tools/fail.sh
|
||||||
|
find /tmp . -name "*.core" -mtime -2 -maxdepth 2 -ls 2>/dev/null
|
98
tools/test/stress2/misc/altbufferflushes.sh
Executable file
98
tools/test/stress2/misc/altbufferflushes.sh
Executable file
@ -0,0 +1,98 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Regression test. This script caused this panic:
|
||||||
|
|
||||||
|
# panic: lockmgr: locking against myself
|
||||||
|
# cpuid = 2
|
||||||
|
# KDB: enter: panic
|
||||||
|
# [thread pid 2526 tid 100070 ]
|
||||||
|
# Stopped at kdb_enter+0x2b: nop
|
||||||
|
# db> bt
|
||||||
|
# Tracing pid 2526 tid 100070 td 0xc46f8360
|
||||||
|
# kdb_enter(c094247f) at kdb_enter+0x2b
|
||||||
|
# panic(c09402b6,c46f8360,0,12,c06af5d9,...) at panic+0x14b
|
||||||
|
# _lockmgr(d864a748,202122,c479f788,c46f8360,c094b01c,12d) at _lockmgr+0x41a
|
||||||
|
# getblk(c479f6b8,5d51940,0,4000,0,...) at getblk+0x13c
|
||||||
|
# breadn(c479f6b8,5d51940,0,4000,0,...) at breadn+0x2f
|
||||||
|
# bread(c479f6b8,5d51940,0,4000,0,e6d13544,c4743eac,0,c095a185,56d) at bread+0x20
|
||||||
|
# ffs_alloccg(c47408c4,104,1754628,0,4000,c4743eac,1,c095a185,4d8) at ffs_alloccg+0x11d
|
||||||
|
# ffs_hashalloc(c47408c4,104,1754628,0,4000,...) at ffs_hashalloc+0x45
|
||||||
|
# ffs_alloc(c47408c4,3f2cd,0,1754628,0,4000,c42fd400,e6d13674) at ffs_alloc+0x1a5
|
||||||
|
# ffs_balloc_ufs2(c4735d70,fcb34000,0,4000,c42fd400,...) at ffs_balloc_ufs2+0x1619
|
||||||
|
# ffs_copyonwrite(c479f6b8,d84e3d08) at ffs_copyonwrite+0x3d3
|
||||||
|
# ffs_geom_strategy(c479f7c0,d84e3d08) at ffs_geom_strategy+0xbd
|
||||||
|
# bufwrite(d84e3d08,4000,d84e3d08,e6d137e4,c070b7a9,...) at bufwrite+0x17a
|
||||||
|
# ffs_bufwrite(d84e3d08) at ffs_bufwrite+0x282
|
||||||
|
# vfs_bio_awrite(d84e3d08) at vfs_bio_awrite+0x235
|
||||||
|
# bdwrite(d864a6e8,c4743eac,0,c095a185,57c,...) at bdwrite+0x237
|
||||||
|
# ffs_alloccg(c4b54a50,104,1754628,0,4000,c4743eac,1,c095a185,4d8) at ffs_alloccg+0x1f6
|
||||||
|
# ffs_hashalloc(c4b54a50,104,1754628,0,4000,...) at ffs_hashalloc+0x45
|
||||||
|
# ffs_alloc(c4b54a50,1b00c,0,1754628,0,4000,c4b22a80,e6d139ac) at ffs_alloc+0x1a5
|
||||||
|
# ffs_balloc_ufs2(c4e72158,6c030000,0,4000,c4b22a80,...) at ffs_balloc_ufs2+0x1619
|
||||||
|
# ffs_write(e6d13b98) at ffs_write+0x2ac
|
||||||
|
# VOP_WRITE_APV(c0a00e80,e6d13b98) at VOP_WRITE_APV+0x132
|
||||||
|
# vn_write(c46c65a0,e6d13c60,c4b22a80,0,c46f8360) at vn_write+0x1f6
|
||||||
|
# dofilewrite(c46f8360,4,c46c65a0,e6d13c60,ffffffff,...) at dofilewrite+0x77
|
||||||
|
# kern_writev(c46f8360,4,e6d13c60,8430000,d0000,...) at kern_writev+0x36
|
||||||
|
# write(c46f8360,e6d13d00) at write+0x45
|
||||||
|
# syscall(e6d13d38) at syscall+0x256
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
persist () {
|
||||||
|
false
|
||||||
|
while [ $? -ne 0 ]; do
|
||||||
|
$1 > /dev/null 2>&1
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
diskfree=`df -k /var/tmp | tail -1 | awk '{print $4}'`
|
||||||
|
[ $((diskfree / 1024 / 1024)) -lt 5 ] && echo "Not enough disk space" && exit 1
|
||||||
|
|
||||||
|
rm -f /var/.snap/stress2 /var/tmp/big.?
|
||||||
|
trap "rm -f /var/.snap/stress2 /var/tmp/big.?" EXIT INT
|
||||||
|
persist 'mksnap_ffs /var /var/.snap/stress2'
|
||||||
|
tresh=`sysctl vfs.dirtybufthresh | awk '{print $NF}'`
|
||||||
|
sysctl vfs.dirtybufthresh=10
|
||||||
|
|
||||||
|
cd /var/tmp
|
||||||
|
for j in `jot 5`; do
|
||||||
|
old=`sysctl vfs.altbufferflushes | awk '{print $NF}'`
|
||||||
|
for i in `jot 4`; do
|
||||||
|
echo "`date '+%T'` Create big.$i"
|
||||||
|
dd if=/dev/zero of=big.$i bs=1m count=4k status=none
|
||||||
|
done
|
||||||
|
sleep 1
|
||||||
|
rm -rf /var/tmp/big.?
|
||||||
|
new=`sysctl vfs.altbufferflushes | awk '{print $NF}'`
|
||||||
|
[ $new -ne $old ] && echo "vfs.altbufferflushes changed from $old to $new."
|
||||||
|
done
|
||||||
|
sysctl vfs.dirtybufthresh=$tresh
|
||||||
|
rm -f /var/.snap/stress2
|
131
tools/test/stress2/misc/alternativeFlushPath.sh
Executable file
131
tools/test/stress2/misc/alternativeFlushPath.sh
Executable file
@ -0,0 +1,131 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Alternate buffer flush path test (Not verified).
|
||||||
|
# Regression test for r169006.
|
||||||
|
# Apply this patch to amplify the problem:
|
||||||
|
#
|
||||||
|
# diff -r1.520 vfs_bio.c
|
||||||
|
# 894c894
|
||||||
|
# < if (bo->bo_dirty.bv_cnt > dirtybufthresh + 10) {
|
||||||
|
# ---
|
||||||
|
# > if (bo->bo_dirty.bv_cnt > dirtybufthresh /*+ 10*/) {
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
odir=`pwd`
|
||||||
|
dir=$RUNDIR/alternativeFlushPath
|
||||||
|
|
||||||
|
[ -d $dir ] && find $dir -type f | xargs rm
|
||||||
|
rm -rf $dir
|
||||||
|
mkdir -p $dir
|
||||||
|
cd $dir
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > $dir/alternativeFlushPath.c
|
||||||
|
mycc -o /tmp/alternativeFlushPath -Wall -Wextra alternativeFlushPath.c ||
|
||||||
|
exit 1
|
||||||
|
rm -f alternativeFlushPath.c
|
||||||
|
|
||||||
|
for j in `jot 10`; do
|
||||||
|
/tmp/alternativeFlushPath &
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
sysctl vfs.altbufferflushes
|
||||||
|
|
||||||
|
cd $odir
|
||||||
|
rm -rf /tmp/alternativeFlushPath $dir
|
||||||
|
|
||||||
|
exit
|
||||||
|
|
||||||
|
EOF
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/signal.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <err.h>
|
||||||
|
|
||||||
|
#define MAXNOFILE 500000 /* To limit runtime */
|
||||||
|
|
||||||
|
static volatile sig_atomic_t more;
|
||||||
|
|
||||||
|
static void
|
||||||
|
handler(int i __unused) {
|
||||||
|
more = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test(void)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
char name[80];
|
||||||
|
pid_t mypid;
|
||||||
|
int *fd;
|
||||||
|
struct rlimit rlp;
|
||||||
|
|
||||||
|
if (getrlimit(RLIMIT_NOFILE, &rlp) == -1)
|
||||||
|
err(1, "getrlimit(RLIMIT_NOFILE)");
|
||||||
|
if (rlp.rlim_cur > MAXNOFILE)
|
||||||
|
rlp.rlim_cur = MAXNOFILE;
|
||||||
|
rlp.rlim_cur /= 10;
|
||||||
|
mypid = getpid();
|
||||||
|
fd = malloc(rlp.rlim_cur * sizeof(int));
|
||||||
|
|
||||||
|
for (i = 0, j = 0; i < rlp.rlim_cur && more == 1; i++, j++) {
|
||||||
|
sprintf(name, "f%05d.%05d", mypid, i);
|
||||||
|
if ((fd[i] = open(name, O_CREAT|O_WRONLY, 0666)) == -1) {
|
||||||
|
warn("open(%s)", name);
|
||||||
|
more = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = 0; i < j; i++) {
|
||||||
|
sprintf(name, "f%05d.%05d", mypid, i);
|
||||||
|
if (unlink(name) == -1)
|
||||||
|
warn("unlink(%s)", name);
|
||||||
|
}
|
||||||
|
for (i = 0; i < j; i++) {
|
||||||
|
if (close(fd[i]) == -1)
|
||||||
|
warn("close(%d)", i);
|
||||||
|
}
|
||||||
|
free(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
more = 1;
|
||||||
|
signal(SIGALRM, handler);
|
||||||
|
alarm(20 * 60);
|
||||||
|
while (more == 1)
|
||||||
|
test();
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
57
tools/test/stress2/misc/arp.sh
Executable file
57
tools/test/stress2/misc/arp.sh
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# arp(8) seen waiting in "sbwait" (on non HEAD):
|
||||||
|
# UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
|
||||||
|
# 0 70090 68079 0 20 0 9872 2384 sbwait S+ u0 0:00.32 arp -da
|
||||||
|
|
||||||
|
[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
start=`date +%s`
|
||||||
|
for i in `jot 3`; do
|
||||||
|
while [ $((`date +%s` - start)) -lt 120 ]; do arp -da > /dev/null 2>&1; done &
|
||||||
|
pids="$pids $!"
|
||||||
|
done
|
||||||
|
(cd ../testcases/swap; ./swap -t 2m -i 20 -h -l 100) > /dev/null
|
||||||
|
while [ $((`date +%s` - start)) -lt 120 ]; do sleep 1; done
|
||||||
|
|
||||||
|
for i in `jot 10`; do
|
||||||
|
n=`pgrep -f arp.sh | wc -l`
|
||||||
|
[ $n -eq 0 ] && break
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
s=0
|
||||||
|
if [ $n -ne 0 ]; then
|
||||||
|
ps -l | grep -v grep | grep arp
|
||||||
|
pgrep arp | xargs procstat -k
|
||||||
|
while pkill arp; do :; done
|
||||||
|
s=1
|
||||||
|
fi
|
||||||
|
wait
|
||||||
|
exit $s
|
46
tools/test/stress2/misc/aslr.sh
Executable file
46
tools/test/stress2/misc/aslr.sh
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
#/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# ELF32/64 address map randomization test.
|
||||||
|
|
||||||
|
# "panic: page 0xfffff8103971b840 has queue state" seen in WiP kernel code.
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/mark087.txt
|
||||||
|
|
||||||
|
old32=`sysctl -ni kern.elf32.aslr.enable`
|
||||||
|
old64=`sysctl -ni kern.elf64.aslr.enable`
|
||||||
|
|
||||||
|
if [ -n "$old32" ]; then
|
||||||
|
sysctl kern.elf32.aslr.enable=$((1 - old32))
|
||||||
|
./su.sh
|
||||||
|
sysctl kern.elf32.aslr.enable=$old32
|
||||||
|
elif [ -n "$old64" ]; then
|
||||||
|
sysctl kern.elf64.aslr.enable=$((1 - old64))
|
||||||
|
./su.sh
|
||||||
|
sysctl kern.elf64.aslr.enable=$old64
|
||||||
|
fi
|
58
tools/test/stress2/misc/audit.sh
Executable file
58
tools/test/stress2/misc/audit.sh
Executable file
@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# "Fatal trap 12: page fault while in kernel mode" seen.
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/audit.txt
|
||||||
|
# Fixed by: r294137
|
||||||
|
|
||||||
|
# Test scenario by: kib
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
[ -z "$footshoot" ] && exit 0
|
||||||
|
|
||||||
|
[ -f /usr/sbin/auditd -a -f /etc/rc.d/auditd ] || exit 0
|
||||||
|
pgrep -q auditd && exit 0
|
||||||
|
mount | grep -q /var || exit 0
|
||||||
|
|
||||||
|
service auditd onestart
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
su $testuser -c date > /dev/null
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
umount -f /var
|
||||||
|
sleep 1
|
||||||
|
mount /var
|
||||||
|
|
||||||
|
service auditd onestop
|
||||||
|
|
||||||
|
# Some services react badly to /var being unmounted.
|
||||||
|
service -R
|
||||||
|
exit 0
|
59
tools/test/stress2/misc/audit2.sh
Executable file
59
tools/test/stress2/misc/audit2.sh
Executable file
@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Dell EMC Isilon
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
# No problems seen.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
[ -f /usr/sbin/auditd -a -f /etc/rc.d/auditd ] || exit 0
|
||||||
|
pgrep -q auditd && exit 0 || service auditd onestart
|
||||||
|
|
||||||
|
mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 1g -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
|
||||||
|
export runRUNTIME=5m
|
||||||
|
export RUNDIR=$mntpoint/stressX
|
||||||
|
|
||||||
|
su $testuser -c 'cd ..; ./run.sh marcus.cfg'
|
||||||
|
|
||||||
|
n=0
|
||||||
|
while mount | grep $mntpoint | grep -q /dev/md; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
[ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; }
|
||||||
|
done
|
||||||
|
checkfs /dev/md${mdstart}$part; s=$?
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
service auditd onestop
|
||||||
|
|
||||||
|
exit 0
|
81
tools/test/stress2/misc/backingstore.sh
Executable file
81
tools/test/stress2/misc/backingstore.sh
Executable file
@ -0,0 +1,81 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Test sparse backing store
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
D=$diskimage
|
||||||
|
export here=`pwd`
|
||||||
|
|
||||||
|
m=$mdstart
|
||||||
|
|
||||||
|
mount | grep "$mntpoint" | grep -q md$m && umount ${mntpoint}$m
|
||||||
|
mdconfig -l | grep -q md$m && mdconfig -d -u $m
|
||||||
|
|
||||||
|
dd if=/dev/zero of=$D$m bs=100m count=1 status=none || exit 1
|
||||||
|
|
||||||
|
mdconfig -a -t vnode -f $D$m -u $m
|
||||||
|
|
||||||
|
bsdlabel -w md$m auto
|
||||||
|
newfs md${m}$part > /dev/null 2>&1
|
||||||
|
[ -d ${mntpoint}$m ] || mkdir -p ${mntpoint}$m
|
||||||
|
mount $opt /dev/md${m}$part ${mntpoint}$m
|
||||||
|
|
||||||
|
n=$m
|
||||||
|
m=$((m + 1))
|
||||||
|
|
||||||
|
mount | grep "$mntpoint" | grep -q md$m && umount ${mntpoint}$m
|
||||||
|
mdconfig -l | grep -q md$m && mdconfig -d -u $m
|
||||||
|
|
||||||
|
truncate -s 500M ${mntpoint}$n/diskimage
|
||||||
|
mdconfig -a -t vnode -f ${mntpoint}$n/diskimage -u $m
|
||||||
|
|
||||||
|
bsdlabel -w md$m auto
|
||||||
|
newfs md${m}$part > /dev/null 2>&1
|
||||||
|
[ -d ${mntpoint}$m ] || mkdir -p ${mntpoint}$m
|
||||||
|
mount $opt /dev/md${m}$part ${mntpoint}$m
|
||||||
|
|
||||||
|
export RUNDIR=${mntpoint}$m/stressX
|
||||||
|
../testcases/rw/rw -t 5m -i 200 -h -n
|
||||||
|
|
||||||
|
while mount | grep -q ${mntpoint}$m; do
|
||||||
|
flag=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f" || echo "")
|
||||||
|
umount $flag ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
mdconfig -l | grep -q md$m && mdconfig -d -u $m
|
||||||
|
|
||||||
|
m=$((m - 1))
|
||||||
|
while mount | grep -q ${mntpoint}$m; do
|
||||||
|
umount $([ $((`date '+%s'` % 2)) -eq 0 ] && \
|
||||||
|
echo "-f" || echo "") ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
mdconfig -l | grep -q md$m && mdconfig -d -u $m
|
||||||
|
rm -f $D
|
72
tools/test/stress2/misc/backingstore2.sh
Executable file
72
tools/test/stress2/misc/backingstore2.sh
Executable file
@ -0,0 +1,72 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Test unmount of a device that is already gone
|
||||||
|
|
||||||
|
# Leaves /mnt6 unmountable and leads to a "panic: 1 vncache entries remaining"
|
||||||
|
# during shut down.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
D=$diskimage
|
||||||
|
export here=`pwd`
|
||||||
|
|
||||||
|
m1=$mdstart
|
||||||
|
m2=$((m1 + 1))
|
||||||
|
mount | grep "$mntpoint" | grep -q md$m2 && umount ${mntpoint}$m2
|
||||||
|
mdconfig -l | grep -q md$m2 && mdconfig -d -u $m2
|
||||||
|
mount | grep "$mntpoint" | grep -q md$m1 && umount ${mntpoint}$m1
|
||||||
|
mdconfig -l | grep -q md$m1 && mdconfig -d -u $m1
|
||||||
|
[ -d ${mntpoint}$m1 ] || mkdir -p ${mntpoint}$m1
|
||||||
|
[ -d ${mntpoint}$m2 ] || mkdir -p ${mntpoint}$m2
|
||||||
|
|
||||||
|
dd if=/dev/zero of=$D$m bs=100m count=1 status=none || exit 1
|
||||||
|
|
||||||
|
mdconfig -a -t vnode -f $D$m1 -u $m1
|
||||||
|
|
||||||
|
bsdlabel -w md$m1 auto
|
||||||
|
newfs md${m1}$part > /dev/null 2>&1
|
||||||
|
mount /dev/md${m1}$part ${mntpoint}$m1
|
||||||
|
|
||||||
|
truncate -s 500M ${mntpoint}$m1/diskimage
|
||||||
|
mdconfig -a -t vnode -f ${mntpoint}$m1/diskimage -u $m2
|
||||||
|
|
||||||
|
bsdlabel -w md$m2 auto
|
||||||
|
newfs md${m2}$part > /dev/null 2>&1
|
||||||
|
mount /dev/md${m2}$part ${mntpoint}$m2
|
||||||
|
|
||||||
|
# Reversed umount sequence:
|
||||||
|
umount -f /dev/md${m1}$part
|
||||||
|
umount -f /dev/md${m2}$part
|
||||||
|
|
||||||
|
mount | grep "$mntpoint" | grep -q md$m2 && umount ${mntpoint}$m2
|
||||||
|
mdconfig -l | grep -q md$m2 && mdconfig -d -u $m2
|
||||||
|
mount | grep "$mntpoint" | grep -q md$m1 && umount ${mntpoint}$m1
|
||||||
|
mdconfig -l | grep -q md$m1 && mdconfig -d -u $m1
|
73
tools/test/stress2/misc/backingstore3.sh
Executable file
73
tools/test/stress2/misc/backingstore3.sh
Executable file
@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Test unmount of a device that is already gone
|
||||||
|
|
||||||
|
# Caused "panic: bundirty: buffer 0xdafaf2c4 still on queue 1"
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
D=$diskimage
|
||||||
|
export here=`pwd`
|
||||||
|
|
||||||
|
m1=$mdstart
|
||||||
|
m2=$((m1 + 1))
|
||||||
|
mount | grep "$mntpoint" | grep -q md$m2 && umount ${mntpoint}$m2
|
||||||
|
mdconfig -l | grep -q md$m2 && mdconfig -d -u $m2
|
||||||
|
mount | grep "$mntpoint" | grep -q md$m1 && umount ${mntpoint}$m1
|
||||||
|
mdconfig -l | grep -q md$m1 && mdconfig -d -u $m1
|
||||||
|
[ -d ${mntpoint}$m1 ] || mkdir -p ${mntpoint}$m1
|
||||||
|
[ -d ${mntpoint}$m2 ] || mkdir -p ${mntpoint}$m2
|
||||||
|
|
||||||
|
dd if=/dev=zero of=$D$m bs=25m count=1 status=none || exit 1
|
||||||
|
|
||||||
|
mdconfig -a -t vnode -f $D$m1 -u $m1
|
||||||
|
|
||||||
|
bsdlabel -w md$m1 auto
|
||||||
|
newfs md${m1}$part > /dev/null 2>&1
|
||||||
|
mount /dev/md${m1}$part ${mntpoint}$m1
|
||||||
|
|
||||||
|
truncate -s 500M ${mntpoint}$m1/diskimage
|
||||||
|
mdconfig -a -t vnode -f ${mntpoint}$m1/diskimage -u $m2
|
||||||
|
|
||||||
|
bsdlabel -w md$m2 auto
|
||||||
|
newfs md${m2}$part > /dev/null 2>&1
|
||||||
|
mount /dev/md${m2}$part ${mntpoint}$m2
|
||||||
|
|
||||||
|
dd if=/dev/zero of=${mntpoint}$m2/file bs=1m > /dev/null 2>&1
|
||||||
|
|
||||||
|
# Reversed umount sequence:
|
||||||
|
umount -f /dev/md${m1}$part
|
||||||
|
umount -f /dev/md${m2}$part
|
||||||
|
|
||||||
|
mount | grep "$mntpoint" | grep -q md$m2 && umount ${mntpoint}$m2
|
||||||
|
mdconfig -l | grep -q md$m2 && mdconfig -d -u $m2
|
||||||
|
mount | grep "$mntpoint" | grep -q md$m1 && umount ${mntpoint}$m1
|
||||||
|
mdconfig -l | grep -q md$m1 && mdconfig -d -u $m1
|
65
tools/test/stress2/misc/badcode.sh
Executable file
65
tools/test/stress2/misc/badcode.sh
Executable file
@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 Dell EMC
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
# Run tests on a 2g swap backed MD with UFS SU fs.
|
||||||
|
|
||||||
|
# "panic: SACK scoreboard must not be empty" seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/full.txt
|
||||||
|
# Fixed by r310547.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
kldstat -v | grep -q pty || kldload pty # ignore any load failure
|
||||||
|
|
||||||
|
mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 2g -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
|
||||||
|
export LOAD=80
|
||||||
|
export rwLOAD=80
|
||||||
|
export runRUNTIME=10m
|
||||||
|
export RUNDIR=$mntpoint/stressX
|
||||||
|
|
||||||
|
export TESTPROGS="
|
||||||
|
testcases/badcode/badcode
|
||||||
|
testcases/swap/swap
|
||||||
|
testcases/sysctl/sysctl
|
||||||
|
"
|
||||||
|
su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS'
|
||||||
|
|
||||||
|
../tools/killall.sh
|
||||||
|
while mount | grep "on $mntpoint " | grep -q /dev/md; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
checkfs /dev/md${mdstart}$part
|
||||||
|
mdconfig -d -u $mdstart
|
57
tools/test/stress2/misc/badcode2.sh
Executable file
57
tools/test/stress2/misc/badcode2.sh
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019 Peter Holm
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
# Freeze seen: https://people.freebsd.org/~pho/stress/log/kostik1241.txt
|
||||||
|
# Fixed by: r355474
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 2g -u $mdstart
|
||||||
|
newfs $newfs_flags md$mdstart > /dev/null
|
||||||
|
mount /dev/md$mdstart $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
|
||||||
|
export badcodeLOAD=100
|
||||||
|
export runRUNTIME=10m
|
||||||
|
export RUNDIR=$mntpoint/stressX
|
||||||
|
|
||||||
|
export TESTPROGS="testcases/badcode/badcode testcases/swap/swap"
|
||||||
|
su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS'
|
||||||
|
|
||||||
|
../tools/killall.sh
|
||||||
|
while mount | grep "on $mntpoint " | grep -q /dev/md; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
exit
|
||||||
|
|
57
tools/test/stress2/misc/badcode3.sh
Executable file
57
tools/test/stress2/misc/badcode3.sh
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019 Peter Holm
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
# No problems seen.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 1g -u $mdstart
|
||||||
|
newfs $newfs_flags md$mdstart > /dev/null
|
||||||
|
mount /dev/md$mdstart $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
cd $mntpoint
|
||||||
|
(cd $here/../testcases/swap; ./swap -t 5m -i 20) &
|
||||||
|
sleep 2
|
||||||
|
while pgrep -q swap; do
|
||||||
|
timeout 1m limits -c 0 $here/../testcases/badcode/badcode -t 1m -i 20
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
cd $here
|
||||||
|
while mount | grep "on $mntpoint " | grep -q /dev/md; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
exit
|
||||||
|
|
300
tools/test/stress2/misc/bench.sh
Executable file
300
tools/test/stress2/misc/bench.sh
Executable file
@ -0,0 +1,300 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2017 Dell EMC Isilon
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# "benchmark" for file system use, using no physical disk.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
export LANG=C
|
||||||
|
dir=/tmp
|
||||||
|
odir=`pwd`
|
||||||
|
cd $dir
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > $dir/bench.c
|
||||||
|
mycc -o bench -Wall -Wextra -O0 -g bench.c || exit 1
|
||||||
|
rm -f bench.c
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 1g -u $mdstart || exit 1
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
|
||||||
|
log=/tmp/stress2.d/bench.sh.log
|
||||||
|
[ -f $log ] && old=`tail -1 $log | awk '{print $2}'`
|
||||||
|
tmp=/tmp/bench.sh.tmp
|
||||||
|
s=0
|
||||||
|
for j in `jot 5`; do
|
||||||
|
newfs -n -b 4096 -f 512 -i 1024 md${mdstart}$part > \
|
||||||
|
/dev/null
|
||||||
|
mount -o async /dev/md${mdstart}$part $mntpoint
|
||||||
|
/usr/bin/time sh -c "(cd $mntpoint; /tmp/bench)" 2>&1 | \
|
||||||
|
awk '{print $1}'
|
||||||
|
[ $? -ne 0 ] && s=1
|
||||||
|
umount $mntpoint
|
||||||
|
done | ministat -n | tail -1 | awk '{printf "%.3f %.3f\n",$6,$7}' > $tmp
|
||||||
|
r=`cat $tmp`
|
||||||
|
echo "`date +%Y%m%d%H%M` $r `uname -a`" >> $log
|
||||||
|
tail -5 $log | cut -c 1-92
|
||||||
|
rm $tmp
|
||||||
|
|
||||||
|
if [ $old ]; then
|
||||||
|
awk -v old=$old -v new=$(echo $r | awk '{print $1}') \
|
||||||
|
'BEGIN {if ((new - old) * 100 / old > 5) exit 1; else exit 0}'
|
||||||
|
s=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in `jot 6`; do
|
||||||
|
mount | grep -q "on $mntpoint " || break
|
||||||
|
umount $mntpoint && break || sleep 10
|
||||||
|
done
|
||||||
|
[ $i -eq 6 ] && exit 1
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
rm -rf /tmp/bench
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define LOOPS 50000
|
||||||
|
#define TESTS 6
|
||||||
|
#define TIMEOUT 600
|
||||||
|
|
||||||
|
static void (*functions[TESTS])();
|
||||||
|
|
||||||
|
static void
|
||||||
|
t1(void)
|
||||||
|
{
|
||||||
|
int fd, i;
|
||||||
|
char file[128];
|
||||||
|
|
||||||
|
alarm(TIMEOUT);
|
||||||
|
for (i = 0; i < LOOPS; i++) {
|
||||||
|
if (i % 1000 == 0)
|
||||||
|
setproctitle("%s @ %d", __func__, i);
|
||||||
|
snprintf(file, sizeof(file), "t1.%06d.%03d", getpid(), i);
|
||||||
|
if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC,
|
||||||
|
DEFFILEMODE)) == -1)
|
||||||
|
err(1, "open(%s)", file);
|
||||||
|
close(fd);
|
||||||
|
if (unlink(file) == -1)
|
||||||
|
err(1, "unlink(%s)", file);
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
t2(void)
|
||||||
|
{
|
||||||
|
int fd, i;
|
||||||
|
char file[128];
|
||||||
|
|
||||||
|
alarm(TIMEOUT);
|
||||||
|
for (i = 0; i < LOOPS; i++) {
|
||||||
|
if (i % 1000 == 0)
|
||||||
|
setproctitle("%s @ %d", __func__, i);
|
||||||
|
snprintf(file, sizeof(file), "t2.%06d.%03d", getpid(), i);
|
||||||
|
if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC,
|
||||||
|
DEFFILEMODE)) == -1)
|
||||||
|
err(1, "open(%s)", file);
|
||||||
|
close(fd);
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
|
for (i = 0; i < LOOPS; i++) {
|
||||||
|
snprintf(file, sizeof(file), "t2.%06d.%03d", getpid(), i);
|
||||||
|
if (unlink(file) == -1)
|
||||||
|
err(1, "unlink(%s)", file);
|
||||||
|
}
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
t3(void)
|
||||||
|
{
|
||||||
|
int fd, i;
|
||||||
|
char dir[128], file[128];
|
||||||
|
|
||||||
|
alarm(TIMEOUT);
|
||||||
|
snprintf(dir, sizeof(dir), "t3.%06d.dir", getpid());
|
||||||
|
if (mkdir(dir, 700) == -1)
|
||||||
|
err(1, "mkdir(%s)", dir);
|
||||||
|
for (i = 0; i < LOOPS; i++) {
|
||||||
|
if (i % 1000 == 0)
|
||||||
|
setproctitle("%s @ %d", __func__, i);
|
||||||
|
snprintf(file, sizeof(file), "%s/t3.%06d.%03d", dir,
|
||||||
|
getpid(), i);
|
||||||
|
if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC,
|
||||||
|
DEFFILEMODE)) == -1)
|
||||||
|
err(1, "open(%s)", file);
|
||||||
|
close(fd);
|
||||||
|
if (unlink(file) == -1)
|
||||||
|
err(1, "unlink(%s)", file);
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
|
if (rmdir(dir) == -1)
|
||||||
|
err(1, "rmdir(%s)", dir);
|
||||||
|
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
t4(void)
|
||||||
|
{
|
||||||
|
int fd, i;
|
||||||
|
char file[128], new[128];
|
||||||
|
|
||||||
|
alarm(TIMEOUT);
|
||||||
|
for (i = 0; i < LOOPS / 2; i++) {
|
||||||
|
if (i % 1000 == 0)
|
||||||
|
setproctitle("%s @ %d", __func__, i);
|
||||||
|
snprintf(file, sizeof(file), "t4.%06d.%03d", getpid(), i);
|
||||||
|
if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC,
|
||||||
|
DEFFILEMODE)) == -1)
|
||||||
|
err(1, "open(%s)", file);
|
||||||
|
close(fd);
|
||||||
|
snprintf(new, sizeof(new), "t4.%06d.%03d.new", getpid(), i);
|
||||||
|
if (rename(file, new) == -1)
|
||||||
|
err(1, "rename(%s, %s)", file, new);
|
||||||
|
if (unlink(new) == -1)
|
||||||
|
err(1, "unlink(%s)", new);
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
t5(void)
|
||||||
|
{
|
||||||
|
int fd, i;
|
||||||
|
char buf[512], file[128];
|
||||||
|
|
||||||
|
alarm(TIMEOUT);
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
for (i = 0; i < LOOPS; i++) {
|
||||||
|
if (i % 1000 == 0)
|
||||||
|
setproctitle("%s @ %d", __func__, i);
|
||||||
|
snprintf(file, sizeof(file), "t5.%06d.%03d", getpid(), i);
|
||||||
|
if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC,
|
||||||
|
DEFFILEMODE)) == -1)
|
||||||
|
err(1, "open(%s)", file);
|
||||||
|
if (write(fd, buf, sizeof(buf)) != sizeof(buf))
|
||||||
|
err(1, "write(%s)", file);
|
||||||
|
close(fd);
|
||||||
|
if (unlink(file) == -1)
|
||||||
|
err(1, "unlink(%s)", file);
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
t6(void)
|
||||||
|
{
|
||||||
|
int fd, i;
|
||||||
|
char buf[512], file[128];
|
||||||
|
|
||||||
|
alarm(TIMEOUT);
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
for (i = 0; i < LOOPS / 2; i++) {
|
||||||
|
if (i % 1000 == 0)
|
||||||
|
setproctitle("%s/write @ %d", __func__, i);
|
||||||
|
snprintf(file, sizeof(file), "t6.%06d.%03d", getpid(), i);
|
||||||
|
if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC,
|
||||||
|
DEFFILEMODE)) == -1)
|
||||||
|
err(1, "open(%s)", file);
|
||||||
|
if (write(fd, buf, sizeof(buf)) != sizeof(buf))
|
||||||
|
err(1, "write(%s)", file);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
for (i = 0; i < LOOPS / 2; i++) {
|
||||||
|
if (i % 1000 == 0)
|
||||||
|
setproctitle("%s/read @ %d", __func__, i);
|
||||||
|
snprintf(file, sizeof(file), "t6.%06d.%03d", getpid(), i);
|
||||||
|
if ((fd = open(file, O_RDONLY)) == -1)
|
||||||
|
err(1, "open(%s)", file);
|
||||||
|
if (read(fd, buf, sizeof(buf)) != sizeof(buf))
|
||||||
|
err(1, "write(%s)", file);
|
||||||
|
close(fd);
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
|
for (i = 0; i < LOOPS / 2; i++) {
|
||||||
|
snprintf(file, sizeof(file), "t6.%06d.%03d", getpid(), i);
|
||||||
|
if (unlink(file) == -1)
|
||||||
|
err(1, "unlink(%s)", file);
|
||||||
|
}
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test(void)
|
||||||
|
{
|
||||||
|
pid_t pids[TESTS];
|
||||||
|
int e, i, status;
|
||||||
|
|
||||||
|
e = 0;
|
||||||
|
for (i = 0; i < TESTS; i++)
|
||||||
|
if ((pids[i] = fork()) == 0)
|
||||||
|
functions[i]();
|
||||||
|
for (i = 0; i < TESTS; i++) {
|
||||||
|
if (waitpid(pids[i], &status, 0) != pids[i])
|
||||||
|
err(1, "waitpid(%d)", pids[i]);
|
||||||
|
e += status != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (e);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
int e;
|
||||||
|
|
||||||
|
functions[0] = &t1;
|
||||||
|
functions[1] = &t2;
|
||||||
|
functions[2] = &t3;
|
||||||
|
functions[3] = &t4;
|
||||||
|
functions[4] = &t5;
|
||||||
|
functions[5] = &t6;
|
||||||
|
|
||||||
|
e = test();
|
||||||
|
|
||||||
|
return (e);
|
||||||
|
}
|
110
tools/test/stress2/misc/beneath.sh
Executable file
110
tools/test/stress2/misc/beneath.sh
Executable file
@ -0,0 +1,110 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2021 Konstantin Belousov <kib@FreeBSD.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Test of open(2) with the O_BENEATH flag.
|
||||||
|
|
||||||
|
# userret: returning with the following locks held:
|
||||||
|
# shared lockmgr ufs (ufs) r = 0 (0xfffff804ec0d2a48) locked @
|
||||||
|
# kern/vfs_subr.c:2590 seen in WiP code:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik1126.txt
|
||||||
|
|
||||||
|
top=/tmp/beneath.d
|
||||||
|
mkdir -p $top
|
||||||
|
cat > $top/beneath.c <<EOF
|
||||||
|
/* $Id: beneath.c,v 1.1 2018/10/13 16:53:02 kostik Exp kostik $ */
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifndef O_BENEATH
|
||||||
|
#define O_BENEATH 0x00400000 /* Fail if not under cwd */
|
||||||
|
#define AT_BENEATH 0x1000 /* Fail if not under dirfd */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
char *name;
|
||||||
|
int error, fd, i;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
name = argv[i];
|
||||||
|
alarm(120);
|
||||||
|
fd = open(name, O_RDONLY | O_BENEATH);
|
||||||
|
if (fd == -1) {
|
||||||
|
fprintf(stderr, "open(\"%s\") failed, error %d %s\n",
|
||||||
|
name, errno, strerror(errno));
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "open(\"%s\") succeeded\n", name);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
error = fstatat(AT_FDCWD, name, &st, AT_BENEATH);
|
||||||
|
if (error == -1){
|
||||||
|
fprintf(stderr, "stat(\"%s\") failed, error %d %s\n",
|
||||||
|
name, errno, strerror(errno));
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "stat(\"%s\") succeeded\n", name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
cc -o $top/beneath -Wall -Wextra $top/beneath.c || exit 1
|
||||||
|
rm $top/beneath.c
|
||||||
|
|
||||||
|
# Test with two directories as arguments:
|
||||||
|
cd $top
|
||||||
|
mkdir -p a/b
|
||||||
|
./beneath a/b
|
||||||
|
./beneath $top/a/b
|
||||||
|
touch $top/a/c
|
||||||
|
./beneath a/c
|
||||||
|
./beneath $top/a/c
|
||||||
|
./beneath a/d
|
||||||
|
./beneath $top/a/d
|
||||||
|
|
||||||
|
# CWD is still $top for this test
|
||||||
|
top2=/var/tmp/beneath.d
|
||||||
|
mkdir -p $top2
|
||||||
|
mkdir -p $top2/a/b
|
||||||
|
./beneath $top2/a/b > /dev/null 2>&1
|
||||||
|
|
||||||
|
touch $top2/a/c
|
||||||
|
./beneath $top2/a/c > /dev/null 2>&1
|
||||||
|
|
||||||
|
# Other CWDs
|
||||||
|
(cd /etc; find . | head -1000 | xargs $top/beneath) > /dev/null 2>&1
|
||||||
|
(cd /var; find . | head -1000 | xargs $top/beneath) > /dev/null 2>&1
|
||||||
|
|
||||||
|
rm -rf $top $top2
|
||||||
|
exit 0
|
101
tools/test/stress2/misc/beneath2.sh
Executable file
101
tools/test/stress2/misc/beneath2.sh
Executable file
@ -0,0 +1,101 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# O_BENEATH test with a relative path, which is a symbolic link pointing
|
||||||
|
# to an absolute path.
|
||||||
|
|
||||||
|
# "panic: Assertion (ndp->ni_lcf & NI_LCF_LATCH) != 0 failed at
|
||||||
|
# ../../../kern/vfs_lookup.c:182" seen. Fixed by r340343.
|
||||||
|
|
||||||
|
# Based on scenario by Vladimir Kondratyev <vladimir kondratyev su>
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
dir=/tmp
|
||||||
|
odir=`pwd`
|
||||||
|
cd $dir
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > $dir/beneath2.c
|
||||||
|
mycc -o beneath2 -Wall -Wextra -O0 -g beneath2.c || exit 1
|
||||||
|
rm -f beneath2.c
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
set -e
|
||||||
|
mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 1g -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
set +e
|
||||||
|
|
||||||
|
cd $mntpoint
|
||||||
|
ln -s /tmp/justalongname symlink
|
||||||
|
$dir/beneath2 symlink
|
||||||
|
s=$?
|
||||||
|
[ -f beneath2.core -a $s -eq 0 ] &&
|
||||||
|
{ ls -l beneath2.core; mv beneath2.core $dir; s=1; }
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
for i in `jot 6`; do
|
||||||
|
mount | grep -q "on $mntpoint " || break
|
||||||
|
umount $mntpoint && break || sleep 10
|
||||||
|
[ $i -eq 6 ] &&
|
||||||
|
{ echo FATAL; fstat -mf $mntpoint; exit 1; }
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
rm -rf $dir/beneath2
|
||||||
|
exit $s
|
||||||
|
|
||||||
|
EOF
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
char *file;
|
||||||
|
|
||||||
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "Usage: %s <file>", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
file = argv[1];
|
||||||
|
if ((fd = open(file, O_RDONLY | O_BENEATH)) != 0 &&
|
||||||
|
errno != ENOTCAPABLE)
|
||||||
|
err(1, "open(%s)", file);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
92
tools/test/stress2/misc/beneath3.sh
Executable file
92
tools/test/stress2/misc/beneath3.sh
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2019 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# vput: 0xfffff808d79c0278 is not locked but should be
|
||||||
|
# KDB: enter: lock violation
|
||||||
|
# Test scenario suggestions by kib@ and markj@
|
||||||
|
|
||||||
|
# Fixed by r348052.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
dir=/tmp
|
||||||
|
odir=`pwd`
|
||||||
|
cd $dir
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > $dir/beneath3.c
|
||||||
|
mycc -o beneath3 -Wall -Wextra -O0 -g beneath3.c || exit 1
|
||||||
|
rm -f beneath3.c
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
set -e
|
||||||
|
mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 1g -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
set +e
|
||||||
|
|
||||||
|
cd $mntpoint
|
||||||
|
(cd /usr; $dir/beneath3)
|
||||||
|
s=$?
|
||||||
|
[ -f beneath3.core -a $s -eq 0 ] &&
|
||||||
|
{ ls -l beneath3.core; mv beneath3.core $dir; s=1; }
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
for i in `jot 6`; do
|
||||||
|
mount | grep -q "on $mntpoint " || break
|
||||||
|
umount $mntpoint && break || sleep 10
|
||||||
|
[ $i -eq 6 ] &&
|
||||||
|
{ echo FATAL; fstat -mf $mntpoint; exit 1; }
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
rm -rf $dir/beneath3
|
||||||
|
exit $s
|
||||||
|
|
||||||
|
EOF
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
char file[] = "/..";
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
fd = open(file, O_CREAT | O_RDONLY | O_BENEATH);
|
||||||
|
if (fd != -1 || errno != ENOTCAPABLE)
|
||||||
|
err(1, "open(%s) returns %d", file, fd);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
133
tools/test/stress2/misc/beneath4.sh
Executable file
133
tools/test/stress2/misc/beneath4.sh
Executable file
@ -0,0 +1,133 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2021 Peter Holm <pho@FreeBSD.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Test of:
|
||||||
|
# AT_BENEATH 0x1000 /* Fail if not under dirfd */
|
||||||
|
# AT_RESOLVE_BENEATH 0x2000 /* As AT_BENEATH, but do not allow
|
||||||
|
# resolve to walk out of dirfd even
|
||||||
|
|
||||||
|
dir=/tmp/beneath4.dir
|
||||||
|
rm -rf $dir
|
||||||
|
mkdir -p $dir
|
||||||
|
here=`pwd`
|
||||||
|
cd $dir
|
||||||
|
|
||||||
|
cat > beneath4.c <<EOF
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
int exp, fd, flag, r;
|
||||||
|
char *cwd, *dir, *obj, *s;
|
||||||
|
|
||||||
|
if (argc != 5) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Usage: %s <dir> <test obj> <flag> <expected return>\n",
|
||||||
|
argv[0]);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
cwd = getwd(NULL);
|
||||||
|
dir = argv[1];
|
||||||
|
obj = argv[2];
|
||||||
|
sscanf(argv[3], "%x", &flag);
|
||||||
|
exp = atoi(argv[4]);
|
||||||
|
#if 0
|
||||||
|
if ((flag & (AT_BENEATH | AT_RESOLVE_BENEATH)) == 0) {
|
||||||
|
fprintf(stderr, "Flag must be %#x or %#x\n",
|
||||||
|
AT_BENEATH, AT_RESOLVE_BENEATH);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if ((fd = open(dir, O_DIRECTORY | O_RDONLY)) == -1)
|
||||||
|
err(1, "open(%s)", dir);
|
||||||
|
|
||||||
|
if (fstatat(fd, obj, &st, flag) == -1)
|
||||||
|
r = errno;
|
||||||
|
else
|
||||||
|
r = 0;
|
||||||
|
s = "FAIL";
|
||||||
|
if (r == exp)
|
||||||
|
s = "OK";
|
||||||
|
warn("cwd=%s, top=%s. flag=%0.6x. fstatf(%s) = %2d (expect %2d). %4s",
|
||||||
|
cwd, dir, flag, obj, r, exp, s);
|
||||||
|
|
||||||
|
return (r == exp ? 0 : errno);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
cc -o beneath4 -Wall -Wextra -O2 -g beneath4.c || exit 1
|
||||||
|
rm beneath4.c
|
||||||
|
|
||||||
|
mkdir -p /tmp/beneath4.dir/a/a
|
||||||
|
touch /tmp/beneath4.dir/a/f
|
||||||
|
ln /tmp/beneath4.dir/a/f /tmp/beneath4.dir/a/c
|
||||||
|
ln -s /tmp/beneath4.dir/a/a /tmp/beneath4.dir/a/d
|
||||||
|
ln -s /tmp/beneath4.dir/a/b /tmp/beneath4.dir/a/e
|
||||||
|
mkfifo /tmp/beneath4.dir/a/fifo
|
||||||
|
|
||||||
|
top=$dir/a
|
||||||
|
|
||||||
|
cd $here
|
||||||
|
s=0
|
||||||
|
ls -lR $dir
|
||||||
|
echo AT_BENEATH
|
||||||
|
$dir/beneath4 $top a 0x1000 0 || s=1
|
||||||
|
$dir/beneath4 $top b 0x1000 2 || s=1
|
||||||
|
$dir/beneath4 $top c 0x1000 0 || s=1
|
||||||
|
$dir/beneath4 $top d 0x1000 0 || s=1
|
||||||
|
$dir/beneath4 $top e 0x1000 2 || s=1
|
||||||
|
$dir/beneath4 $top fifo 0x1000 0 || s=1
|
||||||
|
$dir/beneath4 $top $top/../../beneath4.d/a/a 0x1000 93 || s=1
|
||||||
|
$dir/beneath4 $top $top/.. 0x1000 93 || s=1
|
||||||
|
$dir/beneath4 $top ../a 0x1000 0 || s=1
|
||||||
|
|
||||||
|
printf "\nAT_RESOLVE_BENEATH\n"
|
||||||
|
$dir/beneath4 $top a 0x2000 0 || s=1
|
||||||
|
$dir/beneath4 $top b 0x2000 2 || s=1
|
||||||
|
$dir/beneath4 $top c 0x2000 0 || s=1
|
||||||
|
$dir/beneath4 $top d 0x2000 93 || s=1
|
||||||
|
$dir/beneath4 $top e 0x2000 93 || s=1
|
||||||
|
$dir/beneath4 $top fifo 0x2000 0 || s=1
|
||||||
|
$dir/beneath4 $top $top/../../beneath4.d/a/a 0x2000 22 || s=1
|
||||||
|
$dir/beneath4 $top $top/.. 0x2000 22 || s=1
|
||||||
|
$dir/beneath4 $top ../a 0x2000 93 || s=1
|
||||||
|
printf "\nNo flag\n"
|
||||||
|
$dir/beneath4 $top ../a 0x0000 0 || s=1
|
||||||
|
rm -rf $top
|
||||||
|
exit $s
|
225
tools/test/stress2/misc/bio.sh
Executable file
225
tools/test/stress2/misc/bio.sh
Executable file
@ -0,0 +1,225 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# mmap() & read()/write() on same file.
|
||||||
|
# Test scenario suggestion by: jeff@
|
||||||
|
|
||||||
|
# Out of VM deadlock seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/jeff114.txt
|
||||||
|
|
||||||
|
# panic: deadlkres: possible deadlock detected:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/jeff115.txt
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
dir=/tmp
|
||||||
|
odir=`pwd`
|
||||||
|
cd $dir
|
||||||
|
ps=`sysctl -n hw.pagesize`
|
||||||
|
sed "1,/^EOF/d;s/\$ps/$ps/" < $odir/$0 > $dir/bio.c
|
||||||
|
mycc -o bio -Wall -Wextra -O0 -g bio.c || exit 1
|
||||||
|
rm -f bio.c
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 2g -u $mdstart || exit 1
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs -n md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
|
||||||
|
(cd $mntpoint; /tmp/bio) &
|
||||||
|
pid1=$!
|
||||||
|
sleep 5
|
||||||
|
(cd ../testcases/swap; ./swap -t 5m -i 20 -k -l 100 -h) &
|
||||||
|
pid2=$!
|
||||||
|
|
||||||
|
while pgrep -q bio; do
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
while pgrep -q swap; do
|
||||||
|
pkill -9 swap
|
||||||
|
done
|
||||||
|
wait $pid2
|
||||||
|
wait $pid1
|
||||||
|
s=$?
|
||||||
|
|
||||||
|
while mount | grep "on $mntpoint " | grep -q /dev/md; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
rm -rf /tmp/bio
|
||||||
|
exit $s
|
||||||
|
|
||||||
|
EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <machine/atomic.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sched.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define PS $ps /* From hw.pagesize */
|
||||||
|
#define SYN1 0
|
||||||
|
#define SYN2 1
|
||||||
|
#define INDX 2
|
||||||
|
|
||||||
|
#define PAGES (512 * 1024 * 1024 / PS) /* 512MB file size */
|
||||||
|
#define PARALLEL 3
|
||||||
|
#define RUNTIME (5 * 60)
|
||||||
|
#define TIMEOUT (30 * 60)
|
||||||
|
|
||||||
|
char buf[PS];
|
||||||
|
|
||||||
|
void
|
||||||
|
test(int inx)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
size_t i, len, slen;
|
||||||
|
time_t start;
|
||||||
|
volatile u_int *share;
|
||||||
|
int fd, r;
|
||||||
|
u_int *ip, val;
|
||||||
|
char file[80];
|
||||||
|
|
||||||
|
slen = PS;
|
||||||
|
if ((share = mmap(NULL, slen, PROT_READ | PROT_WRITE, MAP_ANON |
|
||||||
|
MAP_SHARED, -1, 0)) == MAP_FAILED)
|
||||||
|
err(1, "mmap");
|
||||||
|
|
||||||
|
snprintf(file, sizeof(file), "file.%06d", inx);
|
||||||
|
if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0640)) < 0)
|
||||||
|
err(1, "%s", file);
|
||||||
|
|
||||||
|
for (i = 0; i < PAGES; i++) {
|
||||||
|
if (write(fd, buf, sizeof(buf)) != sizeof(buf))
|
||||||
|
err(1, "write error");
|
||||||
|
}
|
||||||
|
|
||||||
|
len = PS * PAGES * sizeof(u_int);
|
||||||
|
if ((ip = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||||
|
fd, 0)) == MAP_FAILED)
|
||||||
|
err(1, "mmap");
|
||||||
|
|
||||||
|
start = time(NULL);
|
||||||
|
if ((pid = fork()) == 0) {
|
||||||
|
alarm(2 * RUNTIME);
|
||||||
|
/* mmap read / write access */
|
||||||
|
for (i = 0; i < (size_t)(PAGES * PS); i += PS) {
|
||||||
|
while (share[SYN1] == 0)
|
||||||
|
sched_yield();
|
||||||
|
atomic_add_int(&share[SYN1], -1);
|
||||||
|
if (ip[share[INDX] / sizeof(u_int)] != share[INDX])
|
||||||
|
warn("child expected %d, but got %d\n",
|
||||||
|
ip[share[INDX] / sizeof(u_int)],
|
||||||
|
share[INDX]);
|
||||||
|
share[INDX] += PS;
|
||||||
|
ip[share[INDX] / sizeof(u_int)] = share[INDX];
|
||||||
|
atomic_add_int(&share[SYN2], 1); /* signal parent */
|
||||||
|
if (i % 1000 == 0 && time(NULL) - start > TIMEOUT)
|
||||||
|
errx(1, "Timed out");;
|
||||||
|
}
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
if (pid == -1)
|
||||||
|
err(1, "fork()");
|
||||||
|
share[INDX] = 0;
|
||||||
|
atomic_add_int(&share[SYN2], 1);
|
||||||
|
alarm(2 * RUNTIME);
|
||||||
|
for (i = 0; i < (size_t)(PAGES * PS); i += PS) {
|
||||||
|
while (share[SYN2] == 0)
|
||||||
|
sched_yield();
|
||||||
|
atomic_add_int(&share[SYN2], -1);
|
||||||
|
if (lseek(fd, share[INDX], SEEK_SET) == -1)
|
||||||
|
err(1, "lseek error");
|
||||||
|
if ((r = read(fd, &val, sizeof(val))) != sizeof(val))
|
||||||
|
err(1, "parent read read %d bytes", r);
|
||||||
|
if (val != share[INDX])
|
||||||
|
warn("parent expected %d, but got %d\n",
|
||||||
|
share[INDX], val);
|
||||||
|
val += PS;
|
||||||
|
if (lseek(fd, val, SEEK_SET) == -1)
|
||||||
|
err(1, "lseek error");
|
||||||
|
if (write(fd, &val, sizeof(val)) != sizeof(val))
|
||||||
|
err(1, "write");
|
||||||
|
|
||||||
|
atomic_add_int(&share[SYN1], 1); /* signal child */
|
||||||
|
if (i % 1000 == 0 && time(NULL) - start > TIMEOUT)
|
||||||
|
errx(1, "Timed out");;
|
||||||
|
}
|
||||||
|
atomic_add_int(&share[SYN2], -1);
|
||||||
|
if (waitpid(pid, NULL, 0) != pid)
|
||||||
|
err(1, "wait");
|
||||||
|
|
||||||
|
if (munmap(ip, len) == -1)
|
||||||
|
err(1, "unmap()");
|
||||||
|
if (munmap((void *)share, slen) == -1)
|
||||||
|
err(1, "unmap()");
|
||||||
|
close(fd);
|
||||||
|
if (unlink(file) == -1)
|
||||||
|
err(1, "unlink(%s)", file);
|
||||||
|
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
pid_t pids[PARALLEL];
|
||||||
|
time_t start;
|
||||||
|
int i, s, status;
|
||||||
|
|
||||||
|
start = time(NULL);
|
||||||
|
s = 0;
|
||||||
|
while ((time(NULL) - start) < RUNTIME && s == 0) {
|
||||||
|
for (i = 0; i < PARALLEL; i++) {
|
||||||
|
if ((pids[i] = fork()) == 0)
|
||||||
|
test(i);
|
||||||
|
}
|
||||||
|
for (i = 0; i < PARALLEL; i++) {
|
||||||
|
if (waitpid(pids[i], &status, 0) == -1)
|
||||||
|
err(1, "waitpid(%d)", pids[i]);
|
||||||
|
if (status != 0)
|
||||||
|
fprintf(stderr, "Child exit status = %d\n",
|
||||||
|
status);
|
||||||
|
s += status == 0 ? 0 : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (s);
|
||||||
|
}
|
63
tools/test/stress2/misc/buildkernel.sh
Executable file
63
tools/test/stress2/misc/buildkernel.sh
Executable file
@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2021 Peter Holm <pho@FreeBSD.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Buildkernel test with SU
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
[ -d /usr/src/sys ] || exit 0
|
||||||
|
set -e
|
||||||
|
mount | grep -q "on $mntpoint " && umount $mntpoint
|
||||||
|
mdconfig -a -t swap -s 5g -u $mdstart
|
||||||
|
newfs $newfs_flags md$mdstart > /dev/null
|
||||||
|
mount /dev/md$mdstart $mntpoint
|
||||||
|
set +e
|
||||||
|
|
||||||
|
cd /usr/src
|
||||||
|
export MAKEOBJDIRPREFIX=$mntpoint/obj
|
||||||
|
export TMPDIR=$mntpoint/tmp
|
||||||
|
mkdir $TMPDIR
|
||||||
|
chmod 0777 $TMPDIR
|
||||||
|
log=$mntpoint/log
|
||||||
|
|
||||||
|
p=$((`sysctl -n hw.ncpu`+ 1))
|
||||||
|
p=`jot -r 1 1 $p`
|
||||||
|
echo "make -j $p buildkernel KERNCONF=GENERIC DESTDIR=$mntpoint" \
|
||||||
|
"TARGET=amd64 TARGET_ARCH=amd64"
|
||||||
|
make -j $p buildkernel KERNCONF=GENERIC DESTDIR=$mntpoint TARGET=amd64 \
|
||||||
|
TARGET_ARCH=amd64 > $log 2>&1; s=$?
|
||||||
|
[ $s -ne 0 ] && tail -50 $log
|
||||||
|
|
||||||
|
while mount | grep -q "on $mntpoint "; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
exit $s
|
67
tools/test/stress2/misc/buildworld.sh
Executable file
67
tools/test/stress2/misc/buildworld.sh
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# "panic: Invalid page 0xfffff8007f227cf0 on inact queue" seen.
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/buildworld.txt
|
||||||
|
# Fixed by r289377
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
[ -d /usr/src/sys ] || exit 0
|
||||||
|
[ `sysctl -n hw.physmem` -gt $(( 2 * 1024 * 1024 * 1024)) ] &&
|
||||||
|
{ echo "RAM must be clamped to 2GB or less for this test."; exit 0; }
|
||||||
|
rm -f $diskimage
|
||||||
|
[ `df -k $(dirname $diskimage) | tail -1 | awk '{print $4}'` -lt \
|
||||||
|
$((3 * 1024 * 1024)) ] && { echo "Need 3GB on `dirname $diskimage`"; \
|
||||||
|
exit 0; }
|
||||||
|
mount | grep -q "on $mntpoint " && umount $mntpoint
|
||||||
|
dd if=/dev/zero of=$diskimage bs=1m count=3k status=none
|
||||||
|
trap "rm -f $diskimage" EXIT INT
|
||||||
|
mdconfig -a -t vnode -f $diskimage -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
mount -o async /dev/md${mdstart}$part $mntpoint
|
||||||
|
|
||||||
|
cd /usr/src
|
||||||
|
export MAKEOBJDIRPREFIX=$mntpoint/obj
|
||||||
|
export TMPDIR=$mntpoint/tmp
|
||||||
|
mkdir $TMPDIR
|
||||||
|
chmod 0777 $TMPDIR
|
||||||
|
|
||||||
|
p=$((`sysctl -n hw.ncpu`+ 1))
|
||||||
|
timeout 20m make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 \
|
||||||
|
TARGET_ARCH=amd64 > /dev/null
|
||||||
|
|
||||||
|
while mount | grep -q "on $mntpoint "; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
checkfs /dev/md$mdstart || s=$?
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
exit $s
|
57
tools/test/stress2/misc/buildworld2.sh
Executable file
57
tools/test/stress2/misc/buildworld2.sh
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# tmpfs version of buildworld.sh
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
[ -d /usr/src/sys ] || exit 0
|
||||||
|
[ `swapinfo | wc -l` -eq 1 ] && exit 0
|
||||||
|
[ `sysctl -n hw.physmem` -gt $(( 2 * 1024 * 1024 * 1024)) ] &&
|
||||||
|
{ echo "RAM must be clamped to 2GB or less."; exit 0; }
|
||||||
|
mount | grep -q "on $mntpoint " && umount $mntpoint
|
||||||
|
mount -t tmpfs tmpfs $mntpoint || exit 1
|
||||||
|
|
||||||
|
cd /usr/src
|
||||||
|
export MAKEOBJDIRPREFIX=$mntpoint/obj
|
||||||
|
export TMPDIR=$mntpoint/tmp
|
||||||
|
mkdir $TMPDIR
|
||||||
|
chmod 0777 $TMPDIR
|
||||||
|
|
||||||
|
p=$((`sysctl -n hw.ncpu`+ 1))
|
||||||
|
make -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 TARGET_ARCH=amd64 \
|
||||||
|
> /dev/null &
|
||||||
|
sleep $((20 * 60))
|
||||||
|
kill $!
|
||||||
|
wait
|
||||||
|
|
||||||
|
while mount | grep -q "on $mntpoint "; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
95
tools/test/stress2/misc/buildworld3.sh
Executable file
95
tools/test/stress2/misc/buildworld3.sh
Executable file
@ -0,0 +1,95 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Buildworld / quota test scenario.
|
||||||
|
|
||||||
|
# "panic: chkdquot: missing dquot" seen
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik1113.txt
|
||||||
|
# Fixed in r338798 + r338799
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
[ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0
|
||||||
|
[ -d /usr/src/sys ] || exit 0
|
||||||
|
mount | grep -q "on $mntpoint " && umount $mntpoint
|
||||||
|
mdconfig -a -t swap -s 2g -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
|
||||||
|
export PATH_FSTAB=/tmp/fstab
|
||||||
|
trap "rm -f $PATH_FSTAB" EXIT INT
|
||||||
|
echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB
|
||||||
|
mount $mntpoint
|
||||||
|
set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'`
|
||||||
|
export QK=$(($1 / 2))
|
||||||
|
export QI=$(($2 / 2))
|
||||||
|
edquota -u -f $mntpoint -e \
|
||||||
|
${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI $testuser
|
||||||
|
quotaon $mntpoint
|
||||||
|
mount | grep $mntpoint
|
||||||
|
|
||||||
|
cd /usr/src
|
||||||
|
export MAKEOBJDIRPREFIX=$mntpoint/obj
|
||||||
|
export TMPDIR=$mntpoint/tmp
|
||||||
|
mkdir $TMPDIR $MAKEOBJDIRPREFIX
|
||||||
|
chmod 0777 $TMPDIR $MAKEOBJDIRPREFIX
|
||||||
|
|
||||||
|
p=$((`sysctl -n hw.ncpu`+ 1))
|
||||||
|
su $testuser -c \
|
||||||
|
"make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 \
|
||||||
|
TARGET_ARCH=amd64 > /dev/null" &
|
||||||
|
sleep 2
|
||||||
|
start=`date +%s`
|
||||||
|
while [ $((`date +%s` - start)) -lt 1200 ]; do
|
||||||
|
kill -0 $! > /dev/null 2>&1 || break
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
kill $! > /dev/null 2>&1
|
||||||
|
# Let make run 50% of the time so quotaoff runs on an active FS
|
||||||
|
[ `jot -r 1 0 1` -eq 1 ] &&
|
||||||
|
pkill -U$testuser make
|
||||||
|
wait
|
||||||
|
|
||||||
|
while ! quotaoff $mntpoint; do
|
||||||
|
sync
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
pgrep -q -U$testuser make && pkill -U$testuser make
|
||||||
|
export tmp=/tmp/$(basename $0).$$
|
||||||
|
quotacheck -v $mntpoint > $tmp 2>&1
|
||||||
|
grep -q failed $tmp && { cat $tmp; s=1; }
|
||||||
|
while mount | grep -q "on $mntpoint "; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
checkfs /dev/md$mdstart || s=$?
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
rm -f $PATH_FSTAB
|
||||||
|
exit $s
|
74
tools/test/stress2/misc/buildworld4.sh
Executable file
74
tools/test/stress2/misc/buildworld4.sh
Executable file
@ -0,0 +1,74 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Buildworld test with SUJ
|
||||||
|
# "fsync: giving up on dirty (error = 35): tag devfs, type VCHR" seen.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
[ -d /usr/src/sys ] || exit 0
|
||||||
|
rm -f $diskimage
|
||||||
|
mount | grep -q "on $mntpoint " && umount $mntpoint
|
||||||
|
mdconfig -a -t swap -s 5g -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
[ "$newfs_flags" = "-U" ] && newfs_flags="-j"
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
mount | grep $mntpoint
|
||||||
|
|
||||||
|
cd /usr/src
|
||||||
|
export MAKEOBJDIRPREFIX=$mntpoint/obj
|
||||||
|
export TMPDIR=$mntpoint/tmp
|
||||||
|
mkdir $TMPDIR
|
||||||
|
chmod 0777 $TMPDIR
|
||||||
|
|
||||||
|
p=$((`sysctl -n hw.ncpu`+ 1))
|
||||||
|
[ `sysctl -n vm.swap_total` -gt 0 ] && p=$((p * 4))
|
||||||
|
p=`jot -r 1 1 $p`
|
||||||
|
echo "make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 "\
|
||||||
|
"TARGET_ARCH=amd64"
|
||||||
|
make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 TARGET_ARCH=amd64 \
|
||||||
|
> /dev/null &
|
||||||
|
sleep 1
|
||||||
|
start=`date +%s`
|
||||||
|
while [ $((`date +%s` - start)) -lt 600 ]; do
|
||||||
|
kill -0 $! > /dev/null 2>&1 || break
|
||||||
|
sleep 30
|
||||||
|
done
|
||||||
|
kill $! > /dev/null 2>&1
|
||||||
|
wait
|
||||||
|
|
||||||
|
while mount | grep -q "on $mntpoint "; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
checkfs /dev/md$mdstart; s=$?
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
exit $s
|
210
tools/test/stress2/misc/burnin.sh
Executable file
210
tools/test/stress2/misc/burnin.sh
Executable file
@ -0,0 +1,210 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Time creating and deleting a number of files once a minute.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
export LANG=C
|
||||||
|
dir=/tmp
|
||||||
|
runtime=1200 # default
|
||||||
|
[ $# -eq 1 ] && runtime=$1
|
||||||
|
odir=`pwd`
|
||||||
|
cd $dir
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > $dir/burnin.c
|
||||||
|
mycc -o burnin -Wall -Wextra -O0 -g burnin.c || exit 1
|
||||||
|
rm -f burnin.c
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 1g -u $mdstart || exit 1
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs -n md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
d=`date '+%Y%m%dT%H%M%S'`
|
||||||
|
log=/tmp/burnin.$d.log
|
||||||
|
mode=`pgrep -q cron && echo "Multi-user" || echo "Single-user"`
|
||||||
|
echo "# `uname -a` $mode mode `hostname`" > $log
|
||||||
|
|
||||||
|
/tmp/burnin -r 10 -d $mntpoint > /dev/null 2>&1
|
||||||
|
/tmp/burnin -r $runtime -d $mntpoint >> $log
|
||||||
|
|
||||||
|
ministat -A -C 2 -w 72 $log | tail -1 | awk '{if ($NF > .1) exit(1)}'
|
||||||
|
s=$?
|
||||||
|
[ $s -ne 0 ] && ministat -C 2 -w 72 $log
|
||||||
|
|
||||||
|
while mount | grep "on $mntpoint " | grep -q /dev/md; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
rm -rf /tmp/burnin $log
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <machine/atomic.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define DELAY 60
|
||||||
|
#define SYNC 0
|
||||||
|
|
||||||
|
volatile u_int *share;
|
||||||
|
int bufsize, files, parallel, runtime;
|
||||||
|
char *buf, *dir;
|
||||||
|
|
||||||
|
void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage: %s [-b buf size] [-d directory] [-p parallel] "
|
||||||
|
"[-r runtime]\n",
|
||||||
|
getprogname());
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test(void)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
int fd, i;
|
||||||
|
char path[MAXPATHLEN + 1];
|
||||||
|
|
||||||
|
atomic_add_int(&share[SYNC], 1);
|
||||||
|
while (share[SYNC] != (volatile u_int)parallel)
|
||||||
|
;
|
||||||
|
|
||||||
|
pid =getpid();
|
||||||
|
for (i = 0; i < files; i++) {
|
||||||
|
snprintf(path, sizeof(path), "%s/f%06d.%06d", dir, pid, i);
|
||||||
|
if ((fd = open(path, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE)) ==
|
||||||
|
-1)
|
||||||
|
err(1, "open(%s)", path);
|
||||||
|
if (write(fd, buf, bufsize) != bufsize)
|
||||||
|
err(1, "write()");
|
||||||
|
if (close(fd) == -1)
|
||||||
|
err(1, "close(%d)", fd);
|
||||||
|
if (unlink(path) == -1)
|
||||||
|
err(1, "unlink(%s)", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct timeval t1, t2, diff;
|
||||||
|
struct tm *tp;
|
||||||
|
size_t len;
|
||||||
|
time_t start, now;
|
||||||
|
int ch, e, i, *pids, status;
|
||||||
|
char help[80];
|
||||||
|
|
||||||
|
bufsize = 8 * 1024;
|
||||||
|
dir = "/tmp";
|
||||||
|
files = 5000;
|
||||||
|
parallel = 4;
|
||||||
|
runtime = 1 * 60 * 60 * 24;
|
||||||
|
|
||||||
|
while ((ch = getopt(argc, argv, "b:d:f:r:")) != -1)
|
||||||
|
switch(ch) {
|
||||||
|
case 'b': /* bufsize */
|
||||||
|
if (sscanf(optarg, "%d", &bufsize) != 1)
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
case 'd': /* dir */
|
||||||
|
dir = optarg;
|
||||||
|
break;
|
||||||
|
case 'f': /* files */
|
||||||
|
if (sscanf(optarg, "%d", &files) != 1)
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
case 'p': /* parallel */
|
||||||
|
if (sscanf(optarg, "%d", ¶llel) != 1)
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
case 'r': /* runtime */
|
||||||
|
if (sscanf(optarg, "%d", &runtime) != 1)
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
argc -= optind;
|
||||||
|
argv += optind;
|
||||||
|
|
||||||
|
printf("# Options used: dir=%s, bufsize=%d, files=%d, parallel=%d, "
|
||||||
|
"runtime=%d\n",
|
||||||
|
dir, bufsize, files, parallel, runtime);
|
||||||
|
if ((buf = malloc(bufsize)) == NULL)
|
||||||
|
err(1, "malloc(%d)", bufsize);
|
||||||
|
if ((pids = malloc(sizeof(pid_t) * parallel)) == NULL)
|
||||||
|
err(1, "malloc(%d)", (int)(sizeof(pid_t) * parallel));
|
||||||
|
e = 0;
|
||||||
|
len = PAGE_SIZE;
|
||||||
|
if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE,
|
||||||
|
MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED)
|
||||||
|
err(1, "mmap");
|
||||||
|
|
||||||
|
start = time(NULL);
|
||||||
|
while ((time(NULL) - start) < runtime && e == 0) {
|
||||||
|
share[SYNC] = 0;
|
||||||
|
gettimeofday(&t1, NULL);
|
||||||
|
for (i = 0; i < parallel; i++) {
|
||||||
|
if ((pids[i] = fork()) == 0)
|
||||||
|
test();
|
||||||
|
}
|
||||||
|
for (i = 0; i < parallel; i++) {
|
||||||
|
waitpid(pids[i], &status, 0);
|
||||||
|
e += status == 0 ? 0 : 1;
|
||||||
|
}
|
||||||
|
gettimeofday(&t2, NULL);
|
||||||
|
timersub(&t2, &t1, &diff);
|
||||||
|
now = time(NULL);
|
||||||
|
tp = localtime(&now);
|
||||||
|
strftime(help, sizeof(help), "%Y%m%d%H%M%S", tp);
|
||||||
|
printf("%s %ld.%06ld\n", help, (long)diff.tv_sec,
|
||||||
|
diff.tv_usec);
|
||||||
|
fflush(stdout);
|
||||||
|
if (runtime > DELAY)
|
||||||
|
sleep(DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (e);
|
||||||
|
}
|
331
tools/test/stress2/misc/callout_reset_on.sh
Executable file
331
tools/test/stress2/misc/callout_reset_on.sh
Executable file
@ -0,0 +1,331 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2012 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Scenario based on pr. kern/166340
|
||||||
|
# Process under FreeBSD 9.0 hangs in uninterruptable sleep with apparently
|
||||||
|
# no syscall (empty wchan).
|
||||||
|
|
||||||
|
# http://people.freebsd.org/~pho/stress/log/callout_reset_on.txt
|
||||||
|
# Fixed in r243901.
|
||||||
|
|
||||||
|
# panic: Bad link elm 0xfffff80012ba8ec8 prev->next != elm
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/rrs005.txt
|
||||||
|
# Fixed in r278623.
|
||||||
|
|
||||||
|
# "ritwait DE 0- 0:00.01 crlogger: writer" seen.
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik917.txt
|
||||||
|
# Fixed in r302981
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
rm -f /tmp/crwriter /tmp/crlogger || exit 1
|
||||||
|
|
||||||
|
cat > /tmp/crwriter.c <<EOF
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
char *txt[] = {
|
||||||
|
"0 This is a line of text: abcdefghijklmnopqrstuvwxyz",
|
||||||
|
"1 Another line of text: ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||||
|
"2 A different line of text",
|
||||||
|
"3 A very, very different text",
|
||||||
|
"4 A much longer line with a lot of characters in the line",
|
||||||
|
"5 Now this is a quite long line of text, with both upper and lower case letters, and one digit!"
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
int i, j, n;
|
||||||
|
char help[256];
|
||||||
|
|
||||||
|
for (i = 0; i < 100000; i++) {
|
||||||
|
j = arc4random() % 6;
|
||||||
|
n = arc4random() % strlen(txt[j]);
|
||||||
|
strncpy(help, txt[j], n);
|
||||||
|
help[n] = 0;
|
||||||
|
printf("%s\n", txt[j]);
|
||||||
|
if ((arc4random() % 1000) == 1)
|
||||||
|
usleep(100000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
mycc -o /tmp/crwriter -Wall -Wextra -O2 -g /tmp/crwriter.c
|
||||||
|
rm -f /tmp/crwriter.c
|
||||||
|
|
||||||
|
cat > /tmp/crlogger.c <<EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define BARRIER_CREATE 1
|
||||||
|
#define BARRIER_WAIT 2
|
||||||
|
#define BARRIER_DELETE 3
|
||||||
|
|
||||||
|
void
|
||||||
|
barrier(int mode)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
char path[128];
|
||||||
|
|
||||||
|
if (mode == BARRIER_CREATE) {
|
||||||
|
snprintf(path, sizeof(path), "barrier.%d", getpid());
|
||||||
|
if ((fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0)
|
||||||
|
err(1, "%s", path);
|
||||||
|
} else if (mode == BARRIER_WAIT) {
|
||||||
|
snprintf(path, sizeof(path), "barrier.%d", getppid());
|
||||||
|
for(;;) {
|
||||||
|
if (access(path, R_OK) == -1)
|
||||||
|
break;
|
||||||
|
usleep(10000);
|
||||||
|
}
|
||||||
|
} else if (mode == BARRIER_DELETE) {
|
||||||
|
snprintf(path, sizeof(path), "barrier.%d", getpid());
|
||||||
|
if (unlink(path) == -1)
|
||||||
|
err(1, "unlink(%s)", path);
|
||||||
|
} else
|
||||||
|
errx(1, "Bad barrier mode: %d", mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
pid_t pid;
|
||||||
|
int bufsize;
|
||||||
|
int port;
|
||||||
|
int alarm_exit;
|
||||||
|
|
||||||
|
void
|
||||||
|
killer(void)
|
||||||
|
{
|
||||||
|
setproctitle("killer");
|
||||||
|
alarm(120);
|
||||||
|
barrier(BARRIER_WAIT);
|
||||||
|
for (;;) {
|
||||||
|
if (pid == 0)
|
||||||
|
break;
|
||||||
|
if (kill(pid, SIGUSR1) == -1)
|
||||||
|
break;
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
handler(int s __unused)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ahandler(int s __unused)
|
||||||
|
{
|
||||||
|
if (alarm_exit)
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read form socket, discard */
|
||||||
|
static void
|
||||||
|
reader(void) {
|
||||||
|
int tcpsock, msgsock;
|
||||||
|
int on;
|
||||||
|
socklen_t len;
|
||||||
|
struct sockaddr_in inetaddr, inetpeer;
|
||||||
|
int n, *buf;
|
||||||
|
|
||||||
|
setproctitle("reader - init");
|
||||||
|
on = 1;
|
||||||
|
if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||||
|
err(1, "socket(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
if (setsockopt(tcpsock,
|
||||||
|
SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
|
||||||
|
err(1, "setsockopt(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
inetaddr.sin_family = AF_INET;
|
||||||
|
inetaddr.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
inetaddr.sin_port = htons(port);
|
||||||
|
inetaddr.sin_len = sizeof(inetaddr);
|
||||||
|
|
||||||
|
signal(SIGUSR1, handler);
|
||||||
|
alarm(60);
|
||||||
|
if (bind(tcpsock,
|
||||||
|
(struct sockaddr *)&inetaddr, sizeof (inetaddr)) < 0)
|
||||||
|
err(1, "bind(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
if (listen(tcpsock, 5) < 0)
|
||||||
|
err(1, "listen(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
len = sizeof(inetpeer);
|
||||||
|
if ((msgsock = accept(tcpsock,
|
||||||
|
(struct sockaddr *)&inetpeer, &len)) < 0)
|
||||||
|
err(1, "accept(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
if ((buf = malloc(bufsize)) == NULL)
|
||||||
|
err(1, "malloc(%d), %s:%d", bufsize, __FILE__, __LINE__);
|
||||||
|
setproctitle("reader");
|
||||||
|
alarm(0);
|
||||||
|
signal(SIGALRM, ahandler);
|
||||||
|
for (;;) {
|
||||||
|
ualarm(5000, 0);
|
||||||
|
if ((n = recvfrom(msgsock, buf, 4, 0, NULL, NULL)) < 0) {
|
||||||
|
if (errno == EAGAIN)
|
||||||
|
continue;
|
||||||
|
err(1, "read(), %s:%d", __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
if (n == 0)
|
||||||
|
break;
|
||||||
|
if (write(msgsock, "OK", 3) != 3)
|
||||||
|
err(1, "write ack. %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
}
|
||||||
|
close(msgsock);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read from stdin, write to socket */
|
||||||
|
static void
|
||||||
|
writer(void) {
|
||||||
|
int tcpsock, on;
|
||||||
|
struct sockaddr_in inetaddr;
|
||||||
|
struct hostent *hostent;
|
||||||
|
int i, r;
|
||||||
|
char line[1024], ack[80];;
|
||||||
|
pid_t ppid;
|
||||||
|
|
||||||
|
setproctitle("writer - init");
|
||||||
|
ppid = getppid();
|
||||||
|
signal(SIGUSR1, handler);
|
||||||
|
alarm(60);
|
||||||
|
on = 1;
|
||||||
|
for (i = 1; i < 5; i++) {
|
||||||
|
if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||||
|
err(1, "socket(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
if (setsockopt(tcpsock,
|
||||||
|
SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
|
||||||
|
err(1, "setsockopt(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
hostent = gethostbyname ("localhost");
|
||||||
|
bzero(&inetaddr, sizeof(inetaddr));
|
||||||
|
memcpy (&inetaddr.sin_addr.s_addr, hostent->h_addr,
|
||||||
|
sizeof (struct in_addr));
|
||||||
|
|
||||||
|
inetaddr.sin_family = AF_INET;
|
||||||
|
inetaddr.sin_port = htons(port);
|
||||||
|
inetaddr.sin_len = sizeof(inetaddr);
|
||||||
|
|
||||||
|
r = connect(tcpsock, (struct sockaddr *) &inetaddr,
|
||||||
|
sizeof(inetaddr));
|
||||||
|
if (r == 0)
|
||||||
|
break;
|
||||||
|
sleep(1);
|
||||||
|
close(tcpsock);
|
||||||
|
}
|
||||||
|
if (r < 0)
|
||||||
|
err(1, "connect(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
setproctitle("writer");
|
||||||
|
barrier(BARRIER_DELETE);
|
||||||
|
alarm(0);
|
||||||
|
while (fgets(line, sizeof(line), stdin) != NULL) {
|
||||||
|
alarm(10);
|
||||||
|
alarm_exit = 1;
|
||||||
|
if (write(tcpsock, line, strlen(line)) < 0)
|
||||||
|
err(1, "socket write(). %s:%d", __FILE__, __LINE__);
|
||||||
|
alarm_exit = 0;
|
||||||
|
ualarm(5000, 0);
|
||||||
|
if (recvfrom(tcpsock, ack, 4, 0, NULL, NULL) < 0) {
|
||||||
|
if (errno == EAGAIN)
|
||||||
|
continue;
|
||||||
|
err(1, "read(), %s:%d", __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sleep(30);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
pid_t kpid;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
errx(1, "Usage: %s <port number>\n", argv[0]);
|
||||||
|
port = atoi(argv[1]);
|
||||||
|
bufsize = 128;
|
||||||
|
|
||||||
|
barrier(BARRIER_CREATE);
|
||||||
|
signal(SIGCHLD, SIG_IGN);
|
||||||
|
if ((pid = fork()) == 0)
|
||||||
|
reader();
|
||||||
|
|
||||||
|
if ((kpid = fork()) == 0)
|
||||||
|
killer();
|
||||||
|
|
||||||
|
writer();
|
||||||
|
sleep(1);
|
||||||
|
kill(pid, SIGINT);
|
||||||
|
kill(kpid, SIGINT);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
mycc -o /tmp/crlogger -Wall -Wextra -O2 -g /tmp/crlogger.c
|
||||||
|
rm -f /tmp/crlogger.c
|
||||||
|
|
||||||
|
N=200
|
||||||
|
cd /tmp
|
||||||
|
start=`date '+%s'`
|
||||||
|
for i in `jot 40`; do
|
||||||
|
for j in `jot $N`; do
|
||||||
|
/tmp/crwriter | /tmp/crlogger 1236$j 2>/dev/null &
|
||||||
|
done
|
||||||
|
|
||||||
|
for j in `jot $N`; do
|
||||||
|
wait
|
||||||
|
done
|
||||||
|
[ $((`date '+%s'` - start)) -gt 1200 ] && break
|
||||||
|
done
|
||||||
|
rm -f /tmp/crwriter /tmp/crlogger ./barrier.*
|
||||||
|
exit 0
|
303
tools/test/stress2/misc/callout_reset_on2.sh
Executable file
303
tools/test/stress2/misc/callout_reset_on2.sh
Executable file
@ -0,0 +1,303 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2012 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Copy of callout_reset_on.sh. Waiting to see if this catches anything.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
rm -f /tmp/crwriter2 /tmp/crlogger2 || exit 1
|
||||||
|
|
||||||
|
cat > /tmp/crwriter2.c <<EOF
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
char *txt[] = {
|
||||||
|
"0 This is a line of text: abcdefghijklmnopqrstuvwxyz",
|
||||||
|
"1 Another line of text: ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||||
|
"2 A different line of text",
|
||||||
|
"3 A very, very different text",
|
||||||
|
"4 A much longer line with a lot of characters in the line",
|
||||||
|
"5 Now this is a quite long line of text, with both upper and lower case letters, and one digit!"
|
||||||
|
};
|
||||||
|
|
||||||
|
#define RUNTIME (10 * 60)
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
time_t start;
|
||||||
|
int j, n;
|
||||||
|
char help[256];
|
||||||
|
|
||||||
|
start = time(NULL);
|
||||||
|
while (time(NULL) - start < RUNTIME) {
|
||||||
|
j = arc4random() % 6;
|
||||||
|
n = arc4random() % strlen(txt[j]);
|
||||||
|
strncpy(help, txt[j], n);
|
||||||
|
help[n] = 0;
|
||||||
|
printf("%s\n", txt[j]);
|
||||||
|
if ((arc4random() % 1000) == 1)
|
||||||
|
usleep(100000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
mycc -o /tmp/crwriter2 -Wall -Wextra -O2 -g /tmp/crwriter2.c
|
||||||
|
rm -f /tmp/crwriter2.c
|
||||||
|
|
||||||
|
cat > /tmp/crlogger2.c <<EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <machine/atomic.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
volatile u_int *share;
|
||||||
|
|
||||||
|
#define SYNC 0
|
||||||
|
|
||||||
|
pid_t pid;
|
||||||
|
int bufsize;
|
||||||
|
int port;
|
||||||
|
int alarm_exit;
|
||||||
|
|
||||||
|
void
|
||||||
|
killer(void)
|
||||||
|
{
|
||||||
|
setproctitle("killer");
|
||||||
|
while (share[SYNC] == 0)
|
||||||
|
;
|
||||||
|
alarm(120);
|
||||||
|
for (;;) {
|
||||||
|
if (pid == 0)
|
||||||
|
break;
|
||||||
|
if (kill(pid, SIGUSR1) == -1)
|
||||||
|
break;
|
||||||
|
usleep(arc4random() % 2000 + 10);
|
||||||
|
}
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
handler(int s __unused)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ahandler(int s __unused)
|
||||||
|
{
|
||||||
|
if (alarm_exit)
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read form socket, discard */
|
||||||
|
static void
|
||||||
|
reader(void) {
|
||||||
|
int tcpsock, msgsock;
|
||||||
|
int on;
|
||||||
|
socklen_t len;
|
||||||
|
struct sockaddr_in inetaddr, inetpeer;
|
||||||
|
int n, *buf;
|
||||||
|
|
||||||
|
setproctitle("reader - init");
|
||||||
|
on = 1;
|
||||||
|
if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||||
|
err(1, "socket(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
if (setsockopt(tcpsock,
|
||||||
|
SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
|
||||||
|
err(1, "setsockopt(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
inetaddr.sin_family = AF_INET;
|
||||||
|
inetaddr.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
inetaddr.sin_port = htons(port);
|
||||||
|
inetaddr.sin_len = sizeof(inetaddr);
|
||||||
|
|
||||||
|
signal(SIGUSR1, handler);
|
||||||
|
alarm(60);
|
||||||
|
if (bind(tcpsock,
|
||||||
|
(struct sockaddr *)&inetaddr, sizeof (inetaddr)) < 0)
|
||||||
|
err(1, "bind(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
if (listen(tcpsock, 5) < 0)
|
||||||
|
err(1, "listen(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
len = sizeof(inetpeer);
|
||||||
|
if ((msgsock = accept(tcpsock,
|
||||||
|
(struct sockaddr *)&inetpeer, &len)) < 0)
|
||||||
|
err(1, "accept(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
if ((buf = malloc(bufsize)) == NULL)
|
||||||
|
err(1, "malloc(%d), %s:%d", bufsize, __FILE__, __LINE__);
|
||||||
|
setproctitle("reader");
|
||||||
|
alarm(0);
|
||||||
|
signal(SIGALRM, ahandler);
|
||||||
|
for (;;) {
|
||||||
|
ualarm(arc4random() % 5000 + 100, 0);
|
||||||
|
if ((n = recvfrom(msgsock, buf, bufsize, 0, NULL, NULL)) < 0) {
|
||||||
|
if (errno == EAGAIN)
|
||||||
|
continue;
|
||||||
|
err(1, "read(), %s:%d", __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
if (n == 0)
|
||||||
|
break;
|
||||||
|
if (write(msgsock, "OK", 3) != 3)
|
||||||
|
err(1, "write ack. %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
}
|
||||||
|
close(msgsock);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read from stdin, write to socket */
|
||||||
|
static void
|
||||||
|
writer(void) {
|
||||||
|
int tcpsock, on;
|
||||||
|
struct sockaddr_in inetaddr;
|
||||||
|
struct hostent *hostent;
|
||||||
|
int i, r;
|
||||||
|
char line[1024], ack[80];;
|
||||||
|
pid_t ppid;
|
||||||
|
|
||||||
|
setproctitle("writer - init");
|
||||||
|
share[SYNC] = 1;
|
||||||
|
ppid = getppid();
|
||||||
|
signal(SIGUSR1, handler);
|
||||||
|
signal(SIGALRM, ahandler);
|
||||||
|
alarm(60);
|
||||||
|
on = 1;
|
||||||
|
for (i = 1; i < 5; i++) {
|
||||||
|
if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||||
|
err(1, "socket(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
if (setsockopt(tcpsock,
|
||||||
|
SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
|
||||||
|
err(1, "setsockopt(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
hostent = gethostbyname ("localhost");
|
||||||
|
bzero(&inetaddr, sizeof(inetaddr));
|
||||||
|
memcpy (&inetaddr.sin_addr.s_addr, hostent->h_addr,
|
||||||
|
sizeof (struct in_addr));
|
||||||
|
|
||||||
|
inetaddr.sin_family = AF_INET;
|
||||||
|
inetaddr.sin_port = htons(port);
|
||||||
|
inetaddr.sin_len = sizeof(inetaddr);
|
||||||
|
|
||||||
|
r = connect(tcpsock, (struct sockaddr *) &inetaddr,
|
||||||
|
sizeof(inetaddr));
|
||||||
|
if (r == 0)
|
||||||
|
break;
|
||||||
|
sleep(1);
|
||||||
|
close(tcpsock);
|
||||||
|
}
|
||||||
|
if (r < 0)
|
||||||
|
err(1, "connect(), %s:%d", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
setproctitle("writer");
|
||||||
|
alarm(0);
|
||||||
|
while (fgets(line, sizeof(line), stdin) != NULL) {
|
||||||
|
alarm(10);
|
||||||
|
alarm_exit = 1;
|
||||||
|
if (write(tcpsock, line, strlen(line)) < 0)
|
||||||
|
err(1, "socket write(). %s:%d", __FILE__, __LINE__);
|
||||||
|
alarm_exit = 0;
|
||||||
|
ualarm(arc4random() % 5000 + 1000, 0);
|
||||||
|
if (recvfrom(tcpsock, ack, 4, 0, NULL, NULL) < 0) {
|
||||||
|
if (errno == EAGAIN)
|
||||||
|
continue;
|
||||||
|
err(1, "read(), %s:%d", __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sleep(30);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
pid_t kpid;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "Usage: %s <port number>\n", argv[0]);
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
port = atoi(argv[1]);
|
||||||
|
bufsize = 128;
|
||||||
|
|
||||||
|
len = PAGE_SIZE;
|
||||||
|
if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE,
|
||||||
|
MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED)
|
||||||
|
err(1, "mmap");
|
||||||
|
|
||||||
|
signal(SIGCHLD, SIG_IGN);
|
||||||
|
if ((pid = fork()) == 0)
|
||||||
|
reader();
|
||||||
|
|
||||||
|
if ((kpid = fork()) == 0)
|
||||||
|
killer();
|
||||||
|
|
||||||
|
writer();
|
||||||
|
sleep(1);
|
||||||
|
kill(pid, SIGINT);
|
||||||
|
kill(kpid, SIGINT);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
mycc -o /tmp/crlogger2 -Wall -Wextra -O2 -g /tmp/crlogger2.c
|
||||||
|
rm -f /tmp/crlogger2.c
|
||||||
|
|
||||||
|
N=50
|
||||||
|
cd /tmp
|
||||||
|
for j in `jot $N`; do
|
||||||
|
/tmp/crwriter2 | /tmp/crlogger2 1236$j &
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
rm -f /tmp/crwriter2 /tmp/crlogger2
|
||||||
|
exit 0
|
77
tools/test/stress2/misc/chain.sh
Executable file
77
tools/test/stress2/misc/chain.sh
Executable file
@ -0,0 +1,77 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2021 Peter Jeremy <peterj@FreeBSD.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
# Unkillable process in "vm map (user)" seen.
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik1070.txt
|
||||||
|
# Fixed by: r327468
|
||||||
|
|
||||||
|
# OOM killing: https://people.freebsd.org/~pho/stress/log/chain.txt
|
||||||
|
|
||||||
|
if [ ! -f /usr/local/include/libmill.h -o \
|
||||||
|
! -x /usr/local/lib/libmill.so ]; then
|
||||||
|
echo "ports/devel/libmill needed."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
cat > /tmp/chain.c <<EOF
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <libmill.h>
|
||||||
|
|
||||||
|
coroutine void f(chan left, chan right) {
|
||||||
|
chs(left, int, 1 + chr(right, int));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc __unused, char **argv)
|
||||||
|
{
|
||||||
|
int i, n = argv[1] ? atoi(argv[1]) : 10000;
|
||||||
|
chan leftmost = chmake(int, 0);
|
||||||
|
chan left = NULL;
|
||||||
|
chan right = leftmost;
|
||||||
|
|
||||||
|
alarm(600);
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
left = right;
|
||||||
|
right = chmake(int, 0);
|
||||||
|
go(f(left, right));
|
||||||
|
}
|
||||||
|
chs(right, int, 0);
|
||||||
|
i = chr(leftmost, int);
|
||||||
|
printf("result = %d\n", i);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mycc -o /tmp/chain -I /usr/local/include -L /usr/local/lib -Wall -Wextra \
|
||||||
|
-O2 -g /tmp/chain.c -lmill || exit 1
|
||||||
|
limits -c 0 /tmp/chain 1000000
|
||||||
|
rm -f /tmp/chain /tmp/chain.c
|
||||||
|
exit 0
|
211
tools/test/stress2/misc/churn.sh
Executable file
211
tools/test/stress2/misc/churn.sh
Executable file
@ -0,0 +1,211 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# VM test. No problems seen.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
dir=/tmp
|
||||||
|
odir=`pwd`
|
||||||
|
cd $dir
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > $dir/churn.c
|
||||||
|
mycc -o churn -Wall -Wextra -O0 -g churn.c -lpthread || exit 1
|
||||||
|
rm -f churn.c
|
||||||
|
|
||||||
|
/tmp/churn `sysctl -n hw.ncpu` `sysctl -n hw.usermem`
|
||||||
|
s=$?
|
||||||
|
|
||||||
|
rm -rf /tmp/churn
|
||||||
|
exit $?
|
||||||
|
|
||||||
|
EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <machine/atomic.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <pthread_np.h>
|
||||||
|
#define __NP__
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define ARRAYSIZE (4 * 1024)
|
||||||
|
#define RUNTIME (10 * 60)
|
||||||
|
#define SYNC 0
|
||||||
|
|
||||||
|
volatile u_int *share;
|
||||||
|
long mem, parallel;
|
||||||
|
int done;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
void *addr;
|
||||||
|
long pages;
|
||||||
|
volatile u_int busy;
|
||||||
|
} v[ARRAYSIZE];
|
||||||
|
|
||||||
|
void *
|
||||||
|
test2(void *arg __unused)
|
||||||
|
{
|
||||||
|
long i, j, n;
|
||||||
|
volatile char *cp;
|
||||||
|
|
||||||
|
#ifdef __NP__
|
||||||
|
pthread_set_name_np(pthread_self(), __func__);
|
||||||
|
#endif
|
||||||
|
while (done == 0) {
|
||||||
|
n = 0;
|
||||||
|
for (i = 0; i < ARRAYSIZE; i++) {
|
||||||
|
if (v[i].pages == 0)
|
||||||
|
continue;
|
||||||
|
atomic_add_int(&v[i].busy, 1);
|
||||||
|
if (v[i].busy != 1) {
|
||||||
|
atomic_add_int(&v[i].busy, -1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
cp = v[i].addr;
|
||||||
|
for (j = 0; j < v[i].pages; j++)
|
||||||
|
cp[j * PAGE_SIZE] = 1;
|
||||||
|
atomic_add_int(&v[i].busy, -1);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
if (n == 0) {
|
||||||
|
usleep(10000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test(void)
|
||||||
|
{
|
||||||
|
pthread_t tp[2];
|
||||||
|
size_t len;
|
||||||
|
time_t start;
|
||||||
|
long i, j, k, size;
|
||||||
|
int r;
|
||||||
|
volatile char *cp;
|
||||||
|
|
||||||
|
atomic_add_int(&share[SYNC], 1);
|
||||||
|
while (share[SYNC] != (volatile u_int)parallel)
|
||||||
|
;
|
||||||
|
|
||||||
|
if ((r = pthread_create(&tp[0], NULL, test2, NULL)) != 0)
|
||||||
|
errc(1, r, "pthread_create");
|
||||||
|
if ((r = pthread_create(&tp[1], NULL, test2, NULL)) != 0)
|
||||||
|
errc(1, r, "pthread_create");
|
||||||
|
size = 0;
|
||||||
|
start = time(NULL);
|
||||||
|
while (time(NULL) - start < RUNTIME) {
|
||||||
|
for (k = 0; k < ARRAYSIZE; k++) {
|
||||||
|
i = arc4random() % ARRAYSIZE;
|
||||||
|
if (v[i].pages != 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (v[i].addr != NULL) {
|
||||||
|
atomic_add_int(&v[i].busy, 1);
|
||||||
|
if (v[i].busy != 1) {
|
||||||
|
atomic_add_int(&v[i].busy, -1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (munmap(v[i].addr, v[i].pages * PAGE_SIZE) == -1)
|
||||||
|
err(1, "munmap(%p, %ld)", v[i].addr, v[i].pages);
|
||||||
|
v[i].addr = NULL;
|
||||||
|
size -= v[i].pages;
|
||||||
|
v[i].pages = 0;
|
||||||
|
atomic_add_int(&v[i].busy, -1);
|
||||||
|
}
|
||||||
|
if (size < mem) {
|
||||||
|
j = round_page((arc4random() % (mem / 10)) + 1);
|
||||||
|
len = j * PAGE_SIZE;
|
||||||
|
if ((v[i].addr = mmap(NULL, len, PROT_READ | PROT_WRITE,
|
||||||
|
MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) {
|
||||||
|
v[i].addr = NULL;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
atomic_add_int(&v[i].busy, 1);
|
||||||
|
v[i].pages = j;
|
||||||
|
size += j;
|
||||||
|
assert(size > 0);
|
||||||
|
cp = v[i].addr;
|
||||||
|
for (k = 0; k < j * PAGE_SIZE; k += PAGE_SIZE)
|
||||||
|
cp[k] = 1;
|
||||||
|
atomic_add_int(&v[i].busy, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
done = 1;
|
||||||
|
pthread_join(tp[0], NULL);
|
||||||
|
pthread_join(tp[1], NULL);
|
||||||
|
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
int e, i, *pids, status;
|
||||||
|
|
||||||
|
if (argc != 3) {
|
||||||
|
fprintf(stderr, "Usage: %s <memory>\n", argv[0]);
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
parallel = atol(argv[1]);
|
||||||
|
mem = atol(argv[2]) / PAGE_SIZE;
|
||||||
|
mem = mem / parallel;
|
||||||
|
|
||||||
|
e = 0;
|
||||||
|
len = PAGE_SIZE;
|
||||||
|
if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE,
|
||||||
|
MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED)
|
||||||
|
err(1, "mmap");
|
||||||
|
|
||||||
|
pids = malloc(sizeof(void *) * parallel);
|
||||||
|
for (i = 0; i < parallel; i++) {
|
||||||
|
if ((pids[i] = fork()) == 0)
|
||||||
|
test();
|
||||||
|
}
|
||||||
|
for (i = 0; i < parallel; i++) {
|
||||||
|
waitpid(pids[i], &status, 0);
|
||||||
|
e += status == 0 ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (e);
|
||||||
|
}
|
105
tools/test/stress2/misc/cleanup.sh
Executable file
105
tools/test/stress2/misc/cleanup.sh
Executable file
@ -0,0 +1,105 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008-2013 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
bname=`basename $mntpoint`
|
||||||
|
mounts=`mount | awk "/$bname/{print \\$3}"`
|
||||||
|
nmounts=`sysctl -n hw.ncpu` # Max number of mounts in use
|
||||||
|
[ $nmounts -lt 31 ] && nmounts=31 # Arbitrary value
|
||||||
|
s=0
|
||||||
|
# Unmount the test mount points: /mnt, /mnt10 .. mnt31
|
||||||
|
for i in $mounts; do
|
||||||
|
u=`echo $i | sed "s/\/$bname//"`
|
||||||
|
[ -z "$u" ] && u=$mdstart
|
||||||
|
echo "$u" | grep -Eq '^[0-9]+$' || continue
|
||||||
|
# [ $u -lt $mdstart -o $u -gt $((mdstart + nmounts)) ] && continue
|
||||||
|
while mount | grep -q "on $i "; do
|
||||||
|
r=`fstat -mf $i 2>/dev/null | awk '$3 ~ /^[0-9]+$/ {print $3}'`
|
||||||
|
if [ -n "$r" ]; then
|
||||||
|
echo "cleanup.sh: kill $r"
|
||||||
|
echo $r | xargs kill; sleep 1
|
||||||
|
fi
|
||||||
|
echo "cleanup.sh: umount -f $i"
|
||||||
|
umount -f $i > /dev/null 2>&1 || s=1
|
||||||
|
[ -z "$r" ] && break
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
# Delete the test mount points /mnt10 .. /mnt31
|
||||||
|
for i in `ls -d $mntpoint* 2>/dev/null | grep -Ev '^$mntpoint$'`; do
|
||||||
|
u=`echo $i | sed "s/\/$bname//"`
|
||||||
|
echo "$u" | grep -Eq '^[0-9]+$' || continue
|
||||||
|
# [ $u -lt $mdstart -o $u -gt $((mdstart + nmounts)) ] && continue
|
||||||
|
if ! mount | grep -q "on $i "; then
|
||||||
|
[ -d $i ] && find $i -delete \
|
||||||
|
2>/dev/null
|
||||||
|
rm -rf $i > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Delete the memory disks
|
||||||
|
units=`mdconfig -l | sed 's/md//g'`
|
||||||
|
for u in $units; do
|
||||||
|
if [ $u -ge $mdstart -a $u -lt $((mdstart + nmounts)) ]; then
|
||||||
|
echo "cleanup.sh: mdconfig -d -u $u"
|
||||||
|
mdconfig -d -u $u || s=1
|
||||||
|
[ -c /dev/md$u ] && sleep .1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
[ -d "$mntpoint" ] && (cd $mntpoint && find . -delete)
|
||||||
|
rm -f /tmp/.snap/stress2* /var/.snap/stress2*
|
||||||
|
rm -rf /tmp/stressX.control $RUNDIR
|
||||||
|
[ -d `dirname "$diskimage"` ] || mkdir -p `dirname "$diskimage"`
|
||||||
|
mkdir -p $RUNDIR
|
||||||
|
chmod 0777 $RUNDIR
|
||||||
|
|
||||||
|
# Delete $testuser's ipcs
|
||||||
|
ipcs | awk "\$5 ~/$testuser/ && \$6 ~/$testuser/ {print \"-\" \$1,\$2}" | \
|
||||||
|
xargs -t ipcrm
|
||||||
|
|
||||||
|
# Modules
|
||||||
|
#mlist=/tmp/stress2.d/mlist
|
||||||
|
#find $mlist -mtime +1 -delete 2>/dev/null
|
||||||
|
#[ -f $mlist ] && touch $mlist ||
|
||||||
|
# { kldstat | kldstat | awk '/\.ko$/ {print $NF}' > $mlist; \
|
||||||
|
# echo "Updating $mlist"; }
|
||||||
|
#for m in `kldstat | awk '/\.ko$/ {print $NF}'`; do
|
||||||
|
# grep -q $m $mlist && continue
|
||||||
|
# echo "pty.ko mqueuefs.ko ioat.ko ums.ko" | grep -q $m && continue
|
||||||
|
# echo "cleanup.sh: kldunload $m"
|
||||||
|
# kldunload $m
|
||||||
|
#done
|
||||||
|
# unloading an active dtrace causes a panic
|
||||||
|
#kldstat | grep -q dtraceall.ko && kldunload dtraceall.ko
|
||||||
|
kldstat | grep -q ext2fs.ko && kldunload ext2fs.ko
|
||||||
|
[ $s -ne 0 ] && echo "cleanup.sh: FAIL $s"
|
||||||
|
exit $s
|
269
tools/test/stress2/misc/cluster.sh
Executable file
269
tools/test/stress2/misc/cluster.sh
Executable file
@ -0,0 +1,269 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Open four (sparse) files for random read and write.
|
||||||
|
|
||||||
|
# "panic: softdep_deallocate_dependencies: dangling deps" seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kirk075.txt
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
dir=`dirname $diskimage`
|
||||||
|
free=`df -k $dir | tail -1 | awk '{print $4}'`
|
||||||
|
[ $((free / 1024 / 1024)) -lt 9 ] && echo "Not enough disk space." && exit
|
||||||
|
|
||||||
|
odir=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > cluster.c
|
||||||
|
rm -f /tmp/cluster
|
||||||
|
mycc -o cluster -Wall -Wextra -g -O2 cluster.c || exit 1
|
||||||
|
rm -f cluster.c
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
su $testuser -c "/tmp/cluster $dir abc"
|
||||||
|
|
||||||
|
rm -f /tmp/cluster
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define BSIZE (8 * 1024 * 1024)
|
||||||
|
#define MX (8LL * 1024 * 1024 * 1024)
|
||||||
|
#define PARALLEL 4
|
||||||
|
#define RUNTIME 600
|
||||||
|
#define WRLOOPS 1024
|
||||||
|
|
||||||
|
int rfd;
|
||||||
|
char *buf;
|
||||||
|
char *path;
|
||||||
|
char *uid;
|
||||||
|
char file[MAXPATHLEN + 1];
|
||||||
|
|
||||||
|
unsigned long long
|
||||||
|
rnd(void) {
|
||||||
|
unsigned long long v;
|
||||||
|
|
||||||
|
read(rfd, &v, sizeof(v));
|
||||||
|
v = v % MX;
|
||||||
|
return (v);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wr(int idx)
|
||||||
|
{
|
||||||
|
off_t offset;
|
||||||
|
size_t ln;
|
||||||
|
int fd, i, n;
|
||||||
|
|
||||||
|
snprintf(file, sizeof(file), "%s/f.%s.%06d", path, uid, idx);
|
||||||
|
setproctitle(__func__);
|
||||||
|
if ((fd = open(file, O_RDWR | O_CREAT, 0644)) == -1)
|
||||||
|
err(1, "open(%s)", file);
|
||||||
|
n = arc4random() % WRLOOPS + 1;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
ln = rnd() % BSIZE + 1;
|
||||||
|
offset = rnd() % (MX - ln);
|
||||||
|
if (lseek(fd, offset, SEEK_SET) == -1)
|
||||||
|
err(1, "lseek in rw 1");
|
||||||
|
while (lockf(fd, F_LOCK, ln) == -1) {
|
||||||
|
if (errno != EDEADLK)
|
||||||
|
err(1, "lockf(%s, F_LOCK)", file);
|
||||||
|
}
|
||||||
|
if (write(fd, buf, ln) < 0)
|
||||||
|
err(1, "write");
|
||||||
|
if (lseek(fd, offset, SEEK_SET) == -1)
|
||||||
|
err(1, "lseek in rw 2");
|
||||||
|
if (lockf(fd, F_ULOCK, ln) == -1)
|
||||||
|
err(1, "lockf(%s, F_ULOCK)", file);
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rd(int idx)
|
||||||
|
{
|
||||||
|
off_t offset;
|
||||||
|
size_t ln;
|
||||||
|
int fd, i, n;
|
||||||
|
|
||||||
|
snprintf(file, sizeof(file), "%s/f.%s.%06d", path, uid, idx);
|
||||||
|
setproctitle(__func__);
|
||||||
|
for (i = 0; i < 100; i++) {
|
||||||
|
if (access(file, R_OK) == 0)
|
||||||
|
break;
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
|
if ((fd = open(file, O_RDONLY)) == -1)
|
||||||
|
if (errno != ENOENT)
|
||||||
|
err(1, "open(%s)for read", file);
|
||||||
|
n = arc4random() % WRLOOPS + 1;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
ln = rnd() % BSIZE + 1;
|
||||||
|
offset = rnd() % (MX - ln);
|
||||||
|
if (lseek(fd, offset, SEEK_SET) == -1) {
|
||||||
|
if (errno == EBADF)
|
||||||
|
continue;
|
||||||
|
err(1, "lseek in rd");
|
||||||
|
}
|
||||||
|
if (read(fd, buf, ln) < 0)
|
||||||
|
err(1, "write");
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mv(int idx)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char file2[MAXPATHLEN + 1];
|
||||||
|
|
||||||
|
snprintf(file, sizeof(file), "%s/f.%s.%06d", path, uid, idx);
|
||||||
|
snprintf(file2, sizeof(file2), "%s/f.%s.%06d.old", path, uid, idx);
|
||||||
|
for (i = 0; i < 100; i++) {
|
||||||
|
if (access(file, R_OK) == 0)
|
||||||
|
break;
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
|
if (rename(file, file2) == -1)
|
||||||
|
if (errno != ENOENT)
|
||||||
|
warn("rename(%s, %s)", file, file2);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tr(int idx)
|
||||||
|
{
|
||||||
|
off_t offset;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
if (arc4random() % 100 < 10) {
|
||||||
|
snprintf(file, sizeof(file), "%s/f.%s.%06d", path, uid, idx);
|
||||||
|
setproctitle(__func__);
|
||||||
|
if ((fd = open(file, O_RDWR | O_CREAT, 0644)) == -1)
|
||||||
|
err(1, "open(%s)for read", file);
|
||||||
|
offset = rnd() % MX;
|
||||||
|
offset = rnd();
|
||||||
|
if (ftruncate(fd, offset) == -1)
|
||||||
|
err(1, "truncate");
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rm(int idx)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char file2[MAXPATHLEN + 1];
|
||||||
|
|
||||||
|
snprintf(file2, sizeof(file2), "%s/f.%s.%06d.old", path, uid, idx);
|
||||||
|
for (i = 0; i < 100; i++) {
|
||||||
|
if (access(file2, R_OK) == 0)
|
||||||
|
break;
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
|
if (unlink(file2) == -1)
|
||||||
|
if (errno != ENOENT)
|
||||||
|
warn("unlink(%s)", file2);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test2(void (*func)(int nr))
|
||||||
|
{
|
||||||
|
time_t start;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
setproctitle(__func__);
|
||||||
|
start = time(NULL);
|
||||||
|
while (time(NULL) - start < RUNTIME) {
|
||||||
|
for (i = 0; i < PARALLEL; i++) {
|
||||||
|
if (fork() == 0)
|
||||||
|
func(i);
|
||||||
|
}
|
||||||
|
for (i = 0; i < PARALLEL; i++)
|
||||||
|
wait(NULL);
|
||||||
|
}
|
||||||
|
_exit(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test(void (*func)(int nr))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (fork() == 0)
|
||||||
|
test2(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (argc != 3)
|
||||||
|
errx(1, "Usage: %s <path> <uid>", argv[0]);
|
||||||
|
|
||||||
|
path = argv[1];
|
||||||
|
uid = argv[2];
|
||||||
|
|
||||||
|
if ((rfd = open("/dev/random", O_RDONLY)) == -1)
|
||||||
|
err(1, "open(/dev/random)");
|
||||||
|
setproctitle(__func__);
|
||||||
|
buf = malloc(BSIZE);
|
||||||
|
test(wr);
|
||||||
|
test(rd);
|
||||||
|
test(tr);
|
||||||
|
test(mv);
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
if (wait(NULL) == -1)
|
||||||
|
err(1, "wait");
|
||||||
|
|
||||||
|
for (i = 0; i < PARALLEL; i++) {
|
||||||
|
snprintf(file, sizeof(file), "%s/f.%s.%06d", path, uid, i);
|
||||||
|
unlink(file);
|
||||||
|
snprintf(file, sizeof(file), "%s/f.%s.%06d.old", path, uid, i);
|
||||||
|
unlink(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
187
tools/test/stress2/misc/cmp.sh
Executable file
187
tools/test/stress2/misc/cmp.sh
Executable file
@ -0,0 +1,187 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Cross mount test of mkdir(2).
|
||||||
|
# Page fault seen:
|
||||||
|
# http://people.freebsd.org/~pho/stress/log/cmp.txt
|
||||||
|
# Fixed by r275347
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $here/$0 > cmp.c
|
||||||
|
mycc -o cmp -Wall -Wextra -O2 -g cmp.c || exit 1
|
||||||
|
rm -f cmp.c
|
||||||
|
|
||||||
|
mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
|
||||||
|
|
||||||
|
mdconfig -a -t swap -s 2g -u $mdstart || exit 1
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
# Don't use SU due to bogus "out of inodes" messages.
|
||||||
|
newfs md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
|
||||||
|
daemon sh -c "(cd $here/../testcases/swap; ./swap -t 5m -i 20 -h -l 100)" \
|
||||||
|
> /dev/null 2>&1
|
||||||
|
sleep 1
|
||||||
|
su $testuser -c "/tmp/cmp $mntpoint" &
|
||||||
|
|
||||||
|
while kill -0 $! 2>/dev/null; do
|
||||||
|
umount -f $mntpoint &&
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
sleep .1
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
|
||||||
|
while mount | grep $mntpoint | grep -q /dev/md; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
[ -d "$mntpoint" ] && (cd $mntpoint && find . -delete)
|
||||||
|
|
||||||
|
# tmpfs
|
||||||
|
mount -t tmpfs tmpfs $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
|
||||||
|
su $testuser -c "/tmp/cmp $mntpoint" &
|
||||||
|
|
||||||
|
while kill -0 $! 2>/dev/null; do
|
||||||
|
umount -f $mntpoint &&
|
||||||
|
mount -t tmpfs tmpfs $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
sleep .1
|
||||||
|
done
|
||||||
|
pkill -9 swap
|
||||||
|
wait
|
||||||
|
|
||||||
|
while pkill -9 swap; do
|
||||||
|
:
|
||||||
|
done > /dev/null 2>&1
|
||||||
|
while mount | grep $mntpoint | grep -q tmpfs; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
[ -d "$mntpoint" ] && (cd $mntpoint && find . -delete)
|
||||||
|
rm -f /tmp/cmp
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define LOOPS 160
|
||||||
|
#define PARALLEL 16
|
||||||
|
|
||||||
|
int nbc, nbd;
|
||||||
|
char *dir;
|
||||||
|
|
||||||
|
void
|
||||||
|
tmkdir(void)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
char d[MAXPATHLEN + 1], name[MAXPATHLEN + 1];
|
||||||
|
|
||||||
|
setproctitle(__func__);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
snprintf(name, sizeof(name), "%s/d1.%05d", dir, getpid());
|
||||||
|
if (mkdir(name, 0755) == -1) {
|
||||||
|
if (errno != ENAMETOOLONG && errno != ENOENT &&
|
||||||
|
errno != EBUSY && errno != EACCES && errno != EPERM)
|
||||||
|
warn("mkdir(%s)", name);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
for (;;) {
|
||||||
|
snprintf(d, sizeof(d), "/%d", i++);
|
||||||
|
strncat(name, d, sizeof(name) - 1);
|
||||||
|
if (mkdir(name, 0755) == -1) {
|
||||||
|
if (errno != ENAMETOOLONG && errno != ENOENT &&
|
||||||
|
errno != EBUSY && errno != EACCES && errno != EPERM)
|
||||||
|
warn("mkdir(%s)", name);
|
||||||
|
i--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nbc++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (i >= 0) {
|
||||||
|
snprintf(name, sizeof(name), "%s/d1.%05d", dir, getpid());
|
||||||
|
for (j = 0; j < i; j++) {
|
||||||
|
snprintf(d, sizeof(d), "/%d", j);
|
||||||
|
strncat(name, d, sizeof(name) - 1);
|
||||||
|
}
|
||||||
|
if (rmdir(name) == -1) {
|
||||||
|
if (errno != ENOTEMPTY && errno != ENOENT && errno !=
|
||||||
|
EBUSY)
|
||||||
|
warn("rmdir(%s)", name);
|
||||||
|
} else
|
||||||
|
nbd++;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
#if defined(TEST)
|
||||||
|
if (nbc == 0)
|
||||||
|
fprintf(stderr, "FAIL nbc = %d, nbd = %d\n", nbc, nbd);
|
||||||
|
#endif
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "Usage: %s <full path to dir>", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
dir = argv[1];
|
||||||
|
|
||||||
|
for (j = 0; j < LOOPS; j++) {
|
||||||
|
for (i = 0; i < PARALLEL; i++) {
|
||||||
|
if (fork() == 0)
|
||||||
|
tmkdir();
|
||||||
|
}
|
||||||
|
for (i = 0; i < PARALLEL; i++)
|
||||||
|
wait(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
153
tools/test/stress2/misc/collapse.sh
Executable file
153
tools/test/stress2/misc/collapse.sh
Executable file
@ -0,0 +1,153 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 Jeffrey Roberson <jeff@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
# "panic: freeing mapped page 0xfffffe000aa73910" seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/collapse.txt
|
||||||
|
|
||||||
|
odir=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > collapse.c
|
||||||
|
mycc -o collapse -Wall -Wextra -g -O0 collapse.c || exit 1
|
||||||
|
rm -f collapse.c
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
daemon sh -c '(cd ../testcases/swap; ./swap -t 20m -i 16 -l 85)' > \
|
||||||
|
/dev/null 2>&1
|
||||||
|
sleep 2
|
||||||
|
/tmp/collapse
|
||||||
|
while pgrep -q swap; do
|
||||||
|
pkill -9 swap
|
||||||
|
done
|
||||||
|
rm -f /tmp/collapse
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define ADRSPACE (256 * 1024)
|
||||||
|
#define DEPTH 6
|
||||||
|
#define WIDTH 3
|
||||||
|
#define PARALLEL 4
|
||||||
|
#define RUNTIME 1200
|
||||||
|
#define CHILDTIME 5
|
||||||
|
#define STARTTIME 5
|
||||||
|
#define TOUCH 16
|
||||||
|
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
static void
|
||||||
|
child(int depth, time_t start)
|
||||||
|
{
|
||||||
|
time_t run, delay;
|
||||||
|
int i, shared, off;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
/* Pick a random bit of address space to change inherit on. */
|
||||||
|
for (i = 0; i < ADRSPACE; i += len) {
|
||||||
|
shared = arc4random() & 0x1;
|
||||||
|
len = roundup2(arc4random() % ((ADRSPACE - i) / 4),
|
||||||
|
PAGE_SIZE);
|
||||||
|
if (minherit(p + i, len, shared ? INHERIT_SHARE :
|
||||||
|
INHERIT_COPY) != 0)
|
||||||
|
err(1, "minherit");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; depth != 0 && i < WIDTH; i++)
|
||||||
|
if (fork() == 0)
|
||||||
|
child(depth - 1, start);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Touch all of the memory and exit at a random time to collapse
|
||||||
|
* some portion of the chain.
|
||||||
|
*/
|
||||||
|
delay = arc4random() % (CHILDTIME - 1);
|
||||||
|
run = arc4random() % (CHILDTIME - delay);
|
||||||
|
for (;;) {
|
||||||
|
if (time(NULL) >= start + delay)
|
||||||
|
break;
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
|
while (time(NULL) - start < run) {
|
||||||
|
off = rounddown2(arc4random() % ADRSPACE, PAGE_SIZE);
|
||||||
|
bzero(p + off, PAGE_SIZE);
|
||||||
|
usleep((run * 1000) / TOUCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
work(int depth)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ((p = mmap(NULL, ADRSPACE, PROT_READ | PROT_WRITE,
|
||||||
|
MAP_SHARED | MAP_ANON, -1, 0)) == MAP_FAILED) {
|
||||||
|
if (errno == ENOMEM)
|
||||||
|
return;
|
||||||
|
err(1, "mmap()");
|
||||||
|
}
|
||||||
|
child(depth, time(NULL) + STARTTIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
pid_t pids[PARALLEL];
|
||||||
|
time_t start;
|
||||||
|
int i, n;
|
||||||
|
|
||||||
|
start = time(NULL);
|
||||||
|
while (time(NULL) - start < RUNTIME) {
|
||||||
|
n = arc4random() % PARALLEL + 1;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
if ((pids[i] = fork()) == 0)
|
||||||
|
work(DEPTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep(CHILDTIME + STARTTIME + 1);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
if (waitpid(pids[i], NULL, 0) != pids[i])
|
||||||
|
err(1, "waitpid(%d)", pids[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
44
tools/test/stress2/misc/compare.sh
Executable file
44
tools/test/stress2/misc/compare.sh
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Compare two disk files.
|
||||||
|
|
||||||
|
diskimage=/var/tmp/diskimage
|
||||||
|
|
||||||
|
d1=$diskimage
|
||||||
|
d2=${diskimage}2
|
||||||
|
have=`df -k $(dirname $d1) | tail -1 | awk '{print int($4 / 1024)}'`
|
||||||
|
[ $have -lt 1024 ] &&
|
||||||
|
{ echo "Not enough disk space on `dirname $d1`"; exit 1; }
|
||||||
|
|
||||||
|
dd if=/dev/random of=$d1 bs=1m count=512 status=none || exit 1
|
||||||
|
cp $d1 $d2
|
||||||
|
cmp $d1 $d2 && s=0 || { echo FAIL; s=1; }
|
||||||
|
rm -f $d1 $d2
|
||||||
|
exit $s
|
130
tools/test/stress2/misc/context.sh
Executable file
130
tools/test/stress2/misc/context.sh
Executable file
@ -0,0 +1,130 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $here/$0 > context.c
|
||||||
|
mycc -o context -Wall -Wextra -O2 -g context.c || exit 1
|
||||||
|
rm -f context.c
|
||||||
|
[ -d $RUNDIR ] || mkdir -p $RUNDIR
|
||||||
|
cd $RUNDIR
|
||||||
|
|
||||||
|
daemon sh -c "(cd $here/../testcases/swap; ./swap -t 10m -i 20)" > \
|
||||||
|
/dev/null 2>&1
|
||||||
|
for i in `jot 4`; do
|
||||||
|
/tmp/context &
|
||||||
|
pids="$pids $!"
|
||||||
|
done
|
||||||
|
s=0
|
||||||
|
for i in $pids; do
|
||||||
|
wait $i
|
||||||
|
[ $? -ne 0 ] && s=$((s + 1))
|
||||||
|
done
|
||||||
|
while pgrep -q swap; do
|
||||||
|
pkill -9 swap
|
||||||
|
done
|
||||||
|
rm -f /tmp/context
|
||||||
|
exit $s
|
||||||
|
EOF
|
||||||
|
/*
|
||||||
|
* Inspired by lmbench-3.0-a9/src/lat_ctx.c
|
||||||
|
* Pass a token thru pipes to CHILDREN+1 processes in a circular list
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define CHILDREN 64
|
||||||
|
#define RUNTIME 300
|
||||||
|
|
||||||
|
int fds[CHILDREN +1 ][2];
|
||||||
|
pid_t pid[CHILDREN];
|
||||||
|
|
||||||
|
void
|
||||||
|
handler(int s __unused)
|
||||||
|
{
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
time_t start;
|
||||||
|
int i, j;
|
||||||
|
int token;
|
||||||
|
|
||||||
|
for (i = 0; i < CHILDREN + 1; i++) {
|
||||||
|
if (pipe(fds[i]) == -1)
|
||||||
|
err(1, "pipe");
|
||||||
|
}
|
||||||
|
|
||||||
|
signal(SIGHUP, handler);
|
||||||
|
start = time(NULL);
|
||||||
|
for (i = 0; i < CHILDREN; i++) {
|
||||||
|
pid[i] = fork();
|
||||||
|
if (pid[i] == -1) {
|
||||||
|
perror("fork");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pid[i] == 0) { /* child */
|
||||||
|
for (;;) {
|
||||||
|
if (read(fds[i][0], &token, sizeof(token))
|
||||||
|
!= sizeof(token))
|
||||||
|
err(1, "read pipe 2");
|
||||||
|
if (write(fds[i+1][1], &token, sizeof(token))
|
||||||
|
!= sizeof(token))
|
||||||
|
err(1, "write pipe 1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* parent */
|
||||||
|
|
||||||
|
for (j = 0; time(NULL) - start < RUNTIME; j++) {
|
||||||
|
token = j;
|
||||||
|
if (write(fds[0][1], &token, sizeof(token)) != sizeof(token))
|
||||||
|
err(1, "write pipe 2");
|
||||||
|
if (read(fds[CHILDREN][0], &token, sizeof(token))
|
||||||
|
!= sizeof(token))
|
||||||
|
err(1, "read pipe 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < CHILDREN; i++)
|
||||||
|
kill(pid[i], SIGHUP);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
131
tools/test/stress2/misc/context2.sh
Executable file
131
tools/test/stress2/misc/context2.sh
Executable file
@ -0,0 +1,131 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# This problem was seen with WiP kernel code:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik1210.txt
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $here/$0 > context2.c
|
||||||
|
mycc -o context2 -Wall -Wextra -O2 context2.c -lpthread || exit 1
|
||||||
|
rm -f context2.c
|
||||||
|
[ -d $RUNDIR ] || mkdir -p $RUNDIR
|
||||||
|
cd $RUNDIR
|
||||||
|
|
||||||
|
daemon sh -c "(cd $here/../testcases/swap; ./swap -t 10m -i 20)" > \
|
||||||
|
/dev/null 2>&1
|
||||||
|
for i in `jot 4`; do
|
||||||
|
/tmp/context2 &
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
while pgrep -q swap; do
|
||||||
|
pkill -9 swap
|
||||||
|
done
|
||||||
|
rm -f /tmp/context2
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
/*
|
||||||
|
* Inspired by lmbench-3.0-a9/src/lat_ctx.c
|
||||||
|
* Pass a token thru pipes to NTHREADS+1 threads in a circular list.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define NTHREADS 64
|
||||||
|
#define RUNTIME 300
|
||||||
|
|
||||||
|
pid_t pid[NTHREADS];
|
||||||
|
int fds[NTHREADS+1][2];
|
||||||
|
|
||||||
|
void *
|
||||||
|
thr_routine(void *arg)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int token;
|
||||||
|
|
||||||
|
i = (long)arg;
|
||||||
|
for (;;) {
|
||||||
|
if (read(fds[i][0], &token, sizeof(token)) != sizeof(token))
|
||||||
|
err(1, "read pipe 2");
|
||||||
|
token++;
|
||||||
|
if (write(fds[i+1][1], &token, sizeof(token)) != sizeof(token))
|
||||||
|
err(1, "write pipe 1");
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
pthread_t threads[NTHREADS];
|
||||||
|
time_t start;
|
||||||
|
long arg;
|
||||||
|
int i, r, token;
|
||||||
|
|
||||||
|
for (i = 0; i < NTHREADS + 1; i++) {
|
||||||
|
if (pipe(fds[i]) == -1)
|
||||||
|
err(1, "pipe");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < NTHREADS; i++) {
|
||||||
|
arg = i;
|
||||||
|
if ((r = pthread_create(&threads[i], NULL, thr_routine,
|
||||||
|
(void *)arg)) != 0)
|
||||||
|
errc(1, r, "pthread_create(): %s\n", strerror(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
start = time(NULL);
|
||||||
|
while (time(NULL) - start < RUNTIME) {
|
||||||
|
token = 0;
|
||||||
|
if (write(fds[0][1], &token, sizeof(token)) != sizeof(token))
|
||||||
|
err(1, "write pipe 2");
|
||||||
|
if (read(fds[NTHREADS][0], &token, sizeof(token)) !=
|
||||||
|
sizeof(token))
|
||||||
|
err(1, "read pipe 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < NTHREADS; i++)
|
||||||
|
if ((r = pthread_cancel(threads[i])) != 0)
|
||||||
|
errc(1, r, "pthread_cancel(%d)", i);
|
||||||
|
for (i = 0; i < NTHREADS; i++)
|
||||||
|
if ((r = pthread_join(threads[i], NULL)) != 0)
|
||||||
|
errc(1, r, "pthread_join(%d)", i);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
255
tools/test/stress2/misc/contigmalloc.sh
Executable file
255
tools/test/stress2/misc/contigmalloc.sh
Executable file
@ -0,0 +1,255 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# contigmalloc(9) / contigfree(9) test scenario.
|
||||||
|
# malloc() a random number of buffers with random size and then free them.
|
||||||
|
|
||||||
|
# A malloc pattern might look like this:
|
||||||
|
# contigmalloc(186 pages)
|
||||||
|
# contigmalloc(56 pages)
|
||||||
|
# contigmalloc(9 pages)
|
||||||
|
# contigmalloc(202 pages)
|
||||||
|
# contigmalloc(49 pages)
|
||||||
|
# contigmalloc(5 pages)
|
||||||
|
|
||||||
|
# "panic: vm_reserv_alloc_contig: reserv 0xff... isn't free" seen.
|
||||||
|
# http://people.freebsd.org/~pho/stress/log/contigmalloc.txt
|
||||||
|
# Fixed by r271351.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
[ -d /usr/src/sys ] || exit 0
|
||||||
|
builddir=`sysctl kern.version | grep @ | sed 's/.*://'`
|
||||||
|
[ -d "$builddir" ] && export KERNBUILDDIR=$builddir || exit 0
|
||||||
|
export SYSDIR=`echo $builddir | sed 's#/sys.*#/sys#'`
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
odir=`pwd`
|
||||||
|
dir=/tmp/contigmalloc
|
||||||
|
rm -rf $dir; mkdir -p $dir
|
||||||
|
cat > $dir/ctest.c <<EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define min(a,b) (((a)<(b))?(a):(b))
|
||||||
|
#define CAP (64 * 1024 * 1024) /* Total allocation */
|
||||||
|
#define MAXBUF (32 * 1024 * 1024) /* Max buffer size */
|
||||||
|
#define N 512 /* Max allocations */
|
||||||
|
#define RUNTIME 120
|
||||||
|
#define TALLOC 1
|
||||||
|
#define TFREE 2
|
||||||
|
|
||||||
|
void *p[N];
|
||||||
|
long size[N];
|
||||||
|
int n;
|
||||||
|
|
||||||
|
void
|
||||||
|
test(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
long mw, s;
|
||||||
|
int i, no, ps, res;
|
||||||
|
|
||||||
|
if (argc == 3) {
|
||||||
|
no = atoi(argv[1]);
|
||||||
|
mw = atol(argv[2]);
|
||||||
|
}
|
||||||
|
if (argc != 3 || no == 0 || mw == 0)
|
||||||
|
errx(1, "Usage: %s <syscall number> <max wired>", argv[0]);
|
||||||
|
|
||||||
|
ps = getpagesize();
|
||||||
|
s = 0;
|
||||||
|
n = arc4random() % N + 1;
|
||||||
|
mw = mw / 100 * 10 * ps; /* Use 10% of vm.max_user_wired */
|
||||||
|
mw = min(mw, CAP);
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
size[i] = round_page((arc4random() % MAXBUF) + 1);
|
||||||
|
if (s + size[i] > mw)
|
||||||
|
continue;
|
||||||
|
res = syscall(no, TALLOC, &p[i], &size[i]);
|
||||||
|
if (res == -1) {
|
||||||
|
warn("contigmalloc(%lu pages) failed at loop %d",
|
||||||
|
size[i] / ps, i);
|
||||||
|
usleep(200000);
|
||||||
|
} else {
|
||||||
|
#if defined(TEST)
|
||||||
|
fprintf(stderr, "contigmalloc(%lu pages)\n",
|
||||||
|
size[i] / ps);
|
||||||
|
#endif
|
||||||
|
s += size[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setproctitle("%ld Mb", s / 1024 / 1024);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
if (p[i] != NULL) {
|
||||||
|
res = syscall(no, TFREE, &p[i], &size[i]);
|
||||||
|
#if defined(TEST)
|
||||||
|
fprintf(stderr, "contigfree(%lu pages)\n",
|
||||||
|
size[i] / ps);
|
||||||
|
#endif
|
||||||
|
p[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
time_t start;
|
||||||
|
|
||||||
|
start = time(NULL);
|
||||||
|
while (time(NULL) - start < RUNTIME)
|
||||||
|
test(argc, argv);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
mycc -o /tmp/ctest -Wall -Wextra -O0 -g $dir/ctest.c || exit 1
|
||||||
|
rm $dir/ctest.c
|
||||||
|
|
||||||
|
cd $dir
|
||||||
|
cat > Makefile <<EOF
|
||||||
|
KMOD= cmalloc
|
||||||
|
SRCS= cmalloc.c
|
||||||
|
|
||||||
|
.include <bsd.kmod.mk>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sed '1,/^EOF2/d' < $odir/$0 > cmalloc.c
|
||||||
|
make || exit 1
|
||||||
|
kldload $dir/cmalloc.ko || exit 1
|
||||||
|
|
||||||
|
cd $odir
|
||||||
|
mw=`sysctl -n vm.max_user_wired` || exit 1
|
||||||
|
/tmp/ctest `sysctl -n debug.cmalloc_offset` $mw 2>&1 | tail -5
|
||||||
|
kldunload $dir/cmalloc.ko
|
||||||
|
rm -rf $dir /tmp/ctest
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
EOF2
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/module.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/sysent.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
|
||||||
|
#define TALLOC 1
|
||||||
|
#define TFREE 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hook up a syscall for contigmalloc testing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct cmalloc_args {
|
||||||
|
int a_op;
|
||||||
|
void *a_ptr;
|
||||||
|
void *a_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmalloc(struct thread *td, struct cmalloc_args *uap)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
unsigned long size;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = copyin(uap->a_size, &size, sizeof(size));
|
||||||
|
if (error != 0) {
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
switch (uap->a_op) {
|
||||||
|
case TFREE:
|
||||||
|
error = copyin(uap->a_ptr, &p, sizeof(p));
|
||||||
|
if (error == 0) {
|
||||||
|
if (p != NULL)
|
||||||
|
contigfree(p, size, M_TEMP);
|
||||||
|
}
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
case TALLOC:
|
||||||
|
p = contigmalloc(size, M_TEMP, M_NOWAIT, 0ul, ~0ul, 4096, 0);
|
||||||
|
if (p != NULL) {
|
||||||
|
error = copyout(&p, uap->a_ptr, sizeof(p));
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
return (ENOMEM);
|
||||||
|
}
|
||||||
|
return (EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The sysent for the new syscall
|
||||||
|
*/
|
||||||
|
static struct sysent cmalloc_sysent = {
|
||||||
|
.sy_narg = 3, /* sy_narg */
|
||||||
|
.sy_call = (sy_call_t *) cmalloc /* sy_call */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The offset in sysent where the syscall is allocated.
|
||||||
|
*/
|
||||||
|
static int cmalloc_offset = NO_SYSCALL;
|
||||||
|
|
||||||
|
SYSCTL_INT(_debug, OID_AUTO, cmalloc_offset, CTLFLAG_RD, &cmalloc_offset, 0,
|
||||||
|
"cmalloc syscall number");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The function called at load/unload.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmalloc_load(struct module *module, int cmd, void *arg)
|
||||||
|
{
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case MOD_LOAD :
|
||||||
|
break;
|
||||||
|
case MOD_UNLOAD :
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
error = EOPNOTSUPP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
SYSCALL_MODULE(cmalloc_syscall, &cmalloc_offset, &cmalloc_sysent,
|
||||||
|
cmalloc_load, NULL);
|
223
tools/test/stress2/misc/contigmalloc2.sh
Executable file
223
tools/test/stress2/misc/contigmalloc2.sh
Executable file
@ -0,0 +1,223 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# contigmalloc(9) / contigfree(9) test scenario.
|
||||||
|
# Regression test for allocations >= 2 GiB.
|
||||||
|
# "panic: vm_page_insert_after: mpred doesn't precede pindex" seen.
|
||||||
|
# Fixed by r284207.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
[ -d /usr/src/sys ] || exit 0
|
||||||
|
builddir=`sysctl kern.version | grep @ | sed 's/.*://'`
|
||||||
|
[ -d "$builddir" ] && export KERNBUILDDIR=$builddir || exit 0
|
||||||
|
export SYSDIR=`echo $builddir | sed 's#/sys.*#/sys#'`
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
odir=`pwd`
|
||||||
|
dir=/tmp/contigmalloc
|
||||||
|
rm -rf $dir; mkdir -p $dir
|
||||||
|
cat > $dir/ctest2.c <<EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define TALLOC 1
|
||||||
|
#define TFREE 2
|
||||||
|
|
||||||
|
void *p;
|
||||||
|
long size;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
void
|
||||||
|
test(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
long mw;
|
||||||
|
int no, ps, res;
|
||||||
|
|
||||||
|
if (argc == 3) {
|
||||||
|
no = atoi(argv[1]);
|
||||||
|
mw = atol(argv[2]);
|
||||||
|
}
|
||||||
|
if (argc != 3 || no == 0 || mw == 0)
|
||||||
|
errx(1, "Usage: %s <syscall number> <max wired>", argv[0]);
|
||||||
|
|
||||||
|
ps = getpagesize();
|
||||||
|
size = mw / 100 * 80 * ps; /* Use 80% of vm.max_user_wired */
|
||||||
|
while (size > 0) {
|
||||||
|
res = syscall(no, TALLOC, &p, &size);
|
||||||
|
if (res == -1) {
|
||||||
|
if (errno != ENOMEM)
|
||||||
|
warn("contigmalloc(%lu pages) failed",
|
||||||
|
size);
|
||||||
|
} else {
|
||||||
|
#if defined(TEST)
|
||||||
|
fprintf(stderr, "pre contigmalloc(%lu pages): %lu MiB\n",
|
||||||
|
size, size * ps / 1024 / 1024);
|
||||||
|
#endif
|
||||||
|
res = syscall(no, TFREE, &p, &size);
|
||||||
|
#if defined(TEST)
|
||||||
|
fprintf(stderr, "contigfree(%lu pages)\n",
|
||||||
|
size);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
size /= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
test(argc, argv);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
mycc -o /tmp/ctest2 -Wall -Wextra -O0 -g $dir/ctest2.c || exit 1
|
||||||
|
rm $dir/ctest2.c
|
||||||
|
|
||||||
|
cd $dir
|
||||||
|
cat > Makefile <<EOF
|
||||||
|
KMOD= cmalloc2
|
||||||
|
SRCS= cmalloc2.c
|
||||||
|
|
||||||
|
.include <bsd.kmod.mk>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sed '1,/^EOF2/d' < $odir/$0 > cmalloc2.c
|
||||||
|
make depend all || exit 1
|
||||||
|
kldload $dir/cmalloc2.ko || exit 1
|
||||||
|
|
||||||
|
cd $odir
|
||||||
|
mw=$((`sysctl -n vm.max_user_wired` - \
|
||||||
|
`sysctl -n vm.stats.vm.v_user_wire_count`)) || exit 1
|
||||||
|
/tmp/ctest2 `sysctl -n debug.cmalloc_offset` $mw #2>&1 | tail -5
|
||||||
|
kldunload $dir/cmalloc2.ko
|
||||||
|
rm -rf $dir /tmp/ctest2
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
EOF2
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/module.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/sysent.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
|
||||||
|
#define TALLOC 1
|
||||||
|
#define TFREE 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hook up a syscall for contigmalloc testing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct cmalloc_args {
|
||||||
|
int a_op;
|
||||||
|
void *a_ptr;
|
||||||
|
void *a_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmalloc(struct thread *td, struct cmalloc_args *uap)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
unsigned long size;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = copyin(uap->a_size, &size, sizeof(size));
|
||||||
|
if (error != 0) {
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
switch (uap->a_op) {
|
||||||
|
case TFREE:
|
||||||
|
error = copyin(uap->a_ptr, &p, sizeof(p));
|
||||||
|
if (error == 0) {
|
||||||
|
if (p != NULL)
|
||||||
|
contigfree(p, size, M_TEMP);
|
||||||
|
}
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
case TALLOC:
|
||||||
|
p = contigmalloc(size, M_TEMP, M_NOWAIT, 0ul, ~0ul, 4096, 0);
|
||||||
|
if (p != NULL) {
|
||||||
|
error = copyout(&p, uap->a_ptr, sizeof(p));
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
return (ENOMEM);
|
||||||
|
}
|
||||||
|
return (EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The sysent for the new syscall
|
||||||
|
*/
|
||||||
|
static struct sysent cmalloc_sysent = {
|
||||||
|
.sy_narg = 3, /* sy_narg */
|
||||||
|
.sy_call = (sy_call_t *) cmalloc /* sy_call */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The offset in sysent where the syscall is allocated.
|
||||||
|
*/
|
||||||
|
static int cmalloc_offset = NO_SYSCALL;
|
||||||
|
|
||||||
|
SYSCTL_INT(_debug, OID_AUTO, cmalloc_offset, CTLFLAG_RD, &cmalloc_offset, 0,
|
||||||
|
"cmalloc syscall number");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The function called at load/unload.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmalloc_load(struct module *module, int cmd, void *arg)
|
||||||
|
{
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case MOD_LOAD :
|
||||||
|
break;
|
||||||
|
case MOD_UNLOAD :
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
error = EOPNOTSUPP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
SYSCALL_MODULE(cmalloc_syscall, &cmalloc_offset, &cmalloc_sysent,
|
||||||
|
cmalloc_load, NULL);
|
225
tools/test/stress2/misc/contigmalloc3.sh
Executable file
225
tools/test/stress2/misc/contigmalloc3.sh
Executable file
@ -0,0 +1,225 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# contigmalloc(9) / contigfree(9) test scenario.
|
||||||
|
# Test allocation with 1GB
|
||||||
|
|
||||||
|
# "panic: Bad link elm 0x6766fbc next->prev != elm" seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik1094.txt
|
||||||
|
# Fixed by r331247
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
[ -d /usr/src/sys ] || exit 0
|
||||||
|
builddir=`sysctl kern.version | grep @ | sed 's/.*://'`
|
||||||
|
[ -d "$builddir" ] && export KERNBUILDDIR=$builddir || exit 0
|
||||||
|
export SYSDIR=`echo $builddir | sed 's#/sys.*#/sys#'`
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
odir=`pwd`
|
||||||
|
dir=/tmp/contigmalloc
|
||||||
|
rm -rf $dir; mkdir -p $dir
|
||||||
|
cat > $dir/ctest.c <<EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define MAXBUF (1LL * 1024 * 1024 * 1024) /* Max buffer size */
|
||||||
|
#define TALLOC 1
|
||||||
|
#define TFREE 2
|
||||||
|
|
||||||
|
void
|
||||||
|
test(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
long mw, size;
|
||||||
|
int i, no, ps, res;
|
||||||
|
char *cp;
|
||||||
|
|
||||||
|
if (argc == 3) {
|
||||||
|
no = atoi(argv[1]);
|
||||||
|
mw = atol(argv[2]);
|
||||||
|
}
|
||||||
|
if (argc != 3 || no == 0 || mw == 0)
|
||||||
|
errx(1, "Usage: %s <syscall number> <max wired>", argv[0]);
|
||||||
|
|
||||||
|
ps = getpagesize();
|
||||||
|
if (mw < MAXBUF / ps) {
|
||||||
|
fprintf(stderr, "max_user_wired too small for this test\n");
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
size = round_page(MAXBUF);
|
||||||
|
res = syscall(no, TALLOC, &cp, &size);
|
||||||
|
if (res == -1) {
|
||||||
|
err(1, "contigmalloc(%lu MB) failed",
|
||||||
|
size / 1024 / 1024);
|
||||||
|
} else {
|
||||||
|
#if defined(TEST)
|
||||||
|
fprintf(stderr, "contigmalloc(%lu pages) %luMB\n",
|
||||||
|
size / ps, size / 1024 / 1024);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
res = syscall(no, TFREE, &cp, &size);
|
||||||
|
#if defined(TEST)
|
||||||
|
fprintf(stderr, "contigfree(%lu pages) %luMB\n",
|
||||||
|
size / ps, size / 1024 / 1024);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
test(argc, argv);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
mycc -o /tmp/ctest -Wall -Wextra -O0 -g $dir/ctest.c || exit 1
|
||||||
|
rm $dir/ctest.c
|
||||||
|
|
||||||
|
cd $dir
|
||||||
|
cat > Makefile <<EOF
|
||||||
|
KMOD= cmalloc
|
||||||
|
SRCS= cmalloc.c
|
||||||
|
|
||||||
|
.include <bsd.kmod.mk>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sed '1,/^EOF2/d' < $odir/$0 > cmalloc.c
|
||||||
|
make || exit 1
|
||||||
|
kldload $dir/cmalloc.ko || exit 1
|
||||||
|
|
||||||
|
cd $odir
|
||||||
|
mw=`sysctl -n vm.max_user_wired` || exit 1
|
||||||
|
/tmp/ctest `sysctl -n debug.cmalloc_offset` $mw 2>&1 | tail -5
|
||||||
|
kldunload $dir/cmalloc.ko
|
||||||
|
rm -rf $dir /tmp/ctest
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
EOF2
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/module.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/sysent.h>
|
||||||
|
#include <sys/sysproto.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
|
||||||
|
#define TALLOC 1
|
||||||
|
#define TFREE 2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hook up a syscall for contigmalloc testing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct cmalloc_args {
|
||||||
|
int a_op;
|
||||||
|
void *a_ptr;
|
||||||
|
void *a_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmalloc(struct thread *td, struct cmalloc_args *uap)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
unsigned long size;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = copyin(uap->a_size, &size, sizeof(size));
|
||||||
|
if (error != 0) {
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
switch (uap->a_op) {
|
||||||
|
case TFREE:
|
||||||
|
error = copyin(uap->a_ptr, &p, sizeof(p));
|
||||||
|
if (error == 0) {
|
||||||
|
if (p != NULL)
|
||||||
|
contigfree(p, size, M_TEMP);
|
||||||
|
}
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
case TALLOC:
|
||||||
|
p = contigmalloc(size, M_TEMP, M_NOWAIT, 0ul, ~0ul, 4096, 0);
|
||||||
|
if (p != NULL) {
|
||||||
|
error = copyout(&p, uap->a_ptr, sizeof(p));
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
return (ENOMEM);
|
||||||
|
}
|
||||||
|
return (EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The sysent for the new syscall
|
||||||
|
*/
|
||||||
|
static struct sysent cmalloc_sysent = {
|
||||||
|
.sy_narg = 3, /* sy_narg */
|
||||||
|
.sy_call = (sy_call_t *) cmalloc /* sy_call */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The offset in sysent where the syscall is allocated.
|
||||||
|
*/
|
||||||
|
static int cmalloc_offset = NO_SYSCALL;
|
||||||
|
|
||||||
|
SYSCTL_INT(_debug, OID_AUTO, cmalloc_offset, CTLFLAG_RD, &cmalloc_offset, 0,
|
||||||
|
"cmalloc syscall number");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The function called at load/unload.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmalloc_load(struct module *module, int cmd, void *arg)
|
||||||
|
{
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case MOD_LOAD :
|
||||||
|
break;
|
||||||
|
case MOD_UNLOAD :
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
error = EOPNOTSUPP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
SYSCALL_MODULE(cmalloc_syscall, &cmalloc_offset, &cmalloc_sysent,
|
||||||
|
cmalloc_load, NULL);
|
77
tools/test/stress2/misc/core.sh
Executable file
77
tools/test/stress2/misc/core.sh
Executable file
@ -0,0 +1,77 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Test multiple (parallel) core dumps
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
odir=`pwd`
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
rm -f core
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > core.c
|
||||||
|
mycc -o core -Wall core.c
|
||||||
|
rm -f core.c
|
||||||
|
cd $RUNDIR
|
||||||
|
|
||||||
|
for i in `jot 2`; do
|
||||||
|
for j in `jot 4`; do
|
||||||
|
/tmp/core &
|
||||||
|
done
|
||||||
|
for j in `jot 4`; do
|
||||||
|
wait
|
||||||
|
done
|
||||||
|
done
|
||||||
|
rm -f /tmp/core
|
||||||
|
exit
|
||||||
|
EOF
|
||||||
|
#include <err.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define SIZ 10*1024*1024
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char *cp;
|
||||||
|
|
||||||
|
if ((cp = malloc(SIZ)) == NULL)
|
||||||
|
err(1, "Could not malloc 10Mb!");
|
||||||
|
|
||||||
|
memset(cp, 1, SIZ);
|
||||||
|
|
||||||
|
sleep(120 - (time(NULL) % 120));
|
||||||
|
raise(SIGSEGV);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
95
tools/test/stress2/misc/core2.sh
Executable file
95
tools/test/stress2/misc/core2.sh
Executable file
@ -0,0 +1,95 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Test multiple (parallel) core dumps and umount
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
odir=`pwd`
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > core2.c
|
||||||
|
mycc -o core2 -Wall -Wextra -O0 core2.c || exit 1
|
||||||
|
rm -f core2.c
|
||||||
|
cd $RUNDIR
|
||||||
|
|
||||||
|
mount | grep "on $mntpoint " | grep -q md$mdstart && umount $mntpoint
|
||||||
|
[ -c /dev/mn$mdstart ] && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 1g -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
|
||||||
|
touch /tmp/continue
|
||||||
|
for i in `jot 64`; do
|
||||||
|
mkdir -p $mntpoint/d$i
|
||||||
|
(cd $mntpoint; /tmp/core2) &
|
||||||
|
done
|
||||||
|
rm -f /tmp/continue
|
||||||
|
|
||||||
|
for i in `jot 60`; do
|
||||||
|
umount $mntpoint 2>/dev/null || sleep 1
|
||||||
|
mount | grep -q "on $mntpoint " || break
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
mount | grep -q "on $mntpoint " &&
|
||||||
|
umount -f $mntpoint
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
rm -f /tmp/core2
|
||||||
|
exit
|
||||||
|
EOF
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define SIZ 1L * 128 * 1024 * 1024
|
||||||
|
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
len = SIZ;
|
||||||
|
p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
|
||||||
|
|
||||||
|
while (access("/tmp/continue", R_OK) == 0)
|
||||||
|
usleep(1);
|
||||||
|
|
||||||
|
raise(SIGSEGV);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
171
tools/test/stress2/misc/core3.sh
Executable file
171
tools/test/stress2/misc/core3.sh
Executable file
@ -0,0 +1,171 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Test multiple (parallel) core dumps and mount / umount.
|
||||||
|
# mount(8) stuck in "ufs" or "tmpfs".
|
||||||
|
# http://people.freebsd.org/~pho/stress/log/kostik724.txt
|
||||||
|
# Fixed by r272535.
|
||||||
|
# On i386 pgrep(1) loops. Fixed by r272566.
|
||||||
|
|
||||||
|
# "Sleeping on "pmapdi" with the following non-sleepable locks held:"
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik883.txt
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
odir=`pwd`
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > core3.c
|
||||||
|
mycc -o core3 -Wall -Wextra -O2 core3.c || exit 1
|
||||||
|
rm -f core3.c
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
mount | grep -q "on $mntpoint " && umount $mntpoint
|
||||||
|
[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 1g -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
mkdir $mntpoint/d
|
||||||
|
chmod 777 $mntpoint/d
|
||||||
|
|
||||||
|
su $testuser -c "/tmp/core3 $mntpoint/d" &
|
||||||
|
pid=$!
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
while pgrep -q core3; do
|
||||||
|
[ -d $mntpoint/d ] &&
|
||||||
|
umount -f $mntpoint
|
||||||
|
done > /dev/null 2>&1 &
|
||||||
|
while pgrep -q core3; do
|
||||||
|
[ -d $mntpoint/d ] ||
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
done > /dev/null 2>&1
|
||||||
|
wait $pid
|
||||||
|
status=$?
|
||||||
|
mount | grep -q "on $mntpoint " &&
|
||||||
|
umount -f $mntpoint
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
[ $status -ne 0 ] && exit $status
|
||||||
|
|
||||||
|
# tmpfs
|
||||||
|
mount -o size=1g -t tmpfs tmpfs $mntpoint
|
||||||
|
su $testuser -c "/tmp/core3 $mntpoint/d" &
|
||||||
|
pid=$!
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
while pgrep -q core3; do
|
||||||
|
[ -d $mntpoint/d ] &&
|
||||||
|
umount -f $mntpoint
|
||||||
|
done > /dev/null &
|
||||||
|
while pgrep -q core3; do
|
||||||
|
if [ ! -d $mntpoint/d ]; then
|
||||||
|
mount -t tmpfs tmpfs $mntpoint
|
||||||
|
mkdir $mntpoint/d
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
wait $pid
|
||||||
|
status=$?
|
||||||
|
for i in `jot 5` ; do
|
||||||
|
mount | grep -q "on $mntpoint " || break
|
||||||
|
umount -f $mntpoint
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
rm -f /tmp/core3
|
||||||
|
exit $status
|
||||||
|
EOF
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define PARALLEL 64
|
||||||
|
#define SIZ (4 * 1024 * 1024)
|
||||||
|
#define TIMEDOUT 22
|
||||||
|
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
static void
|
||||||
|
hand(int i __unused) { /* handler */
|
||||||
|
_exit(TIMEDOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test(char *argv[])
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
len = SIZ;
|
||||||
|
p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This loop caused mount to wait in "ufs".
|
||||||
|
* Adding a usleep(200) would remove the hang.
|
||||||
|
*/
|
||||||
|
signal(SIGALRM, hand);
|
||||||
|
alarm(600);
|
||||||
|
while (chdir(argv[1]) == -1)
|
||||||
|
;
|
||||||
|
|
||||||
|
raise(SIGSEGV);
|
||||||
|
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
time_t start;
|
||||||
|
int i, s, status;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
errx(1, "Usage: %s <path>", argv[0]);
|
||||||
|
|
||||||
|
status = 0;
|
||||||
|
start = time(NULL);
|
||||||
|
while (time(NULL) - start < 600 && status == 0) {
|
||||||
|
for (i = 0; i < PARALLEL; i++) {
|
||||||
|
if (fork() == 0)
|
||||||
|
test(argv);
|
||||||
|
}
|
||||||
|
for (i = 0; i < PARALLEL; i++) {
|
||||||
|
wait(&s);
|
||||||
|
if (WEXITSTATUS(s) == TIMEDOUT)
|
||||||
|
status = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (status);
|
||||||
|
}
|
89
tools/test/stress2/misc/core4.sh
Executable file
89
tools/test/stress2/misc/core4.sh
Executable file
@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Test multiple (parallel) core dumps and umount -f
|
||||||
|
|
||||||
|
# "panic: vn_finished_write: neg cnt" seen.
|
||||||
|
# http://people.freebsd.org/~pho/core4.sh
|
||||||
|
# Fixed in r274501
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $here/$0 > core4.c
|
||||||
|
mycc -o core4 -Wall -Wextra -O0 -g core4.c || exit 1
|
||||||
|
rm -f core4.c
|
||||||
|
|
||||||
|
mount | grep -q "$mntpoint" && umount $mntpoint
|
||||||
|
mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart
|
||||||
|
|
||||||
|
mdconfig -a -t swap -s 2g -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
for i in `jot 20`; do
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
su $testuser -c "(cd $mntpoint; /tmp/core4)" &
|
||||||
|
su $testuser -c "(cd $mntpoint; /tmp/core4)" &
|
||||||
|
su $testuser -c "(cd $mntpoint; /tmp/core4)" &
|
||||||
|
sleep .5
|
||||||
|
sleep .`jot -r 1 1 9`
|
||||||
|
umount -f $mntpoint
|
||||||
|
wait
|
||||||
|
done 2>/dev/null
|
||||||
|
|
||||||
|
while mount | grep -q "on $mntpoint "; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
rm -f /tmp/core4
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define SIZ (1024L * 1024 * 1024)
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
p = mmap(NULL, SIZ, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
|
||||||
|
usleep(1000);
|
||||||
|
raise(SIGSEGV);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
199
tools/test/stress2/misc/core5.sh
Executable file
199
tools/test/stress2/misc/core5.sh
Executable file
@ -0,0 +1,199 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# The core file vnode is unreferenced before notification is sent.
|
||||||
|
|
||||||
|
# Problem reported by sbruno@
|
||||||
|
# http://people.freebsd.org/~pho/stress/log/core5.txt
|
||||||
|
# Fixed by r279237.
|
||||||
|
|
||||||
|
# 20150714 Slowdown seen with core5 waiting in vlruwk.
|
||||||
|
# sysctl vfs.vlru_allow_cache_src=1 used to resolve this.
|
||||||
|
# For now change MAXVNODES from 1.000 to 4.000.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $here/$0 > core5.c
|
||||||
|
mycc -o core5 -Wall -Wextra -O0 -g core5.c || exit 1
|
||||||
|
rm -f core5.c
|
||||||
|
|
||||||
|
cat > core5-dumper.c << EOT
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc __unused, char *argv[])
|
||||||
|
{
|
||||||
|
time_t start;
|
||||||
|
char core[80];
|
||||||
|
|
||||||
|
snprintf(core, sizeof(core), "%s.core", argv[0]);
|
||||||
|
|
||||||
|
if (unlink(core) == -1)
|
||||||
|
if (errno != ENOENT)
|
||||||
|
warn("unlink(%s)", core);
|
||||||
|
|
||||||
|
start = time(NULL);
|
||||||
|
while (time(NULL) - start < 600) {
|
||||||
|
if (fork() == 0)
|
||||||
|
raise(SIGSEGV);
|
||||||
|
wait(NULL);
|
||||||
|
}
|
||||||
|
if (unlink(core) == -1)
|
||||||
|
if (errno != ENOENT)
|
||||||
|
warn("unlink(%s)", core);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
EOT
|
||||||
|
mycc -o core5-dumper -Wall -Wextra -O0 -g core5-dumper.c || exit 1
|
||||||
|
rm -f core5-dumper.c
|
||||||
|
for i in `jot 10`; do
|
||||||
|
cp core5-dumper core5-dumper$i
|
||||||
|
done
|
||||||
|
rm -f core5-dumper
|
||||||
|
|
||||||
|
mount | grep -q "on $mntpoint " && umount $mntpoint
|
||||||
|
[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
|
||||||
|
|
||||||
|
mdconfig -a -t malloc -s 1g -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
|
||||||
|
newfs -b 4096 -f 512 -i 2048 md${mdstart}$part > /dev/null
|
||||||
|
mount -o async /dev/md${mdstart}$part $mntpoint || exit 1
|
||||||
|
|
||||||
|
cp /tmp/core5 $mntpoint
|
||||||
|
mkdir $mntpoint/dir
|
||||||
|
cd $mntpoint
|
||||||
|
|
||||||
|
mp2=${mntpoint}2
|
||||||
|
[ -d $mp2 ] || mkdir $mp2
|
||||||
|
mount | grep -q "on $mp2 " && umount $mp2
|
||||||
|
mount -o size=2g -t tmpfs tmpfs $mp2 || exit 1
|
||||||
|
for i in `jot 10`; do
|
||||||
|
(cd $mp2; /tmp/core5-dumper$i ) &
|
||||||
|
done
|
||||||
|
maxvnodes=`sysctl -n kern.maxvnodes`
|
||||||
|
trap "sysctl kern.maxvnodes=$maxvnodes > /dev/null" EXIT INT
|
||||||
|
$mntpoint/core5 $mntpoint/dir
|
||||||
|
wait
|
||||||
|
umount $mp2
|
||||||
|
|
||||||
|
cd $here
|
||||||
|
while mount | grep -q "on $mntpoint "; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
rm -f /tmp/core5 /tmp/core5-dumper* /tmp/core5-dumper*.core
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define MAXVNODES 4000
|
||||||
|
#define NBFILES 10000
|
||||||
|
#define PARALLEL 4
|
||||||
|
#define RTIME (10 * 60)
|
||||||
|
|
||||||
|
char *path;
|
||||||
|
|
||||||
|
void
|
||||||
|
test(int n)
|
||||||
|
{
|
||||||
|
int fd, i;
|
||||||
|
char file[80];
|
||||||
|
|
||||||
|
usleep(arc4random() % 1000);
|
||||||
|
for (i = 0; i < NBFILES; i++) {
|
||||||
|
snprintf(file, sizeof(file), "%s/f%d.%06d", path, n, i);
|
||||||
|
if ((fd = open(file, O_CREAT, 0644)) == -1) {
|
||||||
|
warn("open(%s)", file);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
for (i = 0; i < NBFILES; i++) {
|
||||||
|
snprintf(file, sizeof(file), "%s/f%d.%06d", path, n, i);
|
||||||
|
if (unlink(file) == -1)
|
||||||
|
err(1, "unlink(%s)", file);
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
time_t start;
|
||||||
|
unsigned long nv, maxvnodes;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
errx(1, "Usage: %s <path>", argv[0]);
|
||||||
|
path = argv[1];
|
||||||
|
|
||||||
|
nv = MAXVNODES;
|
||||||
|
len = sizeof(maxvnodes);
|
||||||
|
if (sysctlbyname("kern.maxvnodes", &maxvnodes, &len, &nv,
|
||||||
|
sizeof(nv)) != 0)
|
||||||
|
err(1, "sysctl kern.maxvnodes 1");
|
||||||
|
|
||||||
|
start = time(NULL);
|
||||||
|
while (time(NULL) - start < RTIME) {
|
||||||
|
for (j = 0; j < PARALLEL; j++)
|
||||||
|
if (fork() == 0)
|
||||||
|
test(j);
|
||||||
|
|
||||||
|
for (j = 0; j < PARALLEL; j++)
|
||||||
|
wait(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sysctlbyname("kern.maxvnodes", NULL, NULL, &maxvnodes,
|
||||||
|
sizeof(maxvnodes)) != 0)
|
||||||
|
err(1, "sysctl kern.maxvnodes 2");
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
49
tools/test/stress2/misc/cpuset.sh
Executable file
49
tools/test/stress2/misc/cpuset.sh
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Deadlock with one really small domain:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/mark074.txt
|
||||||
|
|
||||||
|
[ `sysctl -n vm.ndomains` -eq 1 ] && exit 0
|
||||||
|
|
||||||
|
#set -e
|
||||||
|
# * round-robin:0-4 explicit
|
||||||
|
# * round-robin:all explicit root domains
|
||||||
|
# * 0-4 implicit root policy
|
||||||
|
# * round-robin implicit root domains
|
||||||
|
# * all explicit root domains and implicit policy
|
||||||
|
|
||||||
|
for p in "round-robin:0" "round-robin:1" "round-robin:0-1" \
|
||||||
|
"round-robin:all" "0-1" round-robin all first-touch prefer:1 \
|
||||||
|
interleave; do
|
||||||
|
echo "`date +%T` cpuset -n $p"
|
||||||
|
cpuset -n $p ../misc/ufsbench.sh
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
162
tools/test/stress2/misc/credleak.sh
Executable file
162
tools/test/stress2/misc/credleak.sh
Executable file
@ -0,0 +1,162 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 Dell EMC
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Demonstrate that vfs_export() leaks M_CRED when mountd(8) is started:
|
||||||
|
# "M_CRED leaked 160".
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
pgrep -q mountd || echo "Note: mountd(8) must run for this test to fail"
|
||||||
|
here=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $here/$0 > credleak.c
|
||||||
|
mycc -o credleak -Wall -Wextra -O2 -g credleak.c || exit 1
|
||||||
|
rm -f credleak.c
|
||||||
|
|
||||||
|
mount | grep -q "on $mntpoint " && umount -f $mntpoint
|
||||||
|
mount -t tmpfs tmpfs $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
|
||||||
|
old=`vmstat -m | grep -w cred | awk '{print $2}'`
|
||||||
|
su $testuser -c "/tmp/credleak $mntpoint" &
|
||||||
|
|
||||||
|
while kill -0 $! 2>/dev/null; do
|
||||||
|
umount -f $mntpoint &&
|
||||||
|
mount -t tmpfs tmpfs $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
sleep .1
|
||||||
|
done
|
||||||
|
pkill -9 swap
|
||||||
|
wait
|
||||||
|
|
||||||
|
while pkill -9 swap; do
|
||||||
|
:
|
||||||
|
done > /dev/null 2>&1
|
||||||
|
while mount | grep $mntpoint | grep -q tmpfs; do
|
||||||
|
umount $mntpoint || sleep 1
|
||||||
|
done
|
||||||
|
[ -d "$mntpoint" ] && (cd $mntpoint && find . -delete)
|
||||||
|
rm -f /tmp/credleak
|
||||||
|
|
||||||
|
s=0
|
||||||
|
leak=$((`vmstat -m | grep -w cred | awk '{print $2}'` - old))
|
||||||
|
[ $leak -gt 10 ] && { echo "M_CRED leaked $leak"; s=1; }
|
||||||
|
exit $s
|
||||||
|
EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define LOOPS 160
|
||||||
|
#define PARALLEL 16
|
||||||
|
|
||||||
|
int nbc, nbd;
|
||||||
|
char *dir;
|
||||||
|
|
||||||
|
void
|
||||||
|
tmkdir(void)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
char d[MAXPATHLEN + 1], name[MAXPATHLEN + 1];
|
||||||
|
|
||||||
|
setproctitle(__func__);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
snprintf(name, sizeof(name), "%s/d1.%05d", dir, getpid());
|
||||||
|
if (mkdir(name, 0755) == -1) {
|
||||||
|
if (errno != ENAMETOOLONG && errno != ENOENT &&
|
||||||
|
errno != EBUSY && errno != EACCES && errno != EPERM)
|
||||||
|
warn("mkdir(%s)", name);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
for (;;) {
|
||||||
|
snprintf(d, sizeof(d), "/%d", i++);
|
||||||
|
strncat(name, d, sizeof(name) - 1);
|
||||||
|
if (mkdir(name, 0755) == -1) {
|
||||||
|
if (errno != ENAMETOOLONG && errno != ENOENT &&
|
||||||
|
errno != EBUSY && errno != EACCES && errno != EPERM)
|
||||||
|
warn("mkdir(%s)", name);
|
||||||
|
i--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nbc++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (i >= 0) {
|
||||||
|
snprintf(name, sizeof(name), "%s/d1.%05d", dir, getpid());
|
||||||
|
for (j = 0; j < i; j++) {
|
||||||
|
snprintf(d, sizeof(d), "/%d", j);
|
||||||
|
strncat(name, d, sizeof(name) - 1);
|
||||||
|
}
|
||||||
|
if (rmdir(name) == -1) {
|
||||||
|
if (errno != ENOTEMPTY && errno != ENOENT && errno !=
|
||||||
|
EBUSY)
|
||||||
|
warn("rmdir(%s)", name);
|
||||||
|
} else
|
||||||
|
nbd++;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
#if defined(TEST)
|
||||||
|
if (nbc == 0)
|
||||||
|
fprintf(stderr, "FAIL nbc = %d, nbd = %d\n", nbc, nbd);
|
||||||
|
#endif
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "Usage: %s <full path to dir>", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
dir = argv[1];
|
||||||
|
|
||||||
|
for (j = 0; j < LOOPS; j++) {
|
||||||
|
for (i = 0; i < PARALLEL; i++) {
|
||||||
|
if (fork() == 0)
|
||||||
|
tmkdir();
|
||||||
|
}
|
||||||
|
for (i = 0; i < PARALLEL; i++)
|
||||||
|
wait(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
89
tools/test/stress2/misc/crossmp.sh
Executable file
89
tools/test/stress2/misc/crossmp.sh
Executable file
@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Parallel mount and umount of file systems
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
mounts=15 # Number of parallel scripts
|
||||||
|
cont=/tmp/crossmp.continue
|
||||||
|
mdstart=$mdstart # Use md unit numbers from this point
|
||||||
|
D=$diskimage
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
touch $cont
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
[ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m
|
||||||
|
mount | grep "on ${mntpoint}$m " | grep -q md$m &&
|
||||||
|
umount ${mntpoint}$m
|
||||||
|
mdconfig -l | grep -q md$m && mdconfig -d -u $m
|
||||||
|
|
||||||
|
dd if=/dev/zero of=$D$m bs=1m count=1 status=none
|
||||||
|
mdconfig -a -t vnode -f $D$m -u $m
|
||||||
|
bsdlabel -w md$m auto
|
||||||
|
newfs $newfs_flags md${m}$part > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
|
||||||
|
# start the parallel tests
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
./$0 $m &
|
||||||
|
./$0 find &
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
mdconfig -d -u $m
|
||||||
|
rm -f $D$m
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ $1 = find ]; then
|
||||||
|
while [ -r $cont ]; do
|
||||||
|
find ${mntpoint}* -type f > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
|
||||||
|
# The test: Parallel mount and unmounts
|
||||||
|
for i in `jot 1024`; do
|
||||||
|
m=$1
|
||||||
|
mount /dev/md${m}$part ${mntpoint}$m
|
||||||
|
while mount | grep -q "on ${mntpoint}$m "; do
|
||||||
|
opt=$([ $((`date '+%s'` % 2)) -eq 0 ] &&
|
||||||
|
echo "-f")
|
||||||
|
umount $opt ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
done
|
||||||
|
rm -f $cont
|
||||||
|
fi
|
||||||
|
fi
|
104
tools/test/stress2/misc/crossmp10.sh
Executable file
104
tools/test/stress2/misc/crossmp10.sh
Executable file
@ -0,0 +1,104 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 Dell EMC Isilon
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# ext2fs parallel mount & umount test scenario
|
||||||
|
# "panic: vm_fault_hold: fault on nofault entry" seen.
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/crossmp10.txt
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
[ -z "`which mke2fs`" ] && echo "mke2fs not found" && exit 0
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
CONT=/tmp/crossmp10.continue
|
||||||
|
mounts=4 # Number of parallel scripts
|
||||||
|
size=512 # Disk size in MB
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
[ ! -d ${mntpoint}$m ] &&
|
||||||
|
{ mkdir ${mntpoint}$m; chmod 755 ${mntpoint}$m; }
|
||||||
|
mount | grep "${mntpoint}$m " | grep -q md$m && umount ${mntpoint}$m
|
||||||
|
mdconfig -l | grep -q md$m && mdconfig -d -u $m
|
||||||
|
|
||||||
|
mdconfig -a -t swap -s ${size}m -u $m
|
||||||
|
bsdlabel -w md$m auto
|
||||||
|
mke2fs -m 0 /dev/md${m}$part > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
|
||||||
|
# start the parallel tests
|
||||||
|
touch $CONT
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
./$0 $m &
|
||||||
|
./$0 find &
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
while mount | grep -q "on ${mntpoint}$m "; do
|
||||||
|
umount ${mntpoint}$m && break
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $m
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ $1 = find ]; then
|
||||||
|
while [ -f $CONT ]; do
|
||||||
|
find ${mntpoint}* -ls > /dev/null 2>&1
|
||||||
|
sleep .1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
export runRUNTIME=30s
|
||||||
|
# The test: Parallel mount and unmounts
|
||||||
|
start=`date '+%s'`
|
||||||
|
while [ $((`date '+%s'` - start)) -lt 300 ]; do
|
||||||
|
m=$1
|
||||||
|
mount -t ext2fs /dev/md${m}$part ${mntpoint}$m &&
|
||||||
|
chmod 777 ${mntpoint}$m
|
||||||
|
export RUNDIR=${mntpoint}$m/stressX
|
||||||
|
export CTRLDIR=${mntpoint}$m/stressX.control
|
||||||
|
(cd ${mntpoint}$m && find . -delete)
|
||||||
|
su $testuser -c 'cd ..; ./run.sh disk.cfg' > /dev/null 2>&1 &
|
||||||
|
|
||||||
|
sleep 2
|
||||||
|
while mount | grep -q "on ${mntpoint}$m "; do
|
||||||
|
opt=$([ `jot -r 1 0 1` -eq 0 ] && echo "-f")
|
||||||
|
umount $opt ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
[ -f $CONT ] || break 2
|
||||||
|
done
|
||||||
|
wait $!
|
||||||
|
done
|
||||||
|
rm -f $CONT
|
||||||
|
../tools/killall.sh
|
||||||
|
fi
|
||||||
|
fi
|
121
tools/test/stress2/misc/crossmp11.sh
Executable file
121
tools/test/stress2/misc/crossmp11.sh
Executable file
@ -0,0 +1,121 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2017 Dell EMC Isilon
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Copy of crossmp3.sh + elements from dfull.sh
|
||||||
|
|
||||||
|
# Live lock seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/crossmp11.txt
|
||||||
|
|
||||||
|
# umount stuck in mnt_ref seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik1002.txt
|
||||||
|
|
||||||
|
# Fixed by r319518, r319519 and r319539.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
g3=$((3 * 1024 * 1024 * 1024))
|
||||||
|
CONT=/tmp/crossmp11.continue
|
||||||
|
N=`sysctl -n hw.ncpu`
|
||||||
|
[ $N -gt 4 ] && N=4
|
||||||
|
usermem=`sysctl -n hw.usermem`
|
||||||
|
[ $usermem -gt $g3 ] && usermem=$g3
|
||||||
|
[ `sysctl -n vm.swap_total` -eq 0 ] && usermem=$((usermem/100*80))
|
||||||
|
size=$((usermem / 1024 / 1024 / N))
|
||||||
|
|
||||||
|
mounts=$N # Number of parallel scripts
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "Expect:
|
||||||
|
/mnt6: write failed, filesystem is full
|
||||||
|
/mnt6: create/symlink failed, no inodes free"
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
[ ! -d ${mntpoint}$m ] &&
|
||||||
|
{ mkdir ${mntpoint}$m; chmod 755 ${mntpoint}$m; }
|
||||||
|
mount | grep "${mntpoint}$m " | grep -q md$m && umount ${mntpoint}$m
|
||||||
|
mdconfig -l | grep -q md$m && mdconfig -d -u $m
|
||||||
|
|
||||||
|
mdconfig -a -t swap -s ${size}m -u $m
|
||||||
|
bsdlabel -w md$m auto
|
||||||
|
newfs $newfs_flags md${m}$part > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
|
||||||
|
# start the parallel tests
|
||||||
|
touch $CONT
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
./$0 $m &
|
||||||
|
./$0 find &
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
while mount | grep -q "on ${mntpoint}$m "; do
|
||||||
|
umount ${mntpoint}$m && break
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $m
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ $1 = find ]; then
|
||||||
|
while [ -f $CONT ]; do
|
||||||
|
find ${mntpoint}* -type f > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
m=$1
|
||||||
|
export runRUNTIME=20s
|
||||||
|
# The test: Parallel mount and unmounts
|
||||||
|
for i in `jot 3`; do
|
||||||
|
mount /dev/md${m}$part ${mntpoint}$m &&
|
||||||
|
chmod 777 ${mntpoint}$m
|
||||||
|
export RUNDIR=${mntpoint}$m/stressX
|
||||||
|
export CTRLDIR=${mntpoint}$m/stressX.control
|
||||||
|
(cd ${mntpoint}$m && find . -delete)
|
||||||
|
if [ -z "$KBLOCKS" ]; then
|
||||||
|
r=`df -ik ${mntpoint}$m | tail -1 | awk '{print $4,$7}'`
|
||||||
|
export KBLOCKS=`echo $r | awk '{print $1 * 10}'`
|
||||||
|
export INODES=`echo $r | awk '{print $2 * 10}'`
|
||||||
|
fi
|
||||||
|
su $testuser -c 'cd ..; ./run.sh disk.cfg' > \
|
||||||
|
/dev/null 2>&1
|
||||||
|
|
||||||
|
while mount | grep -q "on ${mntpoint}$m "; do
|
||||||
|
opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f")
|
||||||
|
umount $opt ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
[ -f $CONT ] || break 2
|
||||||
|
done
|
||||||
|
done
|
||||||
|
rm -f $CONT
|
||||||
|
fi
|
||||||
|
fi
|
86
tools/test/stress2/misc/crossmp2.sh
Executable file
86
tools/test/stress2/misc/crossmp2.sh
Executable file
@ -0,0 +1,86 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2008 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# NFS test
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
cont=/tmp/crossmp2.continue
|
||||||
|
mounts=10 # Number of parallel scripts
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
[ -z "$nfs_export" ] && exit 0
|
||||||
|
ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 ||
|
||||||
|
exit 0
|
||||||
|
touch $cont
|
||||||
|
mount -t nfs -o tcp -o nfsv3 -o retrycnt=1 -o intr,soft,timeout=1 \
|
||||||
|
-o rw $nfs_export $mntpoint || exit 0
|
||||||
|
sleep .2
|
||||||
|
umount $mntpoint
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
mp=${mntpoint}$i
|
||||||
|
[ ! -d $mp ] && mkdir $mp
|
||||||
|
mount | grep -q "$mp " && umount $mp
|
||||||
|
done
|
||||||
|
|
||||||
|
# start the parallel tests
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
./$0 $i &
|
||||||
|
./$0 find &
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ $1 = find ]; then
|
||||||
|
while [ -r $cont ]; do
|
||||||
|
find ${mntpoint}* -maxdepth 1 -type f > \
|
||||||
|
/dev/null 2>&1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
|
||||||
|
# The test: Parallel mount and unmounts
|
||||||
|
for i in `jot 128`; do
|
||||||
|
m=$1
|
||||||
|
mount -t nfs -o tcp -o nfsv3 -o retrycnt=3 \
|
||||||
|
-o intr,soft -o rw $nfs_export ${mntpoint}$m
|
||||||
|
sleep .5
|
||||||
|
opt=`[ $(( m % 2 )) -eq 0 ] && echo -f`
|
||||||
|
n=0
|
||||||
|
while mount | grep -q "${mntpoint}$m "; do
|
||||||
|
umount $opt ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
[ $((n += 1)) -gt 99 ] && umount -f \
|
||||||
|
${mntpoint}$m > /dev/null 2>&1
|
||||||
|
[ $n -gt 100 ] && exit
|
||||||
|
done
|
||||||
|
done
|
||||||
|
rm -f $cont
|
||||||
|
fi
|
||||||
|
fi
|
108
tools/test/stress2/misc/crossmp3.sh
Executable file
108
tools/test/stress2/misc/crossmp3.sh
Executable file
@ -0,0 +1,108 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Parallel mount and umount of file systems
|
||||||
|
# "panic: Bad link elm 0xfffff8052a20cc00 prev->next != elm" seen:
|
||||||
|
# http://people.freebsd.org/~pho/stress/log/crossmp3.txt
|
||||||
|
# Fixed in r269853
|
||||||
|
|
||||||
|
# panic: softdep_waitidle: work added after flush:
|
||||||
|
# http://people.freebsd.org/~pho/stress/log/crossmp3-2.txt, fixed by r273967.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
CONT=/tmp/crossmp3.continue
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
N=`sysctl -n hw.ncpu`
|
||||||
|
usermem=`sysctl -n hw.usermem`
|
||||||
|
[ `sysctl -n vm.swap_total` -eq 0 ] && usermem=$((usermem / 2))
|
||||||
|
size=$((usermem / 1024 / 1024 / N))
|
||||||
|
echo "Using $N memory disks of size $size MB."
|
||||||
|
|
||||||
|
mounts=$N # Number of parallel scripts
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
[ ! -d ${mntpoint}$m ] &&
|
||||||
|
{ mkdir ${mntpoint}$m; chmod 755 ${mntpoint}$m; }
|
||||||
|
mount | grep "${mntpoint}$m " | grep -q md$m &&
|
||||||
|
umount ${mntpoint}$m
|
||||||
|
mdconfig -l | grep -q md$m && mdconfig -d -u $m
|
||||||
|
|
||||||
|
mdconfig -a -t swap -s ${size}m -u $m
|
||||||
|
bsdlabel -w md$m auto
|
||||||
|
newfs $newfs_flags md${m}$part > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
|
||||||
|
# start the parallel tests
|
||||||
|
touch $CONT
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
./$0 $m &
|
||||||
|
./$0 find &
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
while mount | grep -q "on ${mntpoint}$m "; do
|
||||||
|
umount ${mntpoint}$m && break
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $m
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ $1 = find ]; then
|
||||||
|
while [ -f $CONT ]; do
|
||||||
|
find ${mntpoint}* -type f > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
export runRUNTIME=20s
|
||||||
|
# The test: Parallel mount and unmounts
|
||||||
|
for i in `jot 3`; do
|
||||||
|
m=$1
|
||||||
|
mount /dev/md${m}$part ${mntpoint}$m &&
|
||||||
|
chmod 777 ${mntpoint}$m
|
||||||
|
export RUNDIR=${mntpoint}$m/stressX
|
||||||
|
export CTRLDIR=${mntpoint}$m/stressX.control
|
||||||
|
(cd ${mntpoint}$m && find . -delete)
|
||||||
|
su $testuser -c 'cd ..; ./run.sh disk.cfg' > \
|
||||||
|
/dev/null 2>&1
|
||||||
|
|
||||||
|
while mount | grep -q "on ${mntpoint}$m "; do
|
||||||
|
opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f")
|
||||||
|
umount $opt ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
[ -f $CONT ] || break 2
|
||||||
|
done
|
||||||
|
done
|
||||||
|
rm -f $CONT
|
||||||
|
fi
|
||||||
|
fi
|
107
tools/test/stress2/misc/crossmp4.sh
Executable file
107
tools/test/stress2/misc/crossmp4.sh
Executable file
@ -0,0 +1,107 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Parallel mount and umount of file systems. Nullfs version.
|
||||||
|
|
||||||
|
# "panic: Lock (lockmgr) null not locked @ kern/vfs_default.c:523." seen.
|
||||||
|
# http://people.freebsd.org/~pho/stress/log/kostik698.txt
|
||||||
|
# Fixed by r269708.
|
||||||
|
|
||||||
|
# Not fixed: https://people.freebsd.org/~pho/stress/log/kostik798.txt
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik856.txt
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
N=`sysctl -n hw.ncpu`
|
||||||
|
usermem=`sysctl -n hw.usermem`
|
||||||
|
[ `swapinfo | wc -l` -eq 1 ] && usermem=$((usermem/100*80))
|
||||||
|
size=$((usermem / 1024 / 1024 - 2))
|
||||||
|
|
||||||
|
CONT=/tmp/crossmp4.continue
|
||||||
|
mounts=$N # Number of parallel scripts
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
mount | grep "$mntpoint" | grep -q md && umount $mntpoint
|
||||||
|
mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart
|
||||||
|
|
||||||
|
mdconfig -a -t swap -s ${size}m -u $mdstart
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null 2>&1
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint
|
||||||
|
|
||||||
|
# start the parallel tests
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
./$0 $m &
|
||||||
|
./$0 find &
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
while mount | grep -q "on $mntpoint "; do
|
||||||
|
umount $mntpoint > /dev/null 2>&1 || sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
touch $CONT
|
||||||
|
if [ $1 = find ]; then
|
||||||
|
while [ -f $CONT ]; do
|
||||||
|
find ${mntpoint}* -type f > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
m=$1
|
||||||
|
set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'`
|
||||||
|
export KBLOCKS=$(($1 / N))
|
||||||
|
export INODES=$(($2 / N))
|
||||||
|
export runRUNTIME=1m
|
||||||
|
export INCARNATIONS=4
|
||||||
|
# The test: Parallel mount and unmounts
|
||||||
|
for i in `jot 4`; do
|
||||||
|
[ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m
|
||||||
|
mount -t nullfs $mntpoint ${mntpoint}$m
|
||||||
|
mkdir -p ${mntpoint}$m/$m
|
||||||
|
chmod 777 ${mntpoint}$m/$m
|
||||||
|
export RUNDIR=${mntpoint}$m/$m/stressX
|
||||||
|
export CTRLDIR=${mntpoint}$m/$m/stressX.control
|
||||||
|
(cd ${mntpoint}$m/$m && find . -delete)
|
||||||
|
su $testuser -c 'cd ..; ./run.sh disk.cfg' > \
|
||||||
|
/dev/null 2>&1 &
|
||||||
|
sleep 30
|
||||||
|
|
||||||
|
while mount | grep -q "on ${mntpoint}$m "; do
|
||||||
|
opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f")
|
||||||
|
umount $opt ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
done
|
||||||
|
rm -f $CONT
|
||||||
|
fi
|
||||||
|
fi
|
95
tools/test/stress2/misc/crossmp5.sh
Executable file
95
tools/test/stress2/misc/crossmp5.sh
Executable file
@ -0,0 +1,95 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Variation of crossmp3.sh
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
N=`sysctl -n hw.ncpu`
|
||||||
|
usermem=`sysctl -n hw.usermem`
|
||||||
|
[ `swapinfo | wc -l` -eq 1 ] && usermem=$((usermem/100*80))
|
||||||
|
size=$((usermem / 1024 / 1024 / N))
|
||||||
|
|
||||||
|
mounts=$N # Number of parallel scripts
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
[ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m
|
||||||
|
mount | grep "${mntpoint}$m " | grep -q md$m &&
|
||||||
|
umount ${mntpoint}$m
|
||||||
|
mdconfig -l | grep -q md$m && mdconfig -d -u $m
|
||||||
|
|
||||||
|
mdconfig -a -t swap -s ${size}m -u $m
|
||||||
|
bsdlabel -w md$m auto
|
||||||
|
newfs $newfs_flags md${m}$part > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
|
||||||
|
# start the parallel tests
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
./$0 $m &
|
||||||
|
./$0 find &
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
mdconfig -d -u $m
|
||||||
|
rm -f $D$m
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
touch /tmp/crossmp.continue
|
||||||
|
if [ $1 = find ]; then
|
||||||
|
while [ -f /tmp/crossmp.continue ]; do
|
||||||
|
find ${mntpoint}* -type f > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# The test: Parallel mount and unmount
|
||||||
|
m=$1
|
||||||
|
for i in `jot 200`; do
|
||||||
|
mount /dev/md${m}$part ${mntpoint}$m
|
||||||
|
chmod 777 ${mntpoint}$m
|
||||||
|
l=`jot -r 1 65535`
|
||||||
|
dd if=/dev/zero of=$mntpoint/$i bs=$l count=100 \
|
||||||
|
status=none
|
||||||
|
rm -f $mntpoint/$i
|
||||||
|
|
||||||
|
while mount | grep -q "on ${mntpoint}$m "; do
|
||||||
|
opt=$([ $((`date '+%s'` % 2)) -eq 0 ] &&
|
||||||
|
echo "-f")
|
||||||
|
umount $opt ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
done
|
||||||
|
rm -f /tmp/crossmp.continue
|
||||||
|
fi
|
||||||
|
fi
|
103
tools/test/stress2/misc/crossmp6.sh
Executable file
103
tools/test/stress2/misc/crossmp6.sh
Executable file
@ -0,0 +1,103 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Copy of crossmp2.sh: NFS test, with lockf(1) added.
|
||||||
|
# "panic: vinvalbuf: dirty bufs" seen.
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/crossmp6.txt
|
||||||
|
# Fixed by r283968.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
[ -z "$nfs_export" ] && exit 0
|
||||||
|
ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 ||
|
||||||
|
exit 0
|
||||||
|
pgrep -q lockd || { echo "lockd not running."; exit 0; }
|
||||||
|
|
||||||
|
CONT=/tmp/crossmp6.continue
|
||||||
|
mounts=10 # Number of parallel scripts
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
[ -z "$nfs_export" ] && exit 0
|
||||||
|
ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 ||
|
||||||
|
exit 0
|
||||||
|
mount -t nfs -o tcp -o nfsv3 -o retrycnt=1 -o soft,timeout=1 \
|
||||||
|
-o rw $nfs_export $mntpoint || exit 0
|
||||||
|
umount $mntpoint
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
mp=${mntpoint}$i
|
||||||
|
[ ! -d $mp ] && mkdir $mp
|
||||||
|
mount | grep -qw "$mp" && umount $mp
|
||||||
|
done
|
||||||
|
|
||||||
|
# start the parallel tests
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
./$0 $i &
|
||||||
|
./$0 find $i &
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
mount -t nfs -o tcp -o nfsv3 -o retrycnt=1 -o soft,timeout=1 \
|
||||||
|
-o rw $nfs_export $mntpoint || exit 0
|
||||||
|
sleep .5
|
||||||
|
rm -f $mntpoint/$0.*
|
||||||
|
umount $mntpoint
|
||||||
|
rm -f $mntpoint*/$0.*
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ $1 = find ]; then
|
||||||
|
for i in `jot 128`; do
|
||||||
|
find ${mntpoint}* -maxdepth 1 -type f > \
|
||||||
|
/dev/null 2>&1
|
||||||
|
(lockf -t 10 ${mntpoint}$2/$0.$$.$i sleep 1 &) > \
|
||||||
|
/dev/null 2>&1
|
||||||
|
[ -f $CONT ] || break
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
else
|
||||||
|
# The test: Parallel mount and unmounts
|
||||||
|
start=`date '+%s'`
|
||||||
|
while [ $((`date '+%s'` - start)) -lt 300 ]; do
|
||||||
|
m=$1
|
||||||
|
mount -t nfs -o tcp -o nfsv3 -o retrycnt=3 \
|
||||||
|
-o soft -o rw $nfs_export ${mntpoint}$m
|
||||||
|
sleep .5
|
||||||
|
opt=`[ $(( m % 2 )) -eq 0 ] && echo -f`
|
||||||
|
n=0
|
||||||
|
while mount | grep -qw ${mntpoint}$m; do
|
||||||
|
umount $opt ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
n=$((n + 1))
|
||||||
|
[ $n -gt 99 ] && umount -f ${mntpoint}$m > \
|
||||||
|
/dev/null 2>&1
|
||||||
|
[ $n -gt 100 ] && exit
|
||||||
|
done
|
||||||
|
done
|
||||||
|
rm -f $CONT
|
||||||
|
fi
|
||||||
|
fi
|
100
tools/test/stress2/misc/crossmp7.sh
Executable file
100
tools/test/stress2/misc/crossmp7.sh
Executable file
@ -0,0 +1,100 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Parallel mount and umount of zfs file systems.
|
||||||
|
|
||||||
|
# Page fault seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/avg002.txt
|
||||||
|
# Fixed by r309090.
|
||||||
|
|
||||||
|
# Page fault seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/crossmp7.txt
|
||||||
|
# Fixed by r352437.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
[ `uname -m` = "i386" ] && exit 0
|
||||||
|
[ `sysctl -n kern.kstack_pages` -lt 4 ] && exit 0
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
mounts=15 # Number of parallel scripts
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
kldstat -v | grep -q zfs.ko || { kldload zfs.ko ||
|
||||||
|
exit 0; loaded=1; }
|
||||||
|
zpool list | egrep -q "^stress2_tank" && zpool destroy stress2_tank
|
||||||
|
|
||||||
|
u1=$mdstart
|
||||||
|
u2=$((u1 + 1))
|
||||||
|
u3=$((u2 + 1))
|
||||||
|
|
||||||
|
[ -c /dev/md$u1 ] && mdconfig -d -u $u1
|
||||||
|
[ -c /dev/md$u2 ] && mdconfig -d -u $u2
|
||||||
|
[ -c /dev/md$u3 ] && mdconfig -d -u $u3
|
||||||
|
|
||||||
|
mdconfig -s 512m -u $u1
|
||||||
|
mdconfig -s 512m -u $u2
|
||||||
|
mdconfig -s 512m -u $u3
|
||||||
|
|
||||||
|
zpool create stress2_tank raidz md$u1 md$u2 md$u3
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
zfs create stress2_tank/test$i
|
||||||
|
zfs umount stress2_tank/test$i
|
||||||
|
done
|
||||||
|
|
||||||
|
# start the parallel tests
|
||||||
|
touch /tmp/crossmp7.continue
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
./$0 $i &
|
||||||
|
./$0 find &
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
zpool destroy stress2_tank
|
||||||
|
[ -n "$loaded" ] && kldunload zfs.ko
|
||||||
|
mdconfig -d -u $u1
|
||||||
|
mdconfig -d -u $u2
|
||||||
|
mdconfig -d -u $u3
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ $1 = find ]; then
|
||||||
|
while [ -f /tmp/crossmp7.continue ]; do
|
||||||
|
find /stress2_tank -type f > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
# The test: Parallel mount and unmounts
|
||||||
|
m=$1
|
||||||
|
for i in `jot 1024`; do
|
||||||
|
zfs mount stress2_tank/test$m
|
||||||
|
zfs umount -f stress2_tank/test$m
|
||||||
|
done 2>/dev/null
|
||||||
|
rm -f /tmp/crossmp7.continue
|
||||||
|
fi
|
||||||
|
fi
|
125
tools/test/stress2/misc/crossmp8.sh
Executable file
125
tools/test/stress2/misc/crossmp8.sh
Executable file
@ -0,0 +1,125 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Variation of crossmp3.sh. fifos and sockets added to load.
|
||||||
|
# Not really a cross mount point test, but a test of the old
|
||||||
|
# non-directory use of the vnode v_un union.
|
||||||
|
# mckusick@ suggested using fifos for this test.
|
||||||
|
|
||||||
|
# "panic: mtx_lock() of spin mutex @ ../kern/vfs_subr.c:512" seen.
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/crossmp8.txt
|
||||||
|
# Fixed by r291671.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
CONT=/tmp/crossmp8.continue
|
||||||
|
N=`sysctl -n hw.ncpu`
|
||||||
|
usermem=`sysctl -n hw.usermem`
|
||||||
|
[ `swapinfo | wc -l` -eq 1 ] && usermem=$((usermem/100*80))
|
||||||
|
size=$((usermem / 1024 / 1024 / N))
|
||||||
|
|
||||||
|
mounts=$N # Number of parallel scripts
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
oldmx=`sysctl -n kern.maxvnodes`
|
||||||
|
trap "sysctl kern.maxvnodes=$oldmx > /dev/null" EXIT SIGINT
|
||||||
|
sysctl kern.maxvnodes=3072 > /dev/null
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$((i + mdstart - 1))
|
||||||
|
[ ! -d ${mntpoint}$m ] &&
|
||||||
|
{ mkdir ${mntpoint}$m; chmod 755 ${mntpoint}$m; }
|
||||||
|
mount | grep "${mntpoint}$m " | grep -q md$m &&
|
||||||
|
umount ${mntpoint}$m
|
||||||
|
mdconfig -l | grep -q md$m && mdconfig -d -u $m
|
||||||
|
|
||||||
|
mdconfig -a -t swap -s ${size}m -u $m
|
||||||
|
bsdlabel -w md$m auto
|
||||||
|
newfs md${m}$part > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
|
||||||
|
# start the parallel tests
|
||||||
|
touch $CONT
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$((i + mdstart - 1))
|
||||||
|
./$0 $m &
|
||||||
|
./$0 find &
|
||||||
|
done
|
||||||
|
sleep 60
|
||||||
|
rm -f $CONT
|
||||||
|
../tools/killall.sh
|
||||||
|
wait
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$((i + mdstart - 1))
|
||||||
|
while mount | grep -q "on ${mntpoint}$m "; do
|
||||||
|
umount ${mntpoint}$m && break
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $m
|
||||||
|
done
|
||||||
|
./cleanup.sh
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ $1 = find ]; then
|
||||||
|
while [ -f $CONT ]; do
|
||||||
|
find ${mntpoint}* -maxdepth 1 -ls > /dev/null 2>&1
|
||||||
|
sleep .1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
export RUNTIME=15s
|
||||||
|
export runRUNTIME=15s
|
||||||
|
# The test: Parallel mount and unmounts
|
||||||
|
start=`date '+%s'`
|
||||||
|
while [ $((`date '+%s'` - start)) -lt 300 ]; do
|
||||||
|
m=$1
|
||||||
|
mount /dev/md${m}$part ${mntpoint}$m &&
|
||||||
|
chmod 777 ${mntpoint}$m
|
||||||
|
export RUNDIR=${mntpoint}$m/stressX
|
||||||
|
export CTRLDIR=${mntpoint}$m/stressX.control
|
||||||
|
export mkfifoLOAD=80
|
||||||
|
export socketLOAD=80
|
||||||
|
export TP="
|
||||||
|
testcases/mkfifo/mkfifo
|
||||||
|
testcases/mkdir/mkdir
|
||||||
|
"
|
||||||
|
(cd ${mntpoint}$m && find . -delete)
|
||||||
|
su $testuser -c 'cd ..; ./testcases/run/run $TP' > \
|
||||||
|
/dev/null 2>&1
|
||||||
|
|
||||||
|
while mount | grep -q "on ${mntpoint}$m "; do
|
||||||
|
opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f")
|
||||||
|
umount $opt ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
[ -f $CONT ] || break 2
|
||||||
|
done
|
||||||
|
done
|
||||||
|
rm -f $CONT
|
||||||
|
fi
|
||||||
|
fi
|
90
tools/test/stress2/misc/crossmp9.sh
Executable file
90
tools/test/stress2/misc/crossmp9.sh
Executable file
@ -0,0 +1,90 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 Dell EMC Isilon
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Parallel mount and umount of file systems, while using getfsstat(2) via
|
||||||
|
# mount(8).
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
mounts=15 # Number of parallel scripts
|
||||||
|
cont=/tmp/crossmp.continue
|
||||||
|
mdstart=$mdstart # Use md unit numbers from this point
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
touch $cont
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
[ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m
|
||||||
|
mount | grep "${mntpoint}$m " | grep -q md$m &&
|
||||||
|
umount ${mntpoint}$m
|
||||||
|
mdconfig -l | grep -q md$m && mdconfig -d -u $m
|
||||||
|
|
||||||
|
mdconfig -a -t swap -s 512m -u $m
|
||||||
|
bsdlabel -w md$m auto
|
||||||
|
newfs $newfs_flags md${m}$part > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
|
||||||
|
# start the parallel tests
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
./$0 $m &
|
||||||
|
./$0 find $m &
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
|
||||||
|
for i in `jot $mounts`; do
|
||||||
|
m=$(( i + mdstart - 1 ))
|
||||||
|
mdconfig -d -u $m
|
||||||
|
rm -f $D$m
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ $1 = find ]; then
|
||||||
|
m=$2
|
||||||
|
while [ -r $cont ]; do
|
||||||
|
df ${mntpoint}$m
|
||||||
|
mount
|
||||||
|
done > /dev/null 2>&1
|
||||||
|
else
|
||||||
|
|
||||||
|
# The test: Parallel mount and unmounts
|
||||||
|
start=`date '+%s'`
|
||||||
|
while [ $((`date '+%s'` - start)) -lt 300 ] ; do
|
||||||
|
m=$1
|
||||||
|
mount /dev/md${m}$part ${mntpoint}$m
|
||||||
|
while mount | grep -qw ${mntpoint}$m; do
|
||||||
|
opt=$([ $((`date '+%s'` % 2)) -eq 0 ] &&
|
||||||
|
echo "-f")
|
||||||
|
umount $opt ${mntpoint}$m > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
done
|
||||||
|
rm -f $cont
|
||||||
|
fi
|
||||||
|
fi
|
87
tools/test/stress2/misc/dangling.sh
Executable file
87
tools/test/stress2/misc/dangling.sh
Executable file
@ -0,0 +1,87 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
# "panic: softdep_deallocate_dependencies: dangling deps" seen.
|
||||||
|
# "panic: softdep_write_inodeblock: indirect pointer #0 mismatch" seen.
|
||||||
|
# http://people.freebsd.org/~pho/stress/log/dangling.txt
|
||||||
|
# http://people.freebsd.org/~pho/stress/log/dangling2.txt
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/kostik1101.txt
|
||||||
|
|
||||||
|
# Test scenario seems optimized for 4 CPUs.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint
|
||||||
|
mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart
|
||||||
|
|
||||||
|
mdconfig -a -t swap -s 4g -u $mdstart || exit 1
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mntpoint || exit 1
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
|
||||||
|
export runRUNTIME=4m
|
||||||
|
export RUNDIR=$mntpoint/stressX
|
||||||
|
set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'`
|
||||||
|
export KBLOCKS=$(($1 / 4))
|
||||||
|
export INODES=$(($2 / 4))
|
||||||
|
|
||||||
|
export symlinkHOG=1
|
||||||
|
export rwHOG=1
|
||||||
|
export mkdirHOG=1
|
||||||
|
|
||||||
|
export LOAD=100
|
||||||
|
export symlinkLOAD=100
|
||||||
|
export rwLOAD=100
|
||||||
|
export mkdirLOAD=100
|
||||||
|
export TESTPROGS="
|
||||||
|
testcases/symlink/symlink
|
||||||
|
testcases/fts/fts
|
||||||
|
testcases/mkdir/mkdir
|
||||||
|
testcases/rw/rw
|
||||||
|
"
|
||||||
|
|
||||||
|
for i in `jot 10`; do
|
||||||
|
su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > \
|
||||||
|
/dev/null 2>&1 &
|
||||||
|
sleep 60
|
||||||
|
kill $!
|
||||||
|
../tools/killall.sh > /dev/null 2>&1
|
||||||
|
../tools/killall.sh > /dev/null 2>&1
|
||||||
|
wait
|
||||||
|
done
|
||||||
|
|
||||||
|
s=0
|
||||||
|
for i in `jot 6`; do
|
||||||
|
umount $mntpoint && break || sleep 10
|
||||||
|
done
|
||||||
|
[ $i -eq 6 ] && s=1
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
exit $s
|
96
tools/test/stress2/misc/datagram.sh
Executable file
96
tools/test/stress2/misc/datagram.sh
Executable file
@ -0,0 +1,96 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# UNIX datagram socket test.
|
||||||
|
|
||||||
|
# "panic: mutex unp not owned at ../../../kern/uipc_usrreq.c:879" seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/datagram.txt
|
||||||
|
# Fixed by r334756.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
cat > datagram.c <<EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
char *filename = "/tmp/datagram.socket";
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void) {
|
||||||
|
|
||||||
|
struct sockaddr_un addr;
|
||||||
|
int bytes, sockfd;
|
||||||
|
char buf[1024];
|
||||||
|
|
||||||
|
unlink(filename);
|
||||||
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
addr.sun_family = AF_UNIX;
|
||||||
|
strncpy(addr.sun_path, filename, 104);
|
||||||
|
|
||||||
|
if ((sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
|
||||||
|
err(1, "socket");
|
||||||
|
|
||||||
|
if (bind(sockfd, (struct sockaddr *) &addr,
|
||||||
|
sizeof(addr)) == -1)
|
||||||
|
err(1, "bind");
|
||||||
|
|
||||||
|
if (connect(sockfd, (struct sockaddr *) &addr,
|
||||||
|
sizeof(addr)) == -1)
|
||||||
|
err(1, "connect");
|
||||||
|
|
||||||
|
bytes = read(sockfd, buf, sizeof(buf));
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mycc -o datagram -Wall -Wextra -O2 -g datagram.c || exit 1
|
||||||
|
rm datagram.c
|
||||||
|
|
||||||
|
./datagram &
|
||||||
|
sleep 1
|
||||||
|
kill $!
|
||||||
|
wait
|
||||||
|
|
||||||
|
rm -f datagram /tmp/datagram.socket
|
||||||
|
exit 0
|
104
tools/test/stress2/misc/datagram2.sh
Executable file
104
tools/test/stress2/misc/datagram2.sh
Executable file
@ -0,0 +1,104 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# UNIX datagram socket test.
|
||||||
|
|
||||||
|
# "panic: mutex unp not owned at ../../../kern/uipc_usrreq.c:879" seen.
|
||||||
|
# Fixed by r334756.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
cat > datagram2.c <<EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
char *filename = "/tmp/datagram2.socket";
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void) {
|
||||||
|
|
||||||
|
struct message { struct cmsghdr msg_hdr; int fd; } m;
|
||||||
|
struct msghdr mh;
|
||||||
|
struct sockaddr_un addr;
|
||||||
|
ssize_t len;
|
||||||
|
int sockfd;
|
||||||
|
|
||||||
|
unlink(filename);
|
||||||
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
addr.sun_family = AF_UNIX;
|
||||||
|
strncpy(addr.sun_path, filename, 104);
|
||||||
|
|
||||||
|
if ((sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
|
||||||
|
err(1, "socket");
|
||||||
|
|
||||||
|
if (bind(sockfd, (struct sockaddr *) &addr,
|
||||||
|
sizeof(addr)) == -1)
|
||||||
|
err(1, "bind");
|
||||||
|
|
||||||
|
if (connect(sockfd, (struct sockaddr *) &addr,
|
||||||
|
sizeof(addr)) == -1)
|
||||||
|
err(1, "connect");
|
||||||
|
|
||||||
|
bzero(&mh, sizeof(mh));
|
||||||
|
bzero(&m, sizeof(m));
|
||||||
|
mh.msg_control = &m;
|
||||||
|
mh.msg_controllen = sizeof(m);
|
||||||
|
m.msg_hdr.cmsg_len = sizeof(m);
|
||||||
|
m.msg_hdr.cmsg_level = SOL_SOCKET;
|
||||||
|
m.msg_hdr.cmsg_type = SCM_RIGHTS;
|
||||||
|
m.fd = sockfd;
|
||||||
|
len = sendmsg(sockfd, &mh, 0);
|
||||||
|
if (len < 0)
|
||||||
|
err(1, "sendmsg");
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cc -o datagram2 -Wall -Wextra -O2 -g datagram2.c || exit 1
|
||||||
|
rm -f datagram2.c datagram2.socket
|
||||||
|
|
||||||
|
./datagram2
|
||||||
|
|
||||||
|
rm datagram2 datagram2.socket
|
||||||
|
exit 0
|
106
tools/test/stress2/misc/datagram3.sh
Executable file
106
tools/test/stress2/misc/datagram3.sh
Executable file
@ -0,0 +1,106 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 Dell EMC Isilon
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# UNIX datagram socket test.
|
||||||
|
|
||||||
|
# "panic: mutex unp not owned at ../../../kern/uipc_usrreq.c:879" seen.
|
||||||
|
# Fixed by r334756.
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
cat > datagram3.c <<EOF
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
char *filename = "/tmp/datagram3.socket";
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void) {
|
||||||
|
|
||||||
|
struct message { struct cmsghdr msg_hdr; int fd; } m;
|
||||||
|
struct msghdr mh;
|
||||||
|
struct sockaddr_un addr;
|
||||||
|
ssize_t len;
|
||||||
|
int i, sockfd;
|
||||||
|
|
||||||
|
unlink(filename);
|
||||||
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
addr.sun_family = AF_UNIX;
|
||||||
|
strncpy(addr.sun_path, filename, 104);
|
||||||
|
|
||||||
|
if ((sockfd = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
|
||||||
|
err(1, "socket");
|
||||||
|
|
||||||
|
if (bind(sockfd, (struct sockaddr *) &addr,
|
||||||
|
sizeof(addr)) == -1)
|
||||||
|
err(1, "bind");
|
||||||
|
|
||||||
|
if (connect(sockfd, (struct sockaddr *) &addr,
|
||||||
|
sizeof(addr)) == -1)
|
||||||
|
err(1, "connect");
|
||||||
|
|
||||||
|
for (i = 0; i < 32; i++) {
|
||||||
|
bzero(&mh, sizeof(mh));
|
||||||
|
bzero(&m, sizeof(m));
|
||||||
|
mh.msg_control = &m;
|
||||||
|
mh.msg_controllen = sizeof(m);
|
||||||
|
m.msg_hdr.cmsg_len = sizeof(m);
|
||||||
|
m.msg_hdr.cmsg_level = SOL_SOCKET;
|
||||||
|
m.msg_hdr.cmsg_type = SCM_RIGHTS;
|
||||||
|
m.fd = sockfd;
|
||||||
|
len = sendmsg(sockfd, &mh, 0);
|
||||||
|
if (len < 0)
|
||||||
|
err(1, "sendmsg");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mycc -o datagram3 -Wall -Wextra -O2 -g datagram3.c || exit 1
|
||||||
|
rm -f datagram3.c datagram3.socket
|
||||||
|
|
||||||
|
./datagram3
|
||||||
|
|
||||||
|
rm datagram3 datagram3.socket
|
||||||
|
exit 0
|
230
tools/test/stress2/misc/datamove.sh
Executable file
230
tools/test/stress2/misc/datamove.sh
Executable file
@ -0,0 +1,230 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# There is a well-known problem in FreeBSD, caused by allowing page faults
|
||||||
|
# while doing filesystem data move to or from userspace during read(2) and
|
||||||
|
# write(2). The issue is that if the userspace address being read or write
|
||||||
|
# from/to is backed by the mapping of the same file we are doing i/o to,
|
||||||
|
# we deadlock.
|
||||||
|
|
||||||
|
# Test scenario by ups
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $here/$0 > datamove.c
|
||||||
|
mycc -o datamove -Wall datamove.c
|
||||||
|
rm -f datamove.c
|
||||||
|
|
||||||
|
n=5
|
||||||
|
old=`sysctl vm.old_msync | awk '{print $NF}'`
|
||||||
|
sysctl vm.old_msync=1
|
||||||
|
for i in `jot $n`; do
|
||||||
|
mkdir -p /tmp/datamove.dir.$i
|
||||||
|
cd /tmp/datamove.dir.$i
|
||||||
|
/tmp/datamove &
|
||||||
|
done
|
||||||
|
cd /tmp
|
||||||
|
for i in `jot $n`; do
|
||||||
|
wait
|
||||||
|
done
|
||||||
|
for i in `jot $n`; do
|
||||||
|
rm -rf /tmp/datamove.dir.$i
|
||||||
|
done
|
||||||
|
sysctl vm.old_msync=$old
|
||||||
|
|
||||||
|
rm -rf /tmp/datamove
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2006, Stephan Uphoff <ups@freebsd.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice unmodified, this list of conditions, and the following
|
||||||
|
* disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
int prepareFile(char* filename,int* fdp);
|
||||||
|
int mapBuffer(char** bufferp,int fd1,int fd2);
|
||||||
|
int startIO(int fd,char *buffer);
|
||||||
|
|
||||||
|
int pagesize;
|
||||||
|
|
||||||
|
#define FILESIZE (32*1024)
|
||||||
|
char wbuffer[FILESIZE];
|
||||||
|
|
||||||
|
/* Create a FILESIZE sized file - then remove file data from the cache*/
|
||||||
|
int prepareFile(char* filename,int* fdp)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int len;
|
||||||
|
int status;
|
||||||
|
void *addr;
|
||||||
|
|
||||||
|
fd = open(filename,O_CREAT | O_TRUNC | O_RDWR,S_IRWXU);
|
||||||
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
perror("Creating file");
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = write(fd,wbuffer,FILESIZE);
|
||||||
|
if (len < 0)
|
||||||
|
{
|
||||||
|
perror("Write failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = fsync(fd);
|
||||||
|
if (status != 0)
|
||||||
|
{
|
||||||
|
perror("fsync failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr = mmap(NULL,FILESIZE, PROT_READ | PROT_WRITE , MAP_SHARED, fd, 0);
|
||||||
|
if (addr == MAP_FAILED)
|
||||||
|
{
|
||||||
|
perror("Mmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = msync(addr,FILESIZE,MS_INVALIDATE | MS_SYNC);
|
||||||
|
if (status != 0)
|
||||||
|
{
|
||||||
|
perror("Msync failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
munmap(addr,FILESIZE);
|
||||||
|
|
||||||
|
*fdp = fd;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* mmap a 2 page buffer - first page is from fd1, second page from fd2 */
|
||||||
|
int mapBuffer(char** bufferp,int fd1,int fd2)
|
||||||
|
{
|
||||||
|
void* addr;
|
||||||
|
char *buffer;
|
||||||
|
|
||||||
|
addr = mmap(NULL,pagesize*2, PROT_READ | PROT_WRITE , MAP_SHARED, fd1, 0);
|
||||||
|
if (addr == MAP_FAILED)
|
||||||
|
{
|
||||||
|
perror("Mmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = addr;
|
||||||
|
addr = mmap(buffer + pagesize,pagesize, PROT_READ | PROT_WRITE , MAP_FIXED |
|
||||||
|
MAP_SHARED, fd2, 0);
|
||||||
|
|
||||||
|
if (addr == MAP_FAILED)
|
||||||
|
{
|
||||||
|
perror("Mmap2 failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
*bufferp = buffer;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int startIO(int fd,char *buffer)
|
||||||
|
{
|
||||||
|
ssize_t len;
|
||||||
|
len = write(fd,buffer,2*pagesize);
|
||||||
|
if (len == -1)
|
||||||
|
{
|
||||||
|
perror("write failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc,char *argv[],char *envp[])
|
||||||
|
{
|
||||||
|
|
||||||
|
int fdA,fdB,fdDelayA,fdDelayB;
|
||||||
|
int status;
|
||||||
|
char *bufferA,*bufferB;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
pagesize = getpagesize();
|
||||||
|
|
||||||
|
if ((prepareFile("A",&fdA))
|
||||||
|
|| (prepareFile("B",&fdB))
|
||||||
|
|| (prepareFile("DelayA",&fdDelayA))
|
||||||
|
|| (prepareFile("DelayB",&fdDelayB))
|
||||||
|
|| (mapBuffer(&bufferA,fdDelayA,fdB))
|
||||||
|
|| (mapBuffer(&bufferB,fdDelayB,fdA)))
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if (pid == 0)
|
||||||
|
{
|
||||||
|
status = startIO(fdA,bufferA);
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pid == -1)
|
||||||
|
{
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
status = startIO(fdB,bufferB);
|
||||||
|
exit(status);
|
||||||
|
|
||||||
|
}
|
244
tools/test/stress2/misc/datamove2.sh
Executable file
244
tools/test/stress2/misc/datamove2.sh
Executable file
@ -0,0 +1,244 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Variation of the datamove.sh scenario by not using "sysctl vm.old_msync=1"
|
||||||
|
|
||||||
|
# Deadlock seen:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/numa042.txt
|
||||||
|
|
||||||
|
# Test scenario by ups
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $here/$0 > datamove2.c
|
||||||
|
mycc -o datamove2 -Wall datamove2.c
|
||||||
|
rm -f datamove2.c
|
||||||
|
|
||||||
|
for i in `jot 2`; do
|
||||||
|
$here/../testcases/swap/swap -t 5m -i 100 -h &
|
||||||
|
sleep 1
|
||||||
|
/tmp/datamove2 || { echo FAIL; r=1; }
|
||||||
|
while pkill -9 swap; do :; done
|
||||||
|
[ -n "$r" ] && break
|
||||||
|
done
|
||||||
|
rm -rf /tmp/datamove2
|
||||||
|
exit $r
|
||||||
|
EOF
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2006, Stephan Uphoff <ups@freebsd.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice unmodified, this list of conditions, and the following
|
||||||
|
* disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int prepareFile(char *filename, int *fdp);
|
||||||
|
int mapBuffer (char **bufferp, int fd1, int fd2);
|
||||||
|
int startIO (int fd, char *buffer);
|
||||||
|
|
||||||
|
int pagesize;
|
||||||
|
|
||||||
|
#define FILESIZE (32*1024)
|
||||||
|
char wbuffer [FILESIZE];
|
||||||
|
|
||||||
|
/* Create a FILESIZE sized file - then remove file data from the cache */
|
||||||
|
int
|
||||||
|
prepareFile(char *filename, int *fdp)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int len;
|
||||||
|
int status;
|
||||||
|
void *addr;
|
||||||
|
|
||||||
|
fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
|
||||||
|
if (fd == -1) {
|
||||||
|
perror("Creating file");
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
len = write(fd, wbuffer, FILESIZE);
|
||||||
|
if (len < 0) {
|
||||||
|
perror("Write failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
status = fsync(fd);
|
||||||
|
if (status != 0) {
|
||||||
|
perror("fsync failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
addr = mmap(NULL, FILESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
perror("Mmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
status = msync(addr, FILESIZE, MS_INVALIDATE | MS_SYNC);
|
||||||
|
if (status != 0) {
|
||||||
|
perror("Msync failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (munmap(addr, FILESIZE) == -1) {
|
||||||
|
perror("munmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*fdp = fd;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* mmap a 2 page buffer - first page is from fd1, second page from fd2 */
|
||||||
|
int
|
||||||
|
mapBuffer(char **bufferp, int fd1, int fd2)
|
||||||
|
{
|
||||||
|
void *addr;
|
||||||
|
char *buffer;
|
||||||
|
|
||||||
|
addr = mmap(NULL, pagesize * 2, PROT_READ | PROT_WRITE, MAP_SHARED, fd1, 0);
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
perror("Mmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
buffer = addr;
|
||||||
|
addr = mmap(buffer + pagesize, pagesize, PROT_READ | PROT_WRITE, MAP_FIXED |
|
||||||
|
MAP_SHARED, fd2, 0);
|
||||||
|
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
perror("Mmap2 failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
*bufferp = buffer;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
unmapBuffer(char *bufferp)
|
||||||
|
{
|
||||||
|
if (munmap(bufferp, pagesize * 2) == -1)
|
||||||
|
err(1, "unmap 1. buffer");
|
||||||
|
/*
|
||||||
|
The following unmaps something random, which could trigger:
|
||||||
|
Program received signal SIGSEGV, Segmentation fault.
|
||||||
|
free (cp=0x28070000) at /usr/src/libexec/rtld-elf/malloc.c:311
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (munmap(bufferp + pagesize * 2, pagesize * 2) == -1)
|
||||||
|
err(1, "unmap 2. buffer");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
startIO(int fd, char *buffer)
|
||||||
|
{
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
|
len = write(fd, buffer, 2 * pagesize);
|
||||||
|
if (len == -1) {
|
||||||
|
perror("write failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[], char *envp[])
|
||||||
|
{
|
||||||
|
|
||||||
|
int fdA, fdB, fdDelayA, fdDelayB;
|
||||||
|
int status;
|
||||||
|
int i;
|
||||||
|
char *bufferA, *bufferB;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
pagesize = getpagesize();
|
||||||
|
|
||||||
|
for (i = 0; i < 1000; i++) {
|
||||||
|
if ((prepareFile("A", &fdA))
|
||||||
|
|| (prepareFile("B", &fdB))
|
||||||
|
|| (prepareFile("DelayA", &fdDelayA))
|
||||||
|
|| (prepareFile("DelayB", &fdDelayB))
|
||||||
|
|| (mapBuffer(&bufferA, fdDelayA, fdB))
|
||||||
|
|| (mapBuffer(&bufferB, fdDelayB, fdA)))
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if (pid == 0) {
|
||||||
|
status = startIO(fdA, bufferA);
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
if (pid == -1) {
|
||||||
|
perror("fork");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
status = startIO(fdB, bufferB);
|
||||||
|
if (wait(&status) == -1)
|
||||||
|
err(1, "wait");
|
||||||
|
|
||||||
|
close(fdA);
|
||||||
|
close(fdB);
|
||||||
|
close(fdDelayA);
|
||||||
|
close(fdDelayB);
|
||||||
|
unmapBuffer(bufferA);
|
||||||
|
unmapBuffer(bufferB);
|
||||||
|
unlink("A");
|
||||||
|
unlink("B");
|
||||||
|
unlink("DelayA");
|
||||||
|
unlink("DelayB");
|
||||||
|
}
|
||||||
|
exit(status);
|
||||||
|
|
||||||
|
}
|
241
tools/test/stress2/misc/datamove3.sh
Executable file
241
tools/test/stress2/misc/datamove3.sh
Executable file
@ -0,0 +1,241 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2009 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Threaded variation of datamove.sh
|
||||||
|
|
||||||
|
# Based on a test scenario by ups and suggestions by kib
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $here/$0 > datamove3.c
|
||||||
|
mycc -o datamove3 -Wall datamove3.c -lpthread
|
||||||
|
rm -f datamove3.c
|
||||||
|
|
||||||
|
n=5
|
||||||
|
old=`sysctl vm.old_msync | awk '{print $NF}'`
|
||||||
|
sysctl vm.old_msync=1
|
||||||
|
for i in `jot $n`; do
|
||||||
|
mkdir -p /tmp/datamove3.dir.$i
|
||||||
|
cd /tmp/datamove3.dir.$i
|
||||||
|
/tmp/datamove3 &
|
||||||
|
done
|
||||||
|
cd /tmp
|
||||||
|
for i in `jot $n`; do
|
||||||
|
wait
|
||||||
|
done
|
||||||
|
for i in `jot $n`; do
|
||||||
|
rm -rf /tmp/datamove3.dir.$i
|
||||||
|
done
|
||||||
|
sysctl vm.old_msync=$old
|
||||||
|
|
||||||
|
rm -rf /tmp/datamove3
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2006, Stephan Uphoff <ups@freebsd.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice unmodified, this list of conditions, and the following
|
||||||
|
* disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
struct args {
|
||||||
|
char *bp;
|
||||||
|
int fd1;
|
||||||
|
int fd2;
|
||||||
|
} a[2];
|
||||||
|
|
||||||
|
int prepareFile(char *, int *);
|
||||||
|
void * mapBuffer(void *);
|
||||||
|
int startIO(int, char *);
|
||||||
|
|
||||||
|
int pagesize;
|
||||||
|
|
||||||
|
#define FILESIZE (32*1024)
|
||||||
|
char wbuffer [FILESIZE];
|
||||||
|
|
||||||
|
/* Create a FILESIZE sized file - then remove file data from the cache */
|
||||||
|
int
|
||||||
|
prepareFile(char *filename, int *fdp)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int len;
|
||||||
|
int status;
|
||||||
|
void *addr;
|
||||||
|
|
||||||
|
fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
|
||||||
|
if (fd == -1) {
|
||||||
|
perror("Creating file");
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
len = write(fd, wbuffer, FILESIZE);
|
||||||
|
if (len < 0) {
|
||||||
|
perror("Write failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
status = fsync(fd);
|
||||||
|
if (status != 0) {
|
||||||
|
perror("fsync failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
addr = mmap(NULL, FILESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
perror("Mmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
status = msync(addr, FILESIZE, MS_INVALIDATE | MS_SYNC);
|
||||||
|
if (status != 0) {
|
||||||
|
perror("Msync failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
munmap(addr, FILESIZE);
|
||||||
|
|
||||||
|
*fdp = fd;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* mmap a 2 page buffer - first page is from fd1, second page from fd2 */
|
||||||
|
void *
|
||||||
|
mapBuffer(void *ar)
|
||||||
|
{
|
||||||
|
void *addr;
|
||||||
|
char *buffer;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = (int )ar;
|
||||||
|
addr = mmap(NULL, pagesize * 2, PROT_READ | PROT_WRITE, MAP_SHARED, a[i].fd1, 0);
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
err(1, "Mmap failed");
|
||||||
|
}
|
||||||
|
buffer = addr;
|
||||||
|
addr = mmap(buffer + pagesize, pagesize, PROT_READ | PROT_WRITE, MAP_FIXED |
|
||||||
|
MAP_SHARED, a[i].fd2, 0);
|
||||||
|
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
err(1, "Mmap2 failed");
|
||||||
|
}
|
||||||
|
a[i].bp = buffer;
|
||||||
|
sleep(1);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
startIO(int fd, char *buffer)
|
||||||
|
{
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
|
len = write(fd, buffer, 2 * pagesize);
|
||||||
|
if (len == -1) {
|
||||||
|
warn("startIO(%d, %p): write failed", fd, buffer);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[], char *envp[])
|
||||||
|
{
|
||||||
|
|
||||||
|
int fdA, fdB, fdDelayA, fdDelayB;
|
||||||
|
int r, status;
|
||||||
|
char *bufferA, *bufferB;
|
||||||
|
pid_t pid;
|
||||||
|
pthread_t threads[2];
|
||||||
|
|
||||||
|
pagesize = getpagesize();
|
||||||
|
|
||||||
|
if ((prepareFile("A", &fdA))
|
||||||
|
|| (prepareFile("B", &fdB))
|
||||||
|
|| (prepareFile("DelayA", &fdDelayA))
|
||||||
|
|| (prepareFile("DelayB", &fdDelayB)))
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
a[0].fd1 = fdDelayA;
|
||||||
|
a[0].fd2 = fdB;
|
||||||
|
|
||||||
|
a[1].fd1 = fdDelayB;
|
||||||
|
a[1].fd2 = fdA;
|
||||||
|
|
||||||
|
if ((r = pthread_create(&threads[0], NULL, mapBuffer, (void *)0)) != 0)
|
||||||
|
errc(1, r, "pthread_create()");
|
||||||
|
if ((r = pthread_create(&threads[1], NULL, mapBuffer, (void *)1)) != 0)
|
||||||
|
errc(1, r, "pthread_create()");
|
||||||
|
|
||||||
|
while (a[0].bp == NULL || a[1].bp == NULL)
|
||||||
|
pthread_yield();
|
||||||
|
|
||||||
|
bufferA = a[0].bp;
|
||||||
|
bufferB = a[1].bp;
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if (pid == 0) {
|
||||||
|
status = startIO(fdA, bufferA);
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
if (pid == -1) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
status = startIO(fdB, bufferB);
|
||||||
|
exit(status);
|
||||||
|
|
||||||
|
}
|
251
tools/test/stress2/misc/datamove4.sh
Executable file
251
tools/test/stress2/misc/datamove4.sh
Executable file
@ -0,0 +1,251 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2012 Peter Holm <pho@FreeBSD.org>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Variation of the datamove2.sh, using TMPFS
|
||||||
|
# Deadlock seen
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/datamove4.txt
|
||||||
|
|
||||||
|
# panic: elf32_putnote: Note type 10 changed as we read it (2236 > 2220)...
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/datamove4-2.txt
|
||||||
|
# Fixed by r288944.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $here/$0 > datamove4.c
|
||||||
|
mycc -o datamove4 -Wall -Wextra -O2 -g datamove4.c
|
||||||
|
rm -f datamove4.c
|
||||||
|
|
||||||
|
mount | grep -q "$mntpoint " && umount $mntpoint
|
||||||
|
mount -t tmpfs tmpfs $mntpoint
|
||||||
|
chmod 777 $mntpoint
|
||||||
|
|
||||||
|
for i in `jot 5`; do
|
||||||
|
su $testuser -c "cd $mntpoint; /tmp/datamove4"
|
||||||
|
done
|
||||||
|
while mount | grep -q $mntpoint; do
|
||||||
|
umount -f $mntpoint > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf /tmp/datamove4
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2006, Stephan Uphoff <ups@freebsd.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice unmodified, this list of conditions, and the following
|
||||||
|
* disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int prepareFile(char *filename, int *fdp);
|
||||||
|
int mapBuffer (char **bufferp, int fd1, int fd2);
|
||||||
|
int startIO (int fd, char *buffer);
|
||||||
|
|
||||||
|
int pagesize;
|
||||||
|
|
||||||
|
#define FILESIZE (32*1024)
|
||||||
|
char wbuffer [FILESIZE];
|
||||||
|
|
||||||
|
/* Create a FILESIZE sized file - then remove file data from the cache */
|
||||||
|
int
|
||||||
|
prepareFile(char *filename, int *fdp)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int len;
|
||||||
|
int status;
|
||||||
|
void *addr;
|
||||||
|
|
||||||
|
fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
|
||||||
|
if (fd == -1) {
|
||||||
|
perror(filename);
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
len = write(fd, wbuffer, FILESIZE);
|
||||||
|
if (len < 0) {
|
||||||
|
perror("Write failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
status = fsync(fd);
|
||||||
|
if (status != 0) {
|
||||||
|
perror("fsync failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
addr = mmap(NULL, FILESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
perror("Mmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
status = msync(addr, FILESIZE, MS_INVALIDATE | MS_SYNC);
|
||||||
|
if (status != 0) {
|
||||||
|
perror("Msync failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (munmap(addr, FILESIZE) == -1) {
|
||||||
|
perror("munmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*fdp = fd;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* mmap a 2 page buffer - first page is from fd1, second page from fd2 */
|
||||||
|
int
|
||||||
|
mapBuffer(char **bufferp, int fd1, int fd2)
|
||||||
|
{
|
||||||
|
void *addr;
|
||||||
|
char *buffer;
|
||||||
|
|
||||||
|
addr = mmap(NULL, pagesize * 2, PROT_READ | PROT_WRITE, MAP_SHARED, fd1, 0);
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
perror("Mmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
buffer = addr;
|
||||||
|
addr = mmap(buffer + pagesize, pagesize, PROT_READ | PROT_WRITE, MAP_FIXED |
|
||||||
|
MAP_SHARED, fd2, 0);
|
||||||
|
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
perror("Mmap2 failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
*bufferp = buffer;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
unmapBuffer(char *bufferp)
|
||||||
|
{
|
||||||
|
if (munmap(bufferp, pagesize * 2) == -1)
|
||||||
|
err(1, "unmap 1. buffer");
|
||||||
|
/*
|
||||||
|
The following unmaps something random, which could trigger:
|
||||||
|
Program received signal SIGSEGV, Segmentation fault.
|
||||||
|
free (cp=0x28070000) at /usr/src/libexec/rtld-elf/malloc.c:311
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (munmap(bufferp + pagesize * 2, pagesize * 2) == -1)
|
||||||
|
err(1, "unmap 2. buffer");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
startIO(int fd, char *buffer)
|
||||||
|
{
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
|
len = write(fd, buffer, 2 * pagesize);
|
||||||
|
if (len == -1) {
|
||||||
|
perror("write failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
|
||||||
|
int fdA, fdB, fdDelayA, fdDelayB;
|
||||||
|
int status;
|
||||||
|
int i;
|
||||||
|
char *bufferA, *bufferB;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
pagesize = getpagesize();
|
||||||
|
|
||||||
|
for (i = 0; i < 1000; i++) {
|
||||||
|
if ((prepareFile("A", &fdA))
|
||||||
|
|| (prepareFile("B", &fdB))
|
||||||
|
|| (prepareFile("DelayA", &fdDelayA))
|
||||||
|
|| (prepareFile("DelayB", &fdDelayB))
|
||||||
|
|| (mapBuffer(&bufferA, fdDelayA, fdB))
|
||||||
|
|| (mapBuffer(&bufferB, fdDelayB, fdA)))
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if (pid == 0) {
|
||||||
|
status = startIO(fdA, bufferA);
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
if (pid == -1) {
|
||||||
|
perror("fork");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
status = startIO(fdB, bufferB);
|
||||||
|
if (wait(&status) == -1)
|
||||||
|
err(1, "wait");
|
||||||
|
|
||||||
|
close(fdA);
|
||||||
|
close(fdB);
|
||||||
|
close(fdDelayA);
|
||||||
|
close(fdDelayB);
|
||||||
|
unmapBuffer(bufferA);
|
||||||
|
unmapBuffer(bufferB);
|
||||||
|
unlink("A");
|
||||||
|
unlink("B");
|
||||||
|
unlink("DelayA");
|
||||||
|
unlink("DelayB");
|
||||||
|
}
|
||||||
|
exit(status);
|
||||||
|
|
||||||
|
}
|
262
tools/test/stress2/misc/datamove5.sh
Executable file
262
tools/test/stress2/misc/datamove5.sh
Executable file
@ -0,0 +1,262 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Variation of the datamove2.sh, using NULLFS
|
||||||
|
# No problems seen.
|
||||||
|
|
||||||
|
[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
cd /tmp
|
||||||
|
sed '1,/^EOF/d' < $here/$0 > datamove5.c
|
||||||
|
mycc -o datamove5 -Wall -Wextra -O2 -g datamove5.c
|
||||||
|
rm -f datamove5.c
|
||||||
|
|
||||||
|
mp1=$mntpoint
|
||||||
|
mp2=${mntpoint}2
|
||||||
|
[ -d $mp2 ] || mkdir $mp2
|
||||||
|
|
||||||
|
mount | grep -wq $mp2 && umount $mp2
|
||||||
|
mount | grep -wq $mp1 && umount $mp1
|
||||||
|
mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart
|
||||||
|
mdconfig -a -t swap -s 2g -u $mdstart || exit 1
|
||||||
|
bsdlabel -w md$mdstart auto
|
||||||
|
newfs $newfs_flags md${mdstart}$part > /dev/null
|
||||||
|
mount /dev/md${mdstart}$part $mp1
|
||||||
|
|
||||||
|
mount -t nullfs $opt $mp1 $mp2
|
||||||
|
chmod 777 $mp2
|
||||||
|
|
||||||
|
for i in `jot 5`; do
|
||||||
|
su $testuser -c "cd $mp2; /tmp/datamove5"
|
||||||
|
done
|
||||||
|
|
||||||
|
while mount | grep -wq $mp2; do
|
||||||
|
umount $mp2 || sleep 1
|
||||||
|
done
|
||||||
|
while mount | grep $mp1 | grep -q /dev/md; do
|
||||||
|
umount $mp1 || sleep 1
|
||||||
|
done
|
||||||
|
mdconfig -d -u $mdstart
|
||||||
|
|
||||||
|
rm -rf /tmp/datamove5
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2006, Stephan Uphoff <ups@freebsd.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice unmodified, this list of conditions, and the following
|
||||||
|
* disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int prepareFile(char *filename, int *fdp);
|
||||||
|
int mapBuffer (char **bufferp, int fd1, int fd2);
|
||||||
|
int startIO (int fd, char *buffer);
|
||||||
|
|
||||||
|
int pagesize;
|
||||||
|
|
||||||
|
#define FILESIZE (32*1024)
|
||||||
|
char wbuffer [FILESIZE];
|
||||||
|
|
||||||
|
/* Create a FILESIZE sized file - then remove file data from the cache */
|
||||||
|
int
|
||||||
|
prepareFile(char *filename, int *fdp)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
int len;
|
||||||
|
int status;
|
||||||
|
void *addr;
|
||||||
|
|
||||||
|
fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU);
|
||||||
|
if (fd == -1) {
|
||||||
|
perror(filename);
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
len = write(fd, wbuffer, FILESIZE);
|
||||||
|
if (len < 0) {
|
||||||
|
perror("Write failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
status = fsync(fd);
|
||||||
|
if (status != 0) {
|
||||||
|
perror("fsync failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
addr = mmap(NULL, FILESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
perror("Mmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
status = msync(addr, FILESIZE, MS_INVALIDATE | MS_SYNC);
|
||||||
|
if (status != 0) {
|
||||||
|
perror("Msync failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (munmap(addr, FILESIZE) == -1) {
|
||||||
|
perror("munmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*fdp = fd;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* mmap a 2 page buffer - first page is from fd1, second page from fd2 */
|
||||||
|
int
|
||||||
|
mapBuffer(char **bufferp, int fd1, int fd2)
|
||||||
|
{
|
||||||
|
void *addr;
|
||||||
|
char *buffer;
|
||||||
|
|
||||||
|
addr = mmap(NULL, pagesize * 2, PROT_READ | PROT_WRITE, MAP_SHARED, fd1, 0);
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
perror("Mmap failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
buffer = addr;
|
||||||
|
addr = mmap(buffer + pagesize, pagesize, PROT_READ | PROT_WRITE, MAP_FIXED |
|
||||||
|
MAP_SHARED, fd2, 0);
|
||||||
|
|
||||||
|
if (addr == MAP_FAILED) {
|
||||||
|
perror("Mmap2 failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
*bufferp = buffer;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
unmapBuffer(char *bufferp)
|
||||||
|
{
|
||||||
|
if (munmap(bufferp, pagesize * 2) == -1)
|
||||||
|
err(1, "unmap 1. buffer");
|
||||||
|
/*
|
||||||
|
The following unmaps something random, which could trigger:
|
||||||
|
Program received signal SIGSEGV, Segmentation fault.
|
||||||
|
free (cp=0x28070000) at /usr/src/libexec/rtld-elf/malloc.c:311
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (munmap(bufferp + pagesize * 2, pagesize * 2) == -1)
|
||||||
|
err(1, "unmap 2. buffer");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
startIO(int fd, char *buffer)
|
||||||
|
{
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
|
len = write(fd, buffer, 2 * pagesize);
|
||||||
|
if (len == -1) {
|
||||||
|
perror("write failed");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
|
||||||
|
int fdA, fdB, fdDelayA, fdDelayB;
|
||||||
|
int status;
|
||||||
|
int i;
|
||||||
|
char *bufferA, *bufferB;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
pagesize = getpagesize();
|
||||||
|
|
||||||
|
for (i = 0; i < 1000; i++) {
|
||||||
|
if ((prepareFile("A", &fdA))
|
||||||
|
|| (prepareFile("B", &fdB))
|
||||||
|
|| (prepareFile("DelayA", &fdDelayA))
|
||||||
|
|| (prepareFile("DelayB", &fdDelayB))
|
||||||
|
|| (mapBuffer(&bufferA, fdDelayA, fdB))
|
||||||
|
|| (mapBuffer(&bufferB, fdDelayB, fdA)))
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if (pid == 0) {
|
||||||
|
status = startIO(fdA, bufferA);
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
if (pid == -1) {
|
||||||
|
perror("fork");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
status = startIO(fdB, bufferB);
|
||||||
|
if (wait(&status) == -1)
|
||||||
|
err(1, "wait");
|
||||||
|
|
||||||
|
close(fdA);
|
||||||
|
close(fdB);
|
||||||
|
close(fdDelayA);
|
||||||
|
close(fdDelayB);
|
||||||
|
unmapBuffer(bufferA);
|
||||||
|
unmapBuffer(bufferB);
|
||||||
|
unlink("A");
|
||||||
|
unlink("B");
|
||||||
|
unlink("DelayA");
|
||||||
|
unlink("DelayB");
|
||||||
|
}
|
||||||
|
exit(status);
|
||||||
|
|
||||||
|
}
|
178
tools/test/stress2/misc/db.sh
Executable file
178
tools/test/stress2/misc/db.sh
Executable file
@ -0,0 +1,178 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015 EMC Corp.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Demonstrate resource starvation using msync(2).
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
dir=/tmp
|
||||||
|
odir=`pwd`
|
||||||
|
cd $dir
|
||||||
|
sed '1,/^EOF/d' < $odir/$0 > $dir/db.c
|
||||||
|
mycc -o db -Wall -Wextra -O0 -g db.c -lpthread || exit 1
|
||||||
|
rm -f db.c
|
||||||
|
cd $odir
|
||||||
|
|
||||||
|
dd if=/dev/zero of=$diskimage bs=1m count=10 status=none
|
||||||
|
|
||||||
|
/tmp/db $diskimage &
|
||||||
|
|
||||||
|
start=`date '+%s'`
|
||||||
|
ls -l $diskimage > /dev/null # Will wait for more than 90 seconds
|
||||||
|
[ `date '+%s'` -gt $((start + 90)) ] && fail="yes"
|
||||||
|
wait
|
||||||
|
e=$((`date +%s` - start))
|
||||||
|
[ $fail ] &&
|
||||||
|
echo "Time for a ls is $((e / 60)) minutes $((e % 60)) seconds"
|
||||||
|
rm -f /tmp/db $diskimage
|
||||||
|
#[ $fail ] && exit 1 || exit 0 # Known issue
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
EOF
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <pthread_np.h>
|
||||||
|
#define __NP__
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
size_t len;
|
||||||
|
void *p;
|
||||||
|
int wthreads;
|
||||||
|
|
||||||
|
#define BZ 128 /* buffer size */
|
||||||
|
#define RUNTIME 180 /* runtime for test */
|
||||||
|
#define RTHREADS 64 /* reader threads */
|
||||||
|
#define WTHREADS 64 /* writer threads */
|
||||||
|
|
||||||
|
void *
|
||||||
|
wt(void *arg __unused)
|
||||||
|
{
|
||||||
|
time_t start;
|
||||||
|
int64_t pos;
|
||||||
|
void *c;
|
||||||
|
int r;
|
||||||
|
char buf[BZ];
|
||||||
|
|
||||||
|
#ifdef __NP__
|
||||||
|
pthread_set_name_np(pthread_self(), __func__);
|
||||||
|
#endif
|
||||||
|
if ((r = pthread_mutex_lock(&mutex)) != 0)
|
||||||
|
errc(1, r, "pthread_mutex_lock");
|
||||||
|
wthreads++;
|
||||||
|
if ((r = pthread_mutex_unlock(&mutex)) != 0)
|
||||||
|
errc(1, r, "pthread_mutex_unlock");
|
||||||
|
|
||||||
|
start = time(NULL);
|
||||||
|
while (time(NULL) - start < RUNTIME) {
|
||||||
|
pos = arc4random() % (len / BZ);
|
||||||
|
pos = pos * BZ;
|
||||||
|
c = p + pos;
|
||||||
|
bcopy(buf, c, BZ);
|
||||||
|
c = (void *)trunc_page((unsigned long)c);
|
||||||
|
if (msync((void *)c, round_page(BZ), MS_SYNC) == -1)
|
||||||
|
err(1, "msync(%p)", c);
|
||||||
|
usleep(10000 + arc4random() % 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((r = pthread_mutex_lock(&mutex)) != 0)
|
||||||
|
errc(1, r, "pthread_mutex_lock");
|
||||||
|
wthreads--;
|
||||||
|
if ((r = pthread_mutex_unlock(&mutex)) != 0)
|
||||||
|
errc(1, r, "pthread_mutex_unlock");
|
||||||
|
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
rt(void *arg __unused)
|
||||||
|
{
|
||||||
|
int64_t pos;
|
||||||
|
char buf[BZ], *c;
|
||||||
|
|
||||||
|
#ifdef __NP__
|
||||||
|
pthread_set_name_np(pthread_self(), __func__);
|
||||||
|
#endif
|
||||||
|
c = p;
|
||||||
|
do {
|
||||||
|
pos = arc4random() % (len / BZ);
|
||||||
|
pos = pos * BZ;
|
||||||
|
bcopy(&c[pos], buf, BZ);
|
||||||
|
usleep(10000 + arc4random() % 1000);
|
||||||
|
} while (wthreads != 0);
|
||||||
|
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
pthread_t cp[RTHREADS + WTHREADS];
|
||||||
|
struct stat st;
|
||||||
|
int fd, i, j, rc;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
errx(1, "Usage: %s <file>", argv[0]);
|
||||||
|
if ((fd = open(argv[1], O_RDWR)) == -1)
|
||||||
|
err(1, "open %s", argv[1]);
|
||||||
|
if (fstat(fd, &st) == -1)
|
||||||
|
err(1, "stat");
|
||||||
|
len = round_page(st.st_size);
|
||||||
|
p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
if ((void *)p == MAP_FAILED)
|
||||||
|
err(1, "mmap");
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
for (j = 0; j < WTHREADS; j++) {
|
||||||
|
if ((rc = pthread_create(&cp[i++], NULL, wt, NULL)) != 0)
|
||||||
|
errc(1, rc, "pthread_create()");
|
||||||
|
}
|
||||||
|
usleep(100);
|
||||||
|
for (j = 0; j < RTHREADS; j++) {
|
||||||
|
if ((rc = pthread_create(&cp[i++], NULL, rt, NULL)) != 0)
|
||||||
|
errc(1, rc, "pthread_create()");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < RTHREADS + WTHREADS; j++)
|
||||||
|
pthread_join(cp[--i], NULL);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
64
tools/test/stress2/misc/dd.sh
Executable file
64
tools/test/stress2/misc/dd.sh
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2017 Dell EMC Isilon
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
# SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Watchdog fired:
|
||||||
|
# https://people.freebsd.org/~pho/stress/log/mark013.txt
|
||||||
|
# Fixed by: r327213
|
||||||
|
|
||||||
|
# watchdogd: https://people.freebsd.org/~pho/stress/log/kostik1245.txt
|
||||||
|
|
||||||
|
. ../default.cfg
|
||||||
|
|
||||||
|
outputfile=$RUNDIR/dd.outputfile
|
||||||
|
(cd ../testcases/swap; ./swap -t 30m -i 20) > /dev/null 2>&1 &
|
||||||
|
trap "rm -f ${outputfile}*" EXIT INT
|
||||||
|
N=2
|
||||||
|
NCPU=`sysctl -n hw.ncpu`
|
||||||
|
s=0
|
||||||
|
size=512
|
||||||
|
start=`date '+%s'`
|
||||||
|
while [ $((`date '+%s'` - start)) -lt 720 ]; do
|
||||||
|
pids=""
|
||||||
|
for i in `jot $N`; do
|
||||||
|
dd if=/dev/zero of=${outputfile}$i bs=1m count=$size &
|
||||||
|
pids="$pids $!"
|
||||||
|
done > /dev/null 2>&1
|
||||||
|
for pid in $pids; do
|
||||||
|
wait $pid
|
||||||
|
s=$?
|
||||||
|
[ $s -ne 0 ] && break 2
|
||||||
|
done
|
||||||
|
N=$((N * 2))
|
||||||
|
rm -f ${outputfile}*
|
||||||
|
[ $N -gt $((NCPU * 2)) ] && break
|
||||||
|
done
|
||||||
|
|
||||||
|
while pgrep -q swap; do
|
||||||
|
pkill -9 swap
|
||||||
|
done
|
||||||
|
exit $s
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user