Linux write barriers, write caching, LVM, and filesystems

Write barriers have gotten some discussion in the Linux world recently which is a good thing due to a lack of documentation about what write barriers are and when they should be used. Let's first start with the assumption that a user wants file system integrity over performance. This often means turning off write caching on all disks. The reason is that file systems rely on the disks not reordering write requests in order to maintain the integrity of the file system. Of course, turning off write caching harms write performance substantially so another option was invented: write barriers.

Write barriers allow write caching to be enabled on the disk. A write barrier is a particular request to the disk which the disk cannot reorder requests around. In other words the disk must finish writing everything to the disk before the barrier before anything after the barrier. Of course this takes a toll on performance as well but not nearly so much as disabling write caching entirely.

Now here's where things get tricky. You can only use write barriers if all of the various io systems support the requests. Most notably the device mapper subsystem does not. That means you cannot use write barriers with dm-raid, dm-crypt, or LVM. You also cannot use it with md-raid except for RAID 1. To use any of these systems on a server one must resort to disabling write caching on all disks to preserve disk integrity.

Trackback URL for this post:

http://hightechsorcery.com/trackback/153
Creative Commons License Except where otherwise noted, content on this site is licensed under a Creative Commons by-nc-sa 3.0 License