DragonFlyBSD Kernel Audit
DF-2631 / fix_validate.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-2631 fix validation on kernel #1 (v4, both fixes):
# umount -f of a same-clid MASTER+MASTER clone pair must COMPLETE (bounded),
# leave no stranded threads, allow further mounts, and not destabilize the box.
set -x
D=/root/poc/fix2631
mkdir -p $D
for v in vn0 vn1 vn2; do vnconfig -u $v 2>/dev/null; done
mkdir -p /mnt/h2 /mnt/h2b /mnt/h2d

# default 60 kept for final validation (was 10 in earlier iterations)

# robust clean start (no leftover mounts/vnds from earlier tests)
for m in /mnt/h2 /mnt/h2b /mnt/h2d; do timeout 90 umount -f $m 2>/dev/null; done
for v in vn0 vn1 vn2; do vnconfig -u $v 2>/dev/null; done
echo -n 'CLEANSTART_h2mounts='; mount -p | grep -c "vn[012]"

cp /root/poc/base.img $D/m1.img
cp /root/poc/base.img $D/m2.img
cp /root/poc/base.img $D/m3.img

vnconfig -c vn0 $D/m1.img
vnconfig -c vn1 $D/m2.img

echo '=== 1. mount MASTER #1 ==='
mount -t hammer2 -o ro /dev/vn0@testvol /mnt/h2
echo "MOUNT1_RC=$?"
echo -n 'T1_h2xop='; ps axlw | grep -c h2xop-testvol
echo -n 'T1_h2nod='; ps axlw | grep -c h2nod-testvol

echo '=== 2. same-clid merge (EBUSY expected) ==='
mount -t hammer2 -o ro /dev/vn1@testvol /mnt/h2b
echo "MOUNT2_RC=$?"
echo -n 'T2_h2xop='; ps axlw | grep -c h2xop-testvol
echo -n 'T2_h2nod='; ps axlw | grep -c h2nod-testvol

echo '=== 3. ls works (quorum 2/2) ==='
ls /mnt/h2
echo "LS_RC=$?"

echo '=== 4. umount -f — must COMPLETE (bounded by collect timeout) ==='
date +%s > $D/ts_start
umount -f /mnt/h2
UMF_RC=$?
date +%s > $D/ts_end
echo "UMOUNTF_RC=$UMF_RC"
echo "ELAPSED=$(( $(cat $D/ts_end) - $(cat $D/ts_start) ))s"

echo '=== 5. survivor census ==='
echo -n 'SURV_h2xop_testvol='; ps axlw | grep -c h2xop-testvol
echo -n 'SURV_h2nod_testvol='; ps axlw | grep -c h2nod-testvol
ps axlw | grep -E "umount|h2twait.*umount" | grep -v grep | head -3
echo '--- wchan histogram of testvol threads ---'
ps axlw | grep -E "h2xop-testvol|h2nod-testvol" | grep -v grep | awk '{print $8}' | sort | uniq -c

echo '=== 6. third hammer2 mount now works (mntlk released) ==='
vnconfig -c vn2 $D/m3.img
timeout 20 mount -t hammer2 -o ro /dev/vn2@testvol /mnt/h2d
echo "MOUNT3_RC=$?"
ls /mnt/h2d
echo "MOUNT3_LS_RC=$?"
timeout 20 umount /mnt/h2d
echo "MOUNT3_UMOUNT_RC=$?"

echo '=== 7. single-device sanity on the same boot ==='
vnconfig -u vn2 2>/dev/null
vnconfig -c vn2 /root/poc/base2.img
timeout 20 mount -t hammer2 -o ro /dev/vn2@othervol /mnt/h2d
echo "SANITY_MOUNT_RC=$?"
timeout 20 umount /mnt/h2d
echo "SANITY_UMOUNT_RC=$?"
vnconfig -u vn2
echo VALIDATION_2631_DONE