Created
August 21, 2023 15:38
-
-
Save dag-erling/54d802b614f5a62e4eb959e1198c2e6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment