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