Not really by accident. I believe the necessary dependence is established by the "data=ordered" mount option. That's pretty much what we need to fix this issue: Make sure that the data is on the disk before you write the updated metadata.
That doesn't mean you need to flush things to the disk early. It just means that things have to happen in a particular order.