lkml.org 
[lkml]   [2007]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectHow to flush the disk write cache from userspace
Date
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.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-01-14 05:33    [W:0.042 / U:0.732 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site