当ext4底下的块设备的易失缓存没有掉电保护时, 开启barrier=1的话, 可以确保jbd操作的安全性, 即EXT4文件系统的日志安全, 也就是说当异常DOWN机, 并且我们使用了没有掉电保护的块设备缓存时, 还能恢复到一致性状态.
jbd + barrier=1 + 没用掉电保护的块设备缓存 = 安全. (如果你发现dmesg日志中出现disable barrier的情况, 可能是IO stack不支持barrier, 那么如果启用没有掉电保护的块设备缓存就不安全了)
还有一种情况是块设备缓存有掉电保护模块(电池), 那么可以关闭barrier, 来获得更好的性能.
barrier=0 / barrier=1 / barrier / nobarrier
This enables/disables the use of write barriers in the jbd code. barrier=0 disables, barrier=1 enables.
This also requires an IO stack which can support barriers, and if jbd gets an error on a barrier write,
it will disable again with a warning. Write barriers enforce proper on-disk ordering of journal com-
mits, making volatile disk write caches safe to use, at some performance penalty. If your disks are
battery-backed in one way or another, disabling barriers may safely improve performance. The mount
options "barrier" and "nobarrier" can also be used to enable or disable barriers, for consistency with
other ext4 mount options.
The ext4 filesystem enables write barriers by default.
[参考]
1. man mount
2. http://blog.163.com/digoal@126/blog/static/16387704020147296454118/
时间: 2025-01-02 19:35:56