Re: Why is one sync() not enough?

From: Helge Hafting
Date: Wed Jun 15 2005 - 03:13:54 EST


Nico Schottelius wrote:

Hello again!

When my system shuts down and init calls sync() and after that
umount and then reboot, the filesystem is left in an unclean state.

If I do sync() two times (one before umount, one after umount) it
seems to work.

Can someboy explain that to me?


You shouldn't need those syncs, as umount does its own
syncing. There may be other explanations:

* Your reboot actually powers down (or resets) the disk.
IDE disks are known for caching stuff, they may indicate
that data is written slightly before it actually happens.
(The same applies to scsi - if you enable caching there for
the little extra performance it buys.)

Rebooting really quickly after umount in such a case can cut
power to the disk before it finishes writing. If this is the case,
then a few seconds of sleep after umount before reboot
will work just as well as that sync. I don't recommend this
as a solution, but it is an easy diagnostic!

* Your startup script accidentally mounted the fs twice.
(Yes - linux support that, and the first umount won't undo
both mounts.) This simply means the fs isn't umounted
when you reboot, but an extra sync and you might get lucky.

Check to see that nothing at all is mounted as you reboot.

Helge Hafting
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/