Re: sleep after sync? how to flush all caches?

Adam D. Bradley (artdodge@cs.bu.edu)
Wed, 24 Jun 1998 13:33:27 -0400 (EDT)


On Tue, 23 Jun 1998, Pavel Machek wrote:

> Hi!
>
> >From man 2 sync:
>
> BUGS
> sync() only schedules the writes, so it may return before
> the actual writing is
> done.
>
> Is it true these days?

UNIX98 says:

[I quote]

The sync() function causes all information in memory that updates file
systems to be scheduled for writing out to all file systems.

The writing, although scheduled, is not necessarily complete upon
return from sync().

[end quote]

As I recall, this is still the case with Linux. So the real bug is
that note appearing under "BUGS" instead of "DESCRIPTION".

If you need to force data to completion, fsync() _should_ do what you
need, although there's still (I believe) an issue w/ some queuing
taking place in SCSI devices. Does anyone know if we have support for
sending a "SCSI Hard Flush" command yet? It would be immensely useful
for my XLFS work...

> And one final question: Is there way to force linux forget its disk
> cache? I would like to play with ondemand loading a bit, and I would
> appredicate being able to bring machine into state without cached data
> without reboot.

Look at refill_freelist(), it has the code to discard existing
buffers.

Good luck!
Adam

--
You crucify all honesty             \\Adam D. Bradley  artdodge@cs.bu.edu
No signs you see do you believe      \\Boston University Computer Science
And all your words just twist and turn\\    Grad Student and Linux Hacker
Reviving just to crash and burn        \\                             <><
--------->   Why can't you listen as love screams everywhere?   <--------

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu