Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Nov 2024 09:47:20 GMT
From:      Peter Holm <pho@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 43778a593f92 - main - stress2: Added zfs test scenarios
Message-ID:  <202411180947.4AI9lKZU027851@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by pho:

URL: https://cgit.FreeBSD.org/src/commit/?id=43778a593f92dc09cedee69b47b6486dd579900b

commit 43778a593f92dc09cedee69b47b6486dd579900b
Author:     Peter Holm <pho@FreeBSD.org>
AuthorDate: 2024-11-18 09:46:28 +0000
Commit:     Peter Holm <pho@FreeBSD.org>
CommitDate: 2024-11-18 09:46:28 +0000

    stress2: Added zfs test scenarios
---
 tools/test/stress2/misc/zfs15.sh |  88 ++++++++++++++++++++++++++++++++
 tools/test/stress2/misc/zfs16.sh | 105 +++++++++++++++++++++++++++++++++++++++
 tools/test/stress2/misc/zfs17.sh |  74 +++++++++++++++++++++++++++
 tools/test/stress2/misc/zfs19.sh |  72 +++++++++++++++++++++++++++
 4 files changed, 339 insertions(+)

diff --git a/tools/test/stress2/misc/zfs15.sh b/tools/test/stress2/misc/zfs15.sh
new file mode 100755
index 000000000000..b40474507517
--- /dev/null
+++ b/tools/test/stress2/misc/zfs15.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+# Test scenario suggestion by: markj@
+
+[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
+kldstat -v | grep -q zfs.ko  || { kldload zfs.ko; loaded=1; } ||
+    exit 0
+
+. ../default.cfg
+
+here=`pwd`
+level=`jot -r 1 1 3`	# Redundancy levels
+mp1=/stress2_tank/test
+s=0
+u1=$mdstart
+u2=$((u1 + 1))
+u3=$((u1 + 2))
+u4=$((u1 + 3))
+u5=$((u1 + 4))
+
+set -e
+mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1
+mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2
+mdconfig -l | grep -q md$u3 && mdconfig -d -u $u3
+mdconfig -l | grep -q md$u4 && mdconfig -d -u $u4
+mdconfig -l | grep -q md$u5 && mdconfig -d -u $u5
+
+mdconfig -s 512m -u $u1
+mdconfig -s 512m -u $u2
+mdconfig -s 512m -u $u3
+mdconfig -s 512m -u $u4
+mdconfig -s 512m -u $u5
+
+zpool list | egrep -q "^stress2_tank" && zpool destroy stress2_tank
+[ -d /stress2_tank ] && rm -rf /stress2_tank
+zpool create stress2_tank raidz$level md$u1 md$u2 md$u3 md$u4
+zfs create stress2_tank/test
+set +e
+
+export RUNDIR=/stress2_tank/test/stressX
+export runRUNTIME=5m
+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/mkfifo/mkfifo
+testcases/dirnprename/dirnprename
+testcases/dirrename/dirrename
+testcases/swap/swap
+"
+
+(cd ..; ./testcases/run/run $TESTPROGS > /dev/null 2>&1) &
+
+sleep 60
+echo "zpool attach stress2_tank raidz$level-0 md$u5"
+zpool attach stress2_tank raidz$level-0 md$u5
+sleep 30
+zfs snapshot stress2_tank/test@1
+wait
+
+while zpool status | grep -q "in progress"; do
+	sleep 5
+done
+zpool scrub stress2_tank
+zpool status | grep -q "errors: No known data errors" ||
+    { zpool status; s=1; }
+
+zfs umount stress2_tank/test
+zfs destroy -r stress2_tank
+zpool destroy stress2_tank
+
+mdconfig -d -u $u1
+mdconfig -d -u $u2
+mdconfig -d -u $u3
+mdconfig -d -u $u4
+mdconfig -d -u $u5
+[ -n "$loaded" ] && kldunload zfs.ko
+exit $s
diff --git a/tools/test/stress2/misc/zfs16.sh b/tools/test/stress2/misc/zfs16.sh
new file mode 100755
index 000000000000..258bf9ea4799
--- /dev/null
+++ b/tools/test/stress2/misc/zfs16.sh
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+# No problems seen
+
+[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
+kldstat -v | grep -q zfs.ko  || { kldload zfs.ko; loaded=1; } ||
+    exit 0
+
+. ../default.cfg
+
+here=`pwd`
+cd /tmp
+sed '1,/^EOF/d' < $here/datamove.sh > zfs16.c
+mycc -o zfs16 -Wall -O0 -g zfs16.c || exit 1
+rm -f zfs16.c
+
+mp1=/stress2_tank/test
+u1=$mdstart
+u2=$((u1 + 1))
+
+set -eu
+mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1
+mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2
+
+mdconfig -s 2g -u $u1
+mdconfig -s 2g -u $u2
+
+zpool list | egrep -q "^stress2_tank" && zpool destroy stress2_tank
+[ -d /stress2_tank ] && rm -rf /stress2_tank
+zpool create stress2_tank md$u1 md$u2
+zfs create stress2_tank/test
+set +e
+
+(cd $here/../testcases/swap; ./swap -t 2m -i 20 -l 100 -h > /dev/null) &
+sleep 2
+cd $mp1
+while pgrep -q swap; do
+	/tmp/zfs16; s=$?
+	rm -f /stress2_tank/test/*
+done
+cd $here
+while pkill swap; do sleep 1; done
+wait
+
+zfs umount stress2_tank/test
+zfs destroy -r stress2_tank
+zpool destroy stress2_tank
+mdconfig -d -u $u1
+mdconfig -d -u $u2
+rm -f /tmp/zfs16
+set +u
+[ $loaded ] && kldunload zfs.ko
+exit $s
+EOF
+#include <sys/types.h>
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/param.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#define SIZ  (500UL * 1024 * 1024)
+
+int
+main(int argc __unused, char *argv[])
+{
+	off_t hole;
+	size_t len;
+	int fd;
+	char *p, *path;
+
+	len = SIZ;
+
+	path = argv[1];
+	if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1)
+		err(1,"open()");
+	if (ftruncate(fd, len) == -1)
+		err(1, "ftruncate");
+	if ((p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) ==
+			MAP_FAILED) {
+		if (errno == ENOMEM)
+			return (1);
+		err(1, "mmap(1)");
+	}
+	p[1 * 1024] = 1;
+	p[2 * 1024] = 1;
+	p[4 * 1024] = 1;
+
+	if (msync(p, len, MS_SYNC | MS_INVALIDATE) == -1)
+		err(1, "msync()");
+
+	if ((hole = lseek(fd, 0, SEEK_HOLE)) == -1)
+		err(1, "lseek(SEEK_HOLE)");
+	if (hole != SIZ)
+		printf("--> hole = %jd, file size=%jd\n",
+		    (intmax_t)hole, (intmax_t)SIZ);
+	close(fd);
+
+	return (hole == SIZ ? 0 : 1);
+}
diff --git a/tools/test/stress2/misc/zfs17.sh b/tools/test/stress2/misc/zfs17.sh
new file mode 100755
index 000000000000..d20e39765afa
--- /dev/null
+++ b/tools/test/stress2/misc/zfs17.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+#
+# Copyright (c) 2024 Peter Holm <pho@FreeBSD.org>
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+
+# Copy from nullfs over zfs to nullfs over ufs
+# Test scenario description by: mjguzik
+
+# Page fault seen:
+# https://people.freebsd.org/~pho/stress/log/log0498.txt
+
+[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
+[ `sysctl -n kern.kstack_pages` -lt 4 ] && exit 0
+
+. ../default.cfg
+
+set -u
+kldstat -v | grep -q zfs.ko  || { kldload zfs.ko ||
+    exit 0; loaded=1; }
+
+u1=$mdstart
+u2=$((u1 + 1))
+u3=$((u2 + 1))
+mp0=/stress2_tank/test		# zfs mount
+mp1=$mntpoint			# nullfs of zfs
+mp2=$mntpoint$mdstart		# ufs
+mp3=$mntpoint$((mdstart + 1))	# nullfs of ufs
+mkdir -p $mp2 $mp3
+
+mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1
+mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2
+
+mdconfig -s 2g -u $u1
+mdconfig -s 2g -u $u2
+
+zpool list | egrep -q "^stress2_tank" && zpool destroy stress2_tank
+[ -d /stress2_tank ] && rm -rf /stress2_tank
+zpool create stress2_tank raidz md$u1 md$u2
+zfs create ${mp0#/}
+
+mount | grep -q $mp1 && umount -f $mp1
+mount -t nullfs $mp0 $mp1
+
+mdconfig -a -t swap -s 1g -u $u3
+newfs $newfs_flags /dev/md$u3 > /dev/null
+mount /dev/md$u3 $mp2
+mount -t nullfs $mp2 $mp3
+
+dd if=/dev/zero of=$diskimage bs=1m count=50 status=none
+cp $diskimage $mp1
+cp $mp1/diskimage $mp3
+rm -f $diskimage
+
+umount $mp3
+umount $mp2
+mdconfig -d -u $u3
+
+while mount | grep -q "on $mntpoint "; do
+	umount $mntpoint && break
+	sleep 1
+done
+
+zfs umount ${mp0#/}
+zfs destroy -r stress2_tank
+zpool destroy stress2_tank
+
+mdconfig -d -u $u2
+mdconfig -d -u $u1
+set +u
+[ -n "$loaded" ] && kldunload zfs.ko
+exit 0
diff --git a/tools/test/stress2/misc/zfs19.sh b/tools/test/stress2/misc/zfs19.sh
new file mode 100755
index 000000000000..a3bb19c8be07
--- /dev/null
+++ b/tools/test/stress2/misc/zfs19.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+#
+# Copyright (c) 2024 Peter Holm <pho@FreeBSD.org>
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+
+# Hunt for "vm_fault: pager read error, pid 99058 (mmap)"
+
+[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
+kldstat -v | grep -q zfs.ko  || { kldload zfs.ko; loaded=1; } ||
+    exit 0
+
+. ../default.cfg
+
+prog=$(basename "$0" .sh)
+here=`pwd`
+log=/tmp/$prog.log
+mp1=/stress2_tank/test
+u1=$mdstart
+u2=$((u1 + 1))
+
+set -e
+mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1
+mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2
+
+mdconfig -s 2g -u $u1
+mdconfig -s 2g -u $u2
+
+zpool list | egrep -q "^stress2_tank" && zpool destroy stress2_tank
+[ -d /stress2_tank ] && rm -rf /stress2_tank
+zpool create stress2_tank md$u1 md$u2
+zfs create stress2_tank/test
+set +e
+
+export RUNDIR=/stress2_tank/test/stressX
+export runRUNTIME=2m
+export LOAD=70
+export mmapLOAD=100
+export TESTPROGS="testcases/mmap/mmap testcases/swap/swap"
+
+(cd ..; ./testcases/run/run $TESTPROGS > /dev/null 2>&1) & rpid=$!
+sleep 5
+
+tail -F -n 0 /var/log/messages > $log & lpid=$!
+
+start=`date +%s`
+while [ $((`date +%s` - start)) -lt 120 ]; do
+	zfs umount -f stress2_tank/test &&
+	    zfs mount stress2_tank/test
+	sleep 5
+	zfs list | grep -q /stress2_tank/test || break
+	pgrep -q mmap || break
+done
+pkill run swap mmap
+while pgrep -q swap; do pkill swap; done
+wait $rpid
+
+zfs umount stress2_tank/test
+zfs destroy -r stress2_tank
+zpool destroy stress2_tank
+
+mdconfig -d -u $u1
+mdconfig -d -u $u2
+[ -n "$loaded" ] && kldunload zfs.ko
+
+kill $lpid && wait $lpid
+grep -m 1 "pager read error" $log && s=1 || s=0
+rm $log
+s=0	# This is an expected behavior for zfs
+exit $s



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202411180947.4AI9lKZU027851>