Use fsync on state dump

This ensures that the state dump files would be on disk. Otherwise, with
a busy suite on the ext4 file system, they may be left as zero size
files on a power failure.
Merge pull request #813 from matthewrmshin/fsync-state-dump

Use fsync on state dump