LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* How to flush the disk write cache from userspace
@ 2007-01-14  4:05 Ricardo Correia
  2007-01-16  0:38 ` Jens Axboe
  0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Correia @ 2007-01-14  4:05 UTC (permalink / raw)
  To: linux-kernel

Hi, (please CC: to my email address, I'm not subscribed)

Quick question: how can I flush the disk write cache from userspace?

Long question:

I'm porting the Solaris ZFS filesystem to the FUSE/Linux filesystem framework.
This is a copy-on-write, transactional filesystem and so it needs to ensure 
correct ordering of writes when transactions are written to disk.

At the moment, when transactions end, I'm using a fsync() on the block device 
followed by a ioctl(BLKFLSBUF).

This is because, according to the fsync manpage, even after fsync() returns, 
data might still be in the disk write cache, so fsync by itself doesn't 
guarantee data safety on power failure.

I was looking for something like the Solaris ioctl(DKIOCFLUSHWRITECACHE), 
which does exactly what I need.

The most similar thing I could find was ioctl(BLKFLSBUF), however a search for 
BLKFLSBUF on the Linux 2.6.15 source doesn't seem to return anything related 
to IDE or SCSI disks.

Can I trust ioctl(BLKFLSBUF) to flush disks' write caches (for disks that 
follow the specs)?

What about block devices of disk partitions, LVM logical volumes and the EMVS 
volumes, do they propagate flush commands to the respective disks?

What about loop devices?

Thanks in advance.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-01-21  4:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <fa.y+HJNAxqDqX5AHUxcmThAo20Ivo@ifi.uio.no>
     [not found] ` <fa.xbdrjhFpvWMJeTroG2DpPE4wd+M@ifi.uio.no>
     [not found]   ` <fa.lqQRZqIqMX2chyIAM888fc1jCuY@ifi.uio.no>
2007-01-19  0:35     ` How to flush the disk write cache from userspace Robert Hancock
2007-01-21  3:50       ` Jens Axboe
2007-01-14  4:05 Ricardo Correia
2007-01-16  0:38 ` Jens Axboe
2007-01-18  1:15   ` Ricardo Correia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).