add dynamic fsync
credits to faux and GideonX