⬢ DragonFlyBSD Kernel Audit
DF-4714 / setup_vinum.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-4714 / DF-4715 / DF-4721 PoC setup (guest, root)
#
# RAID-5 vinum volume on 2 md (malloc) drives with 3 subdisks:
#   s0 on drive d1 (/dev/md0s0)
#   s1 on drive d2 (/dev/md1s0) at driveoffset 0      (auto-allocated)
#   s2 on drive d2 (/dev/md1s0) at driveoffset 4361s   (2 sds share ONE drive;
#        4361s = 265s vinum label/config reserve + 4096s first sd)
#
# stripesize 16k = 32 sectors, 3 subdisks: stripe group i covers volume
# sectors [i*64,(i+1)*64); parity ordinal = 2 - (i % 3).  Group i=2
# => parity ordinal 0 (s0), data ordinals 1 (s1) and 2 (s2).
# Test window: volume sectors [128,192) = bytes [65536,98304).
#
# NB: all triggers use SINGLE write()/read() calls (dd bs=32768/16384
# count=1 or the trigger binary): a 512-byte dd issues per-sector bios
# that each touch only ONE data subdisk and never engage the two-bad-
# columns-in-one-request code paths under test.
kldload vinum >/dev/null 2>&1
for u in 0 1; do
  dd if=/dev/zero of=/dev/md${u} bs=1m count=12 >/dev/null 2>&1
  gpt create -f md${u} >/dev/null 2>&1
  gpt add -t vinum -s 16384 md${u} >/dev/null 2>&1
done
printf "drive d1 device /dev/md0s0\n"        >  /tmp/vc.txt
printf "drive d2 device /dev/md1s0\n"        >> /tmp/vc.txt
printf "volume rv\n"                         >> /tmp/vc.txt
printf " plex org raid5 16k\n"               >> /tmp/vc.txt
printf "  sd length 2m drive d1\n"           >> /tmp/vc.txt
printf "  sd length 2m drive d2\n"           >> /tmp/vc.txt
printf "  sd length 2m driveoffset 4361s drive d2\n" >> /tmp/vc.txt
vinum create -f /tmp/vc.txt >/dev/null 2>&1
for o in rv.p0.s0 rv.p0.s1 rv.p0.s2 rv.p0 rv; do
  vinum setstate -f up $o >/dev/null 2>&1
done
sleep 1
echo "== initial state =="
vinum list | tr -d '\r' | grep -E "^D |^V |^P |^S "
# sanity: single 32KB roundtrip with everything up
dd if=/dev/zero bs=512 count=64 2>/dev/null | tr '\0' '\165' > /tmp/sanity
dd of=/dev/vinum/vol/rv bs=32768 seek=2 count=1 if=/tmp/sanity 2>/dev/null
dd if=/dev/vinum/vol/rv bs=32768 skip=2 count=1 of=/tmp/sanity_out 2>/dev/null
cmp -s /tmp/sanity /tmp/sanity_out && echo "SANITY: 32KB roundtrip OK" || echo "SANITY: FAILED"