Files
erofs-freebsd-out-tree/tests/TC094-chunk-multi-device.md
T
2026-08-13 10:44:59 +02:00

4.1 KiB

Test Case: Chunk Indexes and Compressed Pcluster on External Slots

Test ID: TC094-chunk-multi-device
Category: Chunk-Based / Multi-Device Priority: Critical

Objective

Verify alternating external chunk slots, a nonzero device ID with uniaddr=0, provider identity, and a real external two-block LZ4 pcluster.

Fixture qualification

Use the fresh G6 artifacts and manifest:

  • multi2-*: /cross-device.bin has three 131072-byte chunks with device IDs 1,2,1; slot blocks differ, so provider swapping fails deterministically.
  • multi2-uniaddr0-*: slot 1 has uniaddr=0, but indexes retain device ID 1.
  • lz4-external-pcluster-*: the original fixed 8192-byte LZ4 pcluster is fsck-qualified before relocation. The generated primary is only 8192 bytes, contains metadata plus the table, and has HEAD pblk 2; both compressed blocks exist only in slot 1.

Alternating slots and provider identity

I=/root/repo22-g6/images
S=/root/repo22-g6/sources/chunk
mkdir -p /mnt/g6
kldload /root/repo22-g6/erofs.ko
mdconfig -a -t vnode -f "$I/multi2-primary.erofs" -u 90
mdconfig -a -t vnode -f "$I/multi2-slot1.blob" -u 91
mdconfig -a -t vnode -f "$I/multi2-slot2.blob" -u 92
mount -t erofs -o ro -o device.2=/dev/md92 -o device.1=/dev/md91 \
  /dev/md90 /mnt/g6
cmp "$S/cross-device.bin" /mnt/g6/cross-device.bin
sha256 "$S/cross-device.bin" /mnt/g6/cross-device.bin
dd if="$S/cross-device.bin" of=/tmp/tc094.expected bs=1 skip=126976 count=8192 2>/dev/null
dd if=/mnt/g6/cross-device.bin of=/tmp/tc094.actual bs=1 skip=126976 count=8192 2>/dev/null
cmp /tmp/tc094.expected /tmp/tc094.actual
for off in 0 131072 262144; do
  dd if="$S/cross-device.bin" of=/tmp/tc094.src.$off bs=1 skip=$off count=4096 2>/dev/null
  dd if=/mnt/g6/cross-device.bin of=/tmp/tc094.mnt.$off bs=1 skip=$off count=4096 2>/dev/null
  cmp /tmp/tc094.src.$off /tmp/tc094.mnt.$off
done
umount /mnt/g6
mdconfig -d -u 92
mdconfig -d -u 91
mdconfig -d -u 90

Confirm swapped providers fail with ENXIO:

mdconfig -a -t vnode -f "$I/multi2-primary.erofs" -u 90
mdconfig -a -t vnode -f "$I/multi2-slot1.blob" -u 91
mdconfig -a -t vnode -f "$I/multi2-slot2.blob" -u 92
truss -f -o /tmp/tc094-swap.truss mount -t erofs -o ro \
  -o device.1=/dev/md92 -o device.2=/dev/md91 /dev/md90 /mnt/g6
tail -20 /tmp/tc094-swap.truss
mdconfig -d -u 92
mdconfig -d -u 91
mdconfig -d -u 90

Zero unified address with explicit device ID

mdconfig -a -t vnode -f "$I/multi2-uniaddr0-primary.erofs" -u 90
mdconfig -a -t vnode -f "$I/multi2-uniaddr0-slot1.blob" -u 91
mdconfig -a -t vnode -f "$I/multi2-uniaddr0-slot2.blob" -u 92
mount -t erofs -o ro -o device.2=/dev/md92 -o device.1=/dev/md91 \
  /dev/md90 /mnt/g6
cmp "$S/cross-device.bin" /mnt/g6/cross-device.bin
umount /mnt/g6
mdconfig -d -u 92
mdconfig -d -u 91
mdconfig -d -u 90

External compressed pcluster

P=/root/repo22-g6/sources/pcluster
mdconfig -a -t vnode -f "$I/lz4-external-pcluster-primary.erofs" -u 90
mdconfig -a -t vnode -f "$I/lz4-external-pcluster-slot1.blob" -u 91
mount -t erofs -o ro -o device.1=/dev/md91 /dev/md90 /mnt/g6
stat -f '%z' /mnt/g6/external-pcluster.bin
sha256 "$P/external-pcluster.bin" /mnt/g6/external-pcluster.bin
cmp "$P/external-pcluster.bin" /mnt/g6/external-pcluster.bin
dd if="$P/external-pcluster.bin" of=/tmp/tc094-p.src bs=1 skip=61440 count=8192 2>/dev/null
dd if=/mnt/g6/external-pcluster.bin of=/tmp/tc094-p.mnt bs=1 skip=61440 count=8192 2>/dev/null
cmp /tmp/tc094-p.src /tmp/tc094-p.mnt
truss -f -o /tmp/tc094-p-ebusy.truss mdconfig -d -u 91
tail -20 /tmp/tc094-p-ebusy.truss

The 131072-byte output must match although the primary has no old compressed extent; normal slot detach must return EBUSY.

Cleanup and zero-state check

umount /mnt/g6
mdconfig -d -u 91
mdconfig -d -u 90
kldunload erofs
rm -f /tmp/tc094.expected /tmp/tc094.actual /tmp/tc094.src.* \
  /tmp/tc094.mnt.* /tmp/tc094-p.src /tmp/tc094-p.mnt
mount -p | awk '$3 == "erofs" { print }'
mdconfig -l
kldstat -n erofs 2>/dev/null || true
sysctl -n kern.geom.conftxt | grep -E 'md9[0-2]|erofs' || true

All four final outputs must be empty, with no panic, trap, or hang.