I have a VM image-building script which can trigger the problem.
In particular, it generates images which are not clean according to fsck:
it finds directory entries pointing to unallocated (clobbered) inodes.
With this change, fsck runs cleanly, and all makefs tests pass.