From nobody Sat Jan 14 19:19:26 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NvSlL6ffsz2sp2C; Sat, 14 Jan 2023 19:19:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NvSlL64nGz4DKm; Sat, 14 Jan 2023 19:19:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673723966; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xXepOK3djv14qTJcQ+VkKNrWiQsG1l6WzCK6dy6lcFA=; b=vQTdRfWwvLBRh6fmq4qrF9LhpRPib9i9nLfHxCTzxwwFVawausAmzr37gf3kfEaQzXFMfc 7H15KW2hma+wvwIkMJjeyxcS1pX6+n0tAbrx3bn+1CSUOx0w9XdkUjcZUhXfNINPwOoX06 kbbeWxylh+1rNh6+GT8gA8i/OXcYkJOyUP0k550URUjXMSRRLpMMs42HzR7zxgwrLNcvgz Qx0NV4+hO6LvdWoKH0XoY5daG0eGcSGN3zy+a28e+cJRFGKde3BrEzSrNutk7rb3mi5GLR AakaamYscVyOow3UxrIqcbT1dj/7lfRuu+MNk+0HzNIHYhs1h9RG+kXS+uaReA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673723966; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xXepOK3djv14qTJcQ+VkKNrWiQsG1l6WzCK6dy6lcFA=; b=oZ5f4IpPw7SJOFOj6GBRdJMnvctx2ccOBIJyifYV8+JrlbNMNsS9TAuTKYeAg0X00BW7Aw 2YQagPRhX1mrlv6J7++clsZJqI7xrjHyVmffXX64mPNuEcUjgp2CphsTxpUQMfn5q1zonc UEWciroAtM/aemdn9Pe+lv8/xYxjY4O3XrDcMIYUdaiN35dJ7kJzId3g0PQKASEdBM98Pz lus2/iFLI9WifzzBMfpslVsafWZSZgvY1IaQnIKT8jL1iReHxnHbqT/aUe3tJ+Ld4hMdN5 Zvc0eeVzKFU1dJCWT3YB1WjQ80+InReav36yyayAxZBCzCXkZoaZ87Qy2jG39Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673723966; a=rsa-sha256; cv=none; b=bHXORR3HbmnlbyIQt56r/fS1PZxMlUwtwDS/DFnCFSXYdphT/FFyAXawR6tTAJ2nsSfY8j IOpegRKkSE71jzziI52McdIpg/IyqeTA61HvjaNvdvxPgsxLFSio5WvR08p2VHnjp59XNF efxqL1LXyhAWtN7LTnlbclJ/Mek+OzfysfA+1BKico5ZA7sJbb5tlhnkBh2OnxXTowNfKR SXbF5tPW/65F/DRGLb4OMoM+hjwftN2u7v6XAXd7Y2clgA3LAvchfUcH0Y3gVOECge5Npj hac/ixt8B2HEgx83pGpI4Jce8quM2CJlRb9KgwXkqyxOXmAgSfFAYI9jLFEdJA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NvSlL56pGzyps; Sat, 14 Jan 2023 19:19:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30EJJQNg021664; Sat, 14 Jan 2023 19:19:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30EJJQr4021663; Sat, 14 Jan 2023 19:19:26 GMT (envelope-from git) Date: Sat, 14 Jan 2023 19:19:26 GMT Message-Id: <202301141919.30EJJQr4021663@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Peter Holm Subject: git: 4dcc6baddb44 - main - stress2: Added a regression test List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pho X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4dcc6baddb446d27a60e30ccc24b29d9e47b553a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=4dcc6baddb446d27a60e30ccc24b29d9e47b553a commit 4dcc6baddb446d27a60e30ccc24b29d9e47b553a Author: Peter Holm AuthorDate: 2023-01-14 19:19:05 +0000 Commit: Peter Holm CommitDate: 2023-01-14 19:19:05 +0000 stress2: Added a regression test --- tools/test/stress2/misc/fsync3.sh | 156 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) diff --git a/tools/test/stress2/misc/fsync3.sh b/tools/test/stress2/misc/fsync3.sh new file mode 100755 index 000000000000..f220d19b8c24 --- /dev/null +++ b/tools/test/stress2/misc/fsync3.sh @@ -0,0 +1,156 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2023 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. +# + +# Regression test for D37997: ffs_syncvnode(): avoid a LoR for SU +# https://people.freebsd.org/~pho/stress/log/log0402.txt +# Fixed by 6e1eabadcb1d - main - ffs_syncvnode(): avoid a LoR for SU + +# Test scenario based on report by jkim + +. ../default.cfg +[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 + +dir=/tmp +odir=`pwd` +prog=$(basename "$0" .sh) +cd $dir +sed '1,/^EOF/d' < $odir/$0 > $dir/$prog.c +mycc -o $prog -Wall -Wextra -O0 -g $prog.c -lpthread || exit 1 +rm -f $prog.c +cd $odir + +set -eu +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 -U md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint +set +e + +cd $odir +../testcases/swap/swap -t 1m -i 20 -l 100 > /dev/null & +sleep .5 +cd $mntpoint +mkdir -p d1/d2/d3/d4/d5 +for i in `jot 8`; do + $dir/$prog $i & +done +cd $odir +wait + +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/$prog +exit 0 +EOF +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RUNTIME 60 + +static time_t start; +static volatile int fd, n; +static char buf[4096]; + +static void * +t1(void *data __unused) +{ + char *path = "d1/d2/d3/d4/d5"; + char d1[1024], d2[1024], file[1024]; + + pthread_set_name_np(pthread_self(), __func__); + snprintf(d1, sizeof(d1), "%s/dir.%d", path, getpid()); + snprintf(d2, sizeof(d2), "%s/new.%d", path, getpid()); + snprintf(file, sizeof(file), "%s/../file.%d", path, getpid()); + while (time(NULL) - start < RUNTIME) { + if (mkdir(d1, 0740) == -1) + err(1, "mkdir(%s)", d1); + if (rename(d1, d2) == -1) + err(1, "rename(%s, %s)", d1, d2); + if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0600)) == -1) + err(1, "open%s()", file); + if (write(fd, buf, sizeof(buf)) != sizeof(buf)) + err(1, "write()"); + close(fd); + if (rename(d2, d1) == -1) + err(1, "rename(%s, %s)", d2, d1); + if (rmdir(d1) == -1) + err(1, "rmdir(%s)", d1); + } + + return (NULL); +} + +static void * +t2(void *data __unused) +{ + pthread_set_name_np(pthread_self(), __func__); + while (time(NULL) - start < RUNTIME) { + fsync(fd); + usleep(arc4random() % 500); + } + + return (NULL); +} + +int +main(int argc __unused, char *argv[]) +{ + pthread_t tid[2]; + int r; + + n = atoi(argv[1]); + start = time(NULL); + if ((r = pthread_create(&tid[0], NULL, t1, NULL)) != 0) + errc(1, r, "pthread_create"); + if ((r = pthread_create(&tid[1], NULL, t2, NULL)) != 0) + errc(1, r, "pthread_create"); + + if ((r = pthread_join(tid[0], NULL)) != 0) + errc(1, r, "pthread_join"); + if ((r = pthread_join(tid[1], NULL)) != 0) + errc(1, r, "pthread_join"); + + return (0); +}