#!/bin/sh
# DF-3215 run variant 1 (in-guest): DEFAULT-config (512MB FIFO) race.
# 4 processes x 16 files x 1MB chunks x 40 rounds = ~2.5GB of REDO records
# into a 512MB FIFO.  The frontend lays records at memory speed while the
# flusher needs to sync hundreds of MB of dirty data buffers + volume
# headers to reclaim; parallel processes keep the frontend busy while any
# single one waits in its relaxed fsync.
set -e
cd /tmp/df3215
[ -x redo_fill ] || cc -O2 -o redo_fill redo_fill.c
./setup_v1.sh
i=0
while [ $i -lt 4 ]; do
	mkdir -p /mnt/h1/scratch/p$i
	chmod 1777 /mnt/h1/scratch/p$i
	i=$((i + 1))
done
echo
echo "== V1 trigger (unprivileged nobody x4) start: $(date) =="
i=0
while [ $i -lt 4 ]; do
	su -m nobody -c "/tmp/df3215/redo_fill /mnt/h1/scratch/p$i 16 1048576 40" \
	    > /tmp/df3215/v1_p$i.log 2>&1 &
	i=$((i + 1))
done
wait
echo "== all triggers exited : $(date) =="
tail -3 /tmp/df3215/v1_p*.log
echo "== if you can read this, no panic occurred =="
dmesg | tail -15
