From nobody Tue Jul 12 04:43:16 2022 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 466BF83D92B; Tue, 12 Jul 2022 04:43:17 +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 4Lhp6F1TKbz3pVj; Tue, 12 Jul 2022 04:43:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657600997; 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=jpHJFxMZfJ/iBo95395i8o/AVg6b2cjdoxnL+Mi4+mk=; b=wRKPnyqZEQiBJuGb6og9Tatve1wUTM2V8uhUwBTSvbq9Ql+RBSKiTZxp5k88v3zdX8LBed mymBvYXB0nwj/VtPL33Mw2cUXdph9wIHhB1RIZbOzsdytpDtLMgNbOYFWEo7WsTcOaNKLC LPJXq4dKVHKUsJfR/G4OeuLQONUOaqMMYDBOumCIrBHCE5i0maq9qkJUyW4bVxtOEzXEAu UKGG97EenEktxzpDpF5R2a+x8gJqfhh6/5mAJsW9kbPGaSukduc8RWvNknqqUhC+kn8fEG WEZ17Hh9bhAkZTBDfUxnSqFhnHtspOraSgBCX02giSZ0I6d+wyS2ZodZy+WKOw== 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 4Lhp6F0WCmzW7g; Tue, 12 Jul 2022 04:43:17 +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 26C4hGnk023794; Tue, 12 Jul 2022 04:43:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26C4hGF9023793; Tue, 12 Jul 2022 04:43:16 GMT (envelope-from git) Date: Tue, 12 Jul 2022 04:43:16 GMT Message-Id: <202207120443.26C4hGF9023793@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: 7f3383d29baa - main - stress2: Added a fsck_ffs(8) test scenario 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: 7f3383d29baae9d211481309c02f93d8cb6c86c1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657600997; 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=jpHJFxMZfJ/iBo95395i8o/AVg6b2cjdoxnL+Mi4+mk=; b=NOlIcf/Br2e4BUBAaArPx2SftZUbkom0pXmlgxpw6PYnzhttKmS8uPbFJJmS442t4HAzZa 1h5oVLxYUzZhIa9CjBYRDIhVs0K4kcInzCJuStet9g2ak7wFhCdMRFi/1a9FZ+9Crau7xk AUZEuHJNr41dxMssUC+bMhcrMyqbEs/DQHIWc0gpe24CrF5tunSY5lSWKUiB7ZbTWj9uJk AN3W6V/mA/5wiqVPJgBvupT7xZa/LLLaEUjbDhudaUR6ZARcHrgrk4Ftqr5FSTNhd8eC9f aGkmAjOm5eFkQwpGRQdpVOFzfJcza16EEBUDvxPg5YUs4AQ8Nb9JGawQYhJPyg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657600997; a=rsa-sha256; cv=none; b=pueMHEpT+VF6MbTt8t4xZq2ZuKSC+doSQ6ka//1I3Qv/aDbDZ1dPHj0kZxiZvRf/EgTRe+ k7EREylqGoubH3StE01nwR4Stxs71L5djikehkWO2dWTqdAu2eQMgBzo/UmHzijhFw6beO jQQDhjZCIHLolzK8yxKe9HOI1mnjoRhMIin0gSJnu9e7xxxcajgsyxSKNFXs2+9G7cKH8R 1f+XiDnCQGhzGyIDlELuljjf5vdfRXefxV46cU4audmOVn2LkXeu0ILqKVbyLLODG7hOr5 XX5AtUtkVpcG6larURYiqPleiGJKhteQ5n2fDIKCIwQQBBw8sbGm6+sPmV6NUg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by pho: URL: https://cgit.FreeBSD.org/src/commit/?id=7f3383d29baae9d211481309c02f93d8cb6c86c1 commit 7f3383d29baae9d211481309c02f93d8cb6c86c1 Author: Peter Holm AuthorDate: 2022-07-12 04:42:33 +0000 Commit: Peter Holm CommitDate: 2022-07-12 04:42:33 +0000 stress2: Added a fsck_ffs(8) test scenario --- tools/test/stress2/misc/fsck8.sh | 178 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) diff --git a/tools/test/stress2/misc/fsck8.sh b/tools/test/stress2/misc/fsck8.sh new file mode 100755 index 000000000000..7b2e20bb7d5b --- /dev/null +++ b/tools/test/stress2/misc/fsck8.sh @@ -0,0 +1,178 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2022 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. +# + +# fsck_ffs(8) disk image fuzz test. SB focus. + +# panic: wrong length 4098 for sectorsize 512 +# FreeBSD 14.0-CURRENT #0 main-n255602-51adf913e8815: Fri May 13 07:55:32 CEST 2022 +# pho@mercat1.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO + +. ../default.cfg + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +cc -o /tmp/flip -Wall -Wextra -O2 ../tools/flip.c || exit 1 + +set -e +u1=$mdstart +u2=$((mdstart + 1)) +mp1=${mntpoint}$u1 +mp2=${mntpoint}$u2 +mkdir -p $mp1 $mp2 +log=$mp1/fsck8.sh.log +diskimage=$mp1/fsck8.sh.diskimage +backup=/tmp/fsck8.sh.diskimage.`date +%Y%m%dT%H%M%S`.gz +asbs=0 +cleans=0 +reruns=0 +waccess=0 + +max=$((10 * 1024 * 1024)) +# UFS1 or UFS2 SU: +[ `jot -r 1 0 1` -eq 0 ] && newfs_flags='-O 1' || newfs_flags='-O 2 -U' + +mount | grep "on $mp1 " | grep -q /dev/md && umount -f $mp1 +[ -c /dev/md$u1 ] && mdconfig -d -u $u1 +mdconfig -a -t swap -s 1g -u $u1 +newfs $newfs_flags -n /dev/md$u1 > /dev/null +mount /dev/md$u1 $mp1 + +[ -c /dev/md$u2 ] && mdconfig -d -u $u2 +dd if=/dev/zero of=$diskimage bs=$max count=1 status=none +mdconfig -a -t vnode -f $diskimage -u $u2 +backups=`newfs -N $newfs_flags md$u2 | grep -A1 "super-block backups" | \ + tail -1 | sed 's/,//g'` +newfs $newfs_flags -n md$u2 > /dev/null +mount /dev/md$u2 $mp2 +[ -d /usr/include/sys ] && cp -r /usr/include/sys $mp2 +umount $mp2 +set +e + +chk() { + local i + + clean=0 + rerun=0 + waccess=0 + fsck_ffs -fy $1 > $log 2>&1 + r=$? + if grep -qE "Cannot find file system superblock|Superblock check-hash failed" $log; then + for b in $backups; do + echo "Using alternate SB $b" + asbs=$((asbs + 1)) + fsck_ffs -b $b -fy $1 > $log 2>&1 + r=$? + grep -qE "Cannot find file system superblock|Superblock check-hash failed" $log || + break + done + usedasb=1 + else + usedasb=0 + fi + LANG=C egrep -q "[A-Z][A-Z]" $log && clean=0 + grep -Eq "IS CLEAN|MARKED CLEAN" $log && clean=1 + # For now regard a "was modified" as a cause for a rerun, + # disregarding the "clean" claim. + grep -Eq "WAS MODIFIED" $log && rerun=1 + grep -q RERUN $log && rerun=1 + grep -q "NO WRITE ACCESS" $log && waccess=1 + [ $r -ne 0 -a $clean -eq 1 ] && echo "Exit code $r w/ clean == 1" +} + +cd $mp1 +clean=0 +s=0 +start=`date +%s` +while [ $((`date +%s` - start)) -lt 300 ]; do + mount /dev/md$u2 $mp2 || { s=101; break; } + ls -lR $mp2 > /dev/null || { s=102; echo "ls failed"; break; } + touch $mp2/`jot -rc 8 a z | tr -d '\n'` + while mount | grep -q "on $mp2 "; do umount $mp2; done + echo * | grep -q core && break + sync + mdconfig -d -u $u2 + # SBLOCK = 64k, SBLOCKSIZE = 8k + /tmp/flip -n 5 -s $(((64 + 8) * 1024)) $diskimage + + sync + if [ `stat -f%z $diskimage` -gt $max ]; then + ls -lh $diskimage + truncate -s $max $diskimage + else + gzip < $diskimage > $backup + fi + fsync $backup + + for i in `jot 5`; do + [ $i -gt 2 ] && echo "fsck run #$i" + chk $diskimage + [ $rerun -eq 1 ] && { reruns=$((reruns + 1)); continue; } + [ $clean -eq 1 ] && { cleans=$((cleans + 1)); break; } + [ -f fsck_ffs.core ] && + { cp $diskimage \ + /tmp/fsck_ffs.core.diskimage.`date +%Y%m%dT%H%M%S`; break 2; } + done + [ $clean -ne 1 ] && break + mdconfig -a -t vnode -f $diskimage -u $u2 + [ $r -ne 0 -a $clean -eq 1 ] && + { echo "CLEAN && non zero exit code"; break; } + [ $clean -eq 1 ] && continue + [ $usedasb -eq 1 ] && { echo "Alt. SB failed"; s=104; } + [ $waccess -eq 1 ] && { echo "No write access"; s=105; } + break +done +sleep 2 # Wait for /dev to catch up +[ -c /dev/md$u2 ] && r1=1 || r1=0 +for i in `jot 5`; do + mount | grep -q "on $mp2 " || break + umount $mp2 && break + sleep 2 +done +mdconfig -d -u $u2 2>/dev/null # XXX when mount fails + +echo "$cleans cleans, $reruns reruns, $asbs alternate SBs." +if [ $clean -ne 1 ]; then + echo "FS still not clean. Last fsck_ffs exit code was $r." + echo ================= + cat $log + echo ================= + cp -v $log /tmp + [ $s -eq 0 ] && s=106 +fi +echo * | grep -q core && { ls -l *.core; cp $log /tmp; exit 106; } || + rm -f $backup +[ $s -eq 101 ] && rm -f $backup # mount error breakout +cd /tmp +for i in `jot 5`; do + umount $mp1 && break + sleep 2 +done +mdconfig -d -u $u1 +rm -f /tmp/flip +exit $s