fsync(2) and on-disk write-back cache

Gary Jennejohn gljennjohn at googlemail.com
Tue Aug 31 10:08:30 UTC 2010


On Mon, 30 Aug 2010 18:58:42 -0400
Martin Cracauer <cracauer at cons.org> wrote:

> I always assumed the answer to this question is "of course":
> 
> When doing an fsync (waiting for the commit), do we actually tell the
> disk to flush the on-disk write-back cache (if that is in use) to the
> platters?
> 
> I just went down some code paths in both FreeBSD and Linux and in both
> cases the paths for fsync quickly disappear in the generic
> block-by-block flushing code that is also used for regular (non-fsync)
> flushing.  I didn't see anything aware of the on-disk cache.
> 

I may be wrong, but it seems to me that the actual cache flush on the
disk is handled at a very low level - in the drivers.

At least I'm pretty certain that e.g. the ahci code sends flush commands
to the disks.

--
Gary Jennejohn


More information about the freebsd-fs mailing list