I was wondering about this subject for some time but the only real solution as I see would be a transactional filesystem (re-designing how filesystems work).
Related: https://news.ycombinator.com/item?id=32200007