Re: Why is one sync() not enough?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/14/05, Martin Waitz <[email protected]> wrote:
> hoi :)
> 
> On Tue, Jun 14, 2005 at 11:41:41AM +0200, Nico Schottelius wrote:
> > 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.
> 
> unmounting the filesystem writes to the disk.
> If you don't wait for those writes to reach the disk, then
> you still have a dirty filesystem.
> 

If I remember correctly, sync (at least in the past) schedules the
dumping of buffers to disk, but may return before everything is
actually written. Thus it was common in ages past to run  sync ; sync
; halt  when shutting down a system since even though the first sync
might return before writing was done, the second sync wouldn't start
before the first was really done, thus when the second sync returned
you'd know that at least the first one had completed.
I believe sync in recent Linux's actually waits for the data to be
written and never returns early, so I don't think this is relevant any
more - and everyone uses shutdown these days anyway. But go read the
implementation of sync if you really want to know.

-- 
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux