# Any point in using O_FSYNC on open()?



## jostrowski (Jan 24, 2009)

Can anyone tell me if there is any point in using the O_FSYNC flag when opening files on disks in FreeBSD since FreeBSD sees disks as character devices rather than block devices? I see the flag is still available. 

  From what I've read, the buffer cache for disks was removed in FreeBSD post ver 3.x.


----------



## Maledictus (Jan 24, 2009)

What should it have to do with block devices? Just expect that it works as documented regardless of the underlying type in the fs.


----------



## Djn (Jan 25, 2009)

There are other caches in the system, so I'd assume it still does something. (For one thing, I believe writes are kept in memory a bit to allow gathering them into more effective disk operations.)


----------



## Maledictus (Jan 25, 2009)

afaik that's not allowed with O_FSYNC. What the system does depends on the underlying FS. So there are differences for UFS or UFS+Softupdates or ZFS.


----------



## Djn (Jan 25, 2009)

Maledictus said:
			
		

> afaik that's not allowed with O_FSYNC.



My point exactly.


----------



## jostrowski (Jan 25, 2009)

*re: Any point in using O_FSYNC on open()*

Thanks for the responses. Yeah those are my thoughts, too. I was just trying to reconcile it with what I was reading in the Developer's Handbook:

http://freebsd.active-venture.com/arch-handbook/driverbasics-block.html

  After reading that, I wondered what part of the kernel the "buffer cache" is referring to. Perhaps there are a couple of different caches, and just one was eliminated.


----------



## trasz@ (Jan 27, 2009)

@jostrowski: Exactly.  What was removed was buffer cache, which was a cache below the filesystem.  What is left is page cache, which is a cache above the filesystem.  So, data is still being buffered in memory.  The buffer cache was just redundant, so got removed.


----------

