umount and data is lost?
Diego Iastrubni
elcuco at kde.org
Sun Nov 6 20:28:45 IST 2011
Hi all,
First of all, thanks for all the responces. I am here, instead of the
gazillion (usefull) answers just so I do not insult anyone... (or everyone?).
Some questions asked:
1) I did fclose() the file.
2) I tried sync() before the umount().
3) Instead of using system("umount...") I am using umount("...", MNT_FORCE).
Return value is OK=0.
4) I did not test which sleep() is the minimal.
5) Micha, HTML mail on this is is badbad. A kitten died because of you, thank
you (I am allergic to them)
6) hdparm... does it work on nand devices? I did mention this once or twise.
Just to make things clear: this is not a PC, it's an ARM based device.
On יום ראשון 06 נובמבר 2011 19:04:48 Nadav Har'El wrote:
> On Sat, Nov 05, 2011, Diego wrote about "umount and data is lost?":
> > overcome otherwise). Before the reboot, I "umount" the proper partition
> > and then "sync".
>
> I believe it is rather pointless to sync(1) after umount(1) as umount(1)
> already writes all the buffered data for that filesystem before it
> succeeds. You can see this behavior in action if you mount a slow USB
> flash drive, write a lot of data to it, and immediately umount - the
> umount often can take many seconds to finish, until all the data is
> actually written to the drive.
... and now the story gets even funnier:
I looked at the source again of my application, and it seems that the boot I
was doing is not the "external power off" reboot I was thinking of, but the
linux reboot(LINUX_REBOOT_CMD_RESTART) (man 2 reboot). This one was supposed
to umount() my partitions, and flush all data, correct? It does not in my case.
The problem on the system got fixed by calling the "external power off" reboot,
since I called sync() and umount() explicitly.... but how come
reboot(0x1234567) did not flush the buffers properly? I admit that the partition
is not in /etc/fstab, but mounted "manually" by some stupid initscript, but...
I *am* confused.
More information about the Linux-il
mailing list