Linux file system Barrier: Enabled or disabled

Source: Internet
Author: User
Tags system log



Most of the current popular Linux file systems, including EXT3 and EXT4, use file system barrier as an enhanced security feature. It protects data from being written to the journal. However, in many cases, we do not know whether these barrier are useful. This article explains why you should enable barrier on your Linux system.


Linux logs and barrier features

To understand barrier, you first need to understand the file system log functionality. The common file system uses the log function to ensure file system integrity. The idea behind this feature is simple: The metadata is written to the log before the new block is written to the disk. Pre-writing the metadata to the log guarantees that the log function can be easily rolled back to the state before the change, if an error occurs before and after the actual data is written. This method ensures that file system crashes do not occur.

Using the log function alone does not guarantee that there will be no errors. Most disks now have large caches, and the data is not written to disk immediately, but is written to the disk cache first. At this point, the disk controller will be able to copy it to disk more efficiently. This is good for performance, but the reverse is true for the logging function. To ensure that the log is absolutely reliable, it must ensure that the metadata is pre-written before the actual data is written. This is why we want to introduce the file system barrier.

It is easy to understand the root cause of using barrier: Barrier itself prohibits writing data after barrier, and real chunks are written to disk completely before barrier is written. Using barrier ensures the integrity of the file system, because the barrier feature is enabled by default in the EXT4 file system (unless your operating system changes this default setting).


Linux file system Barrier: Enabled or disabled?

You can monitor the current state of the file system barrier through the/proc/mounts file, and for each mounted file system, open this file to see all of the Mount options. If you see barrier=1, then your file system is using the barrier feature. The following information is an example of a file system:

/dev/sda1/boot ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
/dev/mapper/luks-3e67401f-44c6-4a27-a1bf-cdf0dcf45f65/home ext4 rw,seclabel,noatime,barrier=1,data=ordered 0 0


When does file system barrier work?

The problem with barrier is that it cannot be applied to all conditions. If the device mapper is used as the priority of the storage tier, then file system barrier will not work because the device mapper does not support barrier. So, even if your file system supports barrier by default, you cannot run it on a logical volume, soft raid, or multipath disk (RED hat and all related Linux versions will barrier as the default option).

One solution to this problem is to avoid using device mapper. So when you install the server, you need to take full account of the configuration options. First of all, you should not use LVM to install the server, but should choose to use the traditional partitioning method. Next, you cannot use a Multipath disk that works with the device mapper, which creates multiple redundant paths on the SAN. In some cases, SAN suppliers offer a proprietary drive as a choice, but not all vendors offer this option. The best approach is to use smart hardware.

One of the risks of using barrier protection is that when a system is interrupted, the data is left in the cache and never written to the file system. A simple battery backup controller can avoid this problem. When the controller used by the server fails, the disk controller can still guarantee the change operation, which fully excludes the need for barrier use.

Another disadvantage of using barrier is that you need to pay a price to reduce performance. If you need top performance, then you can use the Mount option-o barrier=0 to turn off the barrier feature, such as: Mount/dev/sda2-o Barrier=0/data.


[Source link]http://blog.sina.com.cn/s/blog_6200c1440100w4mp.html





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.