第一,先探讨一个问题,一个写IO的流程,什么样就算完成一次IO操做了。html
"Disk Caches,磁盘高速缓存。
将磁盘上的数据缓存在内存中,加速文件的读写。实际上,在通常状况下,
read/write是只跟缓存打交道的。(固然,存在特殊状况。下面会说到。)
read就直接从缓存读数据。若是要读的数据还不在缓存中,则触发一次读盘操做,而后等待磁盘上的数据被更新到磁盘高速缓存中;
write也是直接写到缓存里去,而后就不用管了。后续内核会负责将数据写回磁盘。
既然磁盘高速缓存提供了有利于提升读写效率的缓存机制,为何又要使用O_DIRECT选项来绕开它呢?
通常状况下,这样作的应用程序会本身在用户态维护一套更利于应用程序使用的专用的缓存机制,
用以取代内核提供的磁盘高速缓存这种通用的缓存机制。"
第二,GFS2使用了磁盘高速缓存了吗?
GFS2像其它文件系统同样是使用了高速缓存的。
2.5.2. VFS Tuning Options: Research and Experiment
Like all Linux file systems, GFS2 sits on top of a layer called the virtual file system (VFS). You can tune the VFS layer to improve underlying GFS2 performance by using the
sysctl
(8) command. For example, the values for
dirty_background_ratio
and
vfs_cache_pressure
may be adjusted depending on your situation. To fetch the current values, use the following commands:
#
# sysctl -n vm.dirty_background_ratiosysctl -n vm.vfs_cache_pressure
The following commands adjust the values:
#
# sysctl -w vm.dirty_background_ratio=20sysctl -w vm.vfs_cache_pressure=500
You can permanently change the values of these parameters by editing the
/etc/sysctl.conf
file.
综合上面两个问题,GFS2使用了高速缓存,当拔掉正在写数据的机器的网线时,虚拟IP漂到其它机器上了。不过拔掉网线的机器仍然在写数据,新接管的机器也在写数据。
当从新插上网线后,两个节点上的数据就不一致了。这只是分析的结论,须要测试验证。
FYI:
写的两种方式:Write Through和Write back
对磁盘写方式的查看方法:
# hdparm -W /dev/sda
/dev/sda:
write-caching = 1 (on)
# hdparm -W0 /dev/sda
/dev/sda:
setting drive write-caching to 0 (off)
write-caching = 0 (off)
# hdparm -W /dev/sda
/dev/sda:
write-caching = 0 (off)