<div dir="ltr"><br><br><div class="gmail_quote">On Sat, Nov 5, 2011 at 11:12 PM, Diego <span dir="ltr"><<a href="mailto:elcuco@kde.org">elcuco@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi list,<br>
<br>
I am trying to debug this problem in a system I am developing:<br>
<br>
at some point I need to write a number to a file, and then reboot via an<br>
external device the machine. That device will cut of the power for a moment,<br>
and the machine will power on again (this is to overcome a fault we could not<br>
overcome otherwise). Before the reboot, I "umount" the proper partition and<br>
then "sync".<br>
<br>
For some reason, on one machine we see that the data is not updated and the<br>
original data is kept in the file. I konw empirically that if I add a<br>
"sleep(5)" after the umount, and before the "reboot" the data is written to<br>
the disk.<br>
<br>
Any tips how to debug this?<br>
* the system is a TI 2.6.32 kernel (OMAP)<br>
* the data is saved using fopen()<br>
* disk is umounted using system("umount /data"), and then I call from C to<br>
sync();<br>
* Cannot print debug this easily since the reboot is automated at the start<br>
of the APP, and then busybox's "login" breaks my serial terminal (like this<br>
eats "\n", git fixes if I press enter)<br>
* The application is also multi-threaded to add more difficulty ...<br>
* FS is JFFS2<br>
* again the workaround is a "sleep(5)"<br>
<br>
Any ideas?<br>
<br></blockquote><div>man 2 sync says:<br><br>BUGS<br> According to the standard specification (e.g., POSIX.1-2001), sync() schedules the writes,<br> but may return before the actual writing is done. However, since version 1.3.20 Linux does<br>
actually wait. (This still does not guarantee data integrity: modern disks have large<br> caches.)<br><br>maybe that's your culprit?<br><br>-- Shimi <br></div></div><br></div>