#!/bin/sh
# DF-3168 fix-validation trigger: identical to trigger.sh but stops after
# the post-rebalance readback (no remount/search -- the 14 leaves we forged
# still carry count=128 in the image, which is pre-existing image corruption
# that btree_search's own INVARIANTS KKASSERT catches regardless of this
# file's fix).
set -e
vnconfig -c -S 12G vn0 /build/poc.img || exit 1
mount -t hammer /dev/vn0 /mnt || { vnconfig -u vn0; exit 1; }
echo "MOUNTED -- running hammer rebalance (FIXED kernel)"
sysctl vfs.hammer.debug_general=0x1000
hammer rebalance /mnt; echo "REBAL_RC=$?"
sysctl vfs.hammer.debug_general=0
dmesg | grep -E "rebalance: bad|panic" | head -20
umount /mnt
echo "== post-rebalance readback (expect ONLY the 14 forged leaves) =="
/tmp/patch_leaf_rebal verify /build/poc.img; echo "VERIFY_RC=$?"
vnconfig -u vn0
echo FIXRUN-DONE
