public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jesper Juhl <jesper.juhl@gmail.com>
To: Nico Schottelius <nico-kernel@schottelius.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Why is one sync() not enough?
Date: Tue, 14 Jun 2005 17:58:36 +0200	[thread overview]
Message-ID: <9a87484905061408585c52f96b@mail.gmail.com> (raw)
In-Reply-To: <20050614125828.GM446@admingilde.org>

On 6/14/05, Martin Waitz <tali@admingilde.org> 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 <jesper.juhl@gmail.com>
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

  reply	other threads:[~2005-06-14 15:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-14  9:41 Why is one sync() not enough? Nico Schottelius
2005-06-14 12:58 ` Martin Waitz
2005-06-14 15:58   ` Jesper Juhl [this message]
2005-06-14 18:36     ` Valdis.Kletnieks
2005-06-15  6:19     ` Nico Schottelius
2005-06-15  4:50 ` Andrew Morton
2005-06-15  3:39   ` jmerkey
2005-06-15  8:20   ` Bernd Eckenfels
2005-06-15 10:55   ` Nico Schottelius
2005-06-15 19:41     ` Andrew Morton
2005-06-15  8:17 ` Helge Hafting
2005-06-15  9:28   ` Denis Vlasenko
2005-06-15  9:43     ` Coywolf Qi Hunt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a87484905061408585c52f96b@mail.gmail.com \
    --to=jesper.juhl@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nico-kernel@schottelius.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox