Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Aug 2023 19:37:45 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        current@freebsd.org
Subject:   Re: ZFS deadlock in 14
Message-ID:  <86pm3op5p2.fsf@ltc.des.no>
In-Reply-To: <86350kqokl.fsf@ltc.des.no> ("Dag-Erling =?utf-8?Q?Sm=C3=B8rg?= =?utf-8?Q?rav=22's?= message of "Tue, 15 Aug 2023 18:04:42 %2B0200")
References:  <86leeltqcb.fsf@ltc.des.no> <86h6p4s64h.fsf@ltc.des.no> <86a5utrafp.fsf@ltc.des.no> <86350kqokl.fsf@ltc.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

The attached script successfully deadlocks 9228ac3a69c4.

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@FreeBSD.org


--=-=-=
Content-Type: text/plain
Content-Disposition: attachment; filename=zfs-deadlock.sh

#!/bin/sh

: ${n:=$(nproc)}
: ${pool:=zroot}
basefs="${pool}/zfsdl"

set -eu

zfs destroy -r "${basefs}" >/dev/null 2>&1 || true
zfs create -o com.sun:auto-snapshot=false "${basefs}"
basedir="$(zfs get -H -o value mountpoint "${basefs}")"

echo "preparing tarball..." >&2
tarball="${basedir}/zfsdl.tar"
mkdir "${basedir}/src"
(cd /usr/src ; find * -type d) | (cd "${basedir}/src" ; xargs mkdir -p)
(cd /usr/src ; find * -type f) | (cd "${basedir}/src" ; xargs touch)
tar cf "${tarball}" -C "${basedir}" src

zfs_deadlock() {
	local fs=$1 dir
	zfs create "${fs}"
	dir="$(zfs get -H -o value mountpoint "${fs}")"
	zfs snapshot "${fs}@empty"
	while ! [ -f "${basedir}/stop" ] ; do
		echo "fill ${fs}..." >&2
		tar xf "${tarball}" -C "${dir}"
		echo "rollback ${fs}..." >&2
		zfs rollback -rR "${fs}@empty"
	done
}

for i in $(seq -w "${n}") ; do
	zfs_deadlock "${basefs}/${i}" &
	sleep 1
done

wait

echo "stop" >&2

zfs destroy -r "${basefs}"

--=-=-=--



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