Re: Is there a way to flush the file cache?




Tony Lawrence wrote:
zentara@xxxxxxxxxxxxxx wrote:
On 28 Dec 2006 21:56:41 GMT, General Schvantzkoph
<schvantzkoph@xxxxxxxxx> wrote:

What I want to do is the following,

1) Create a file and write it to the disk.
2) Read that file off of the disk and then check it.

I'm trying to check the SATA interfaces so it's important that the file go
to and from the disks. The file cache interferes with this because if the
file is present in the cache the program will get the cached copy not the
copy that is on the disk. The sync() call forces the disk writes to happen
immediately which is half of the battle. The other half is to purge the
file cache so that all subsequent file reads come from the disk. Is there
a way to do this?

Dosn't the 'sync' command do this?

Maybe. In traditional Unix, sync is a REQUEST to the kernel to flush
data. That the data is actually written right then is almost always
reasonable to assume, but isn't something you'd put your life on the
line over.

And we can't forget that almost all disk drives have some caching
themselves, even if only momentary. I just did a quick Google and it
looks like most SATA drives have 8-16 MB of cache.

Back to my original reaction: any given app might implement its own
cache, either through STDIO or its own buffers, and "sync" doesn't help
you there.

I have to assume that the reason for this question has something to do
with data integrity: the op wants to be certain data is safely stored
on magnetic media. Given all the places the data could be until it
gets there, I'd say a UPS is mandatory.

--

.



Relevant Pages

  • Re: Caching control
    ... |> | invalidate/unmap them in order to discard the data from memory. ... |> writing out to disk. ... | easy to discard as clean disk cache. ... stating that a specific amount of RAM can be used only for I/O ...
    (comp.os.linux.development.system)
  • PROBLEM: sata_sil24 lockups under heavy i/o
    ... a total of 4) and started heavy i/o (extending a software raid5 device) ... system recovers the disk transfer speed is reduced from UDMA/100 to ... Cache Line Size: 32 bytes ... parport_pc: Current parallel port base: 0x378 ...
    (Linux-Kernel)
  • Re: Scheduler: Process priority fed back to parent?
    ... Mac OS X has a special cache ... on disk of things that get loaded on boot. ... >>initial priority is a guess, and isn't set until the priority info has ... This prefetch activity could be turned on/off ...
    (Linux-Kernel)
  • Re: Pull request for FS-Cache, including NFS patches
    ... Would a disk cache on SSD make any sense? ... including NFS patches ... Allow you to reduce the latency of slow network links by diverting ...
    (Linux-Kernel)
  • Re: 2 questions: IWP, and indexing
    ... using GTRR script steps in the web interface. ... I have a portal on the student layout that shows enrollment ... "Flush Cache to Disk performs an immediate flush of the FileMaker Pro ...
    (comp.databases.filemaker)