ufs_dirbad: /mnt: bad dir ino 50626 at offset 0: mangled entry

From: mike tancsa <mike_at_sentex.net>
Date: Fri, 22 Oct 2021 14:36:01 UTC
In one of my VMs, I do a bunch of testing to a nano image on /dev/md0 
and increasingly I am getting a panic on umounting the file system

The image is just

truncate -s 5G /tmp/junk.bin
mdconfig -f /tmp/junk.bin

and then I dd my nano image, mount it, make some configuration changes 
and then umount it.

After cycles of this, unmounts, mounts etc, I get


panic: ufs_dirbad: /mnt: bad dir ino 50626 at offset 0: mangled entry
cpuid = 1
time = 1634912598
KDB: stack backtrace:
#0 0xffffffff80c77035 at kdb_backtrace+0x65
#1 0xffffffff80c28a47 at vpanic+0x187
#2 0xffffffff80c288b3 at panic+0x43
#3 0xffffffff80f345f7 at ufs_lookup_ino+0xdc7
#4 0xffffffff80ceae1d at vfs_cache_lookup+0xad
#5 0xffffffff80cf872c at lookup+0x46c
#6 0xffffffff80cf785c at namei+0x26c
#7 0xffffffff80d1c979 at vn_open_cred+0x509
#8 0xffffffff80d12a3e at kern_openat+0x26e
#9 0xffffffff810b4d3c at amd64_syscall+0x10c
#10 0xffffffff8108bdab at fast_syscall_common+0xf8
Uptime: 4m48s

I forced an fsck on reboot, and the file system is clean. I also deleted 
/mnt and recreated the directory and still get this issue.  Any idea 
what might be causing it or how I can better track it down ?

     ---Mike