manpage for fsync says:
If the underlying hard disk has write caching enabled, then the data
may not really be on permanent storage when fsync() / fdatasync()
return.
Is there any way how to ensure that data was physically written to the disk?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, there is not.
With
fsyncyou tell your OS to write it to disk and as far as the OS is concerned, it has been written to disk.If disks are faking this then it is not something you can really change unfortunately.
With proper disk systems (i.e. BBU raid setups) you can simply enable/disable write cache to avoid this mostly.
Do note that if you specify the
O_DIRECTandO_SYNCflags, it should write it to disk: http://www.kernel.org/doc/man-pages/online/pages/man2/open.2.html