fix various fs correctness and perf issues

This is a grab-bag of fs correctness and perf improvements. It'll be easier to review each individual commit separately.

Oh, right, so it doesn't matter anyway.