#!/bin/sh
# root side: churn journals on /tmp while user writers hammer VOPs.
# $1 = total seconds
SECS=$1
mkdir -p /tmp/jrace && chmod 777 /tmp/jrace
rm -f /root/jchurn_*.bin
n=0
t0=$(date +%s)
while [ $(( $(date +%s) - t0 )) -lt $SECS ]; do
  n=$((n+1))
  mountctl -a -w /root/jchurn_$n.bin -o memfifo=64k /tmp:churn 2>/dev/null
  mountctl -d /tmp:churn 2>/dev/null
  rm -f /root/jchurn_$n.bin
  usleep 200000 2>/dev/null || sleep 0.2
done
echo "churn cycles: $n"
