disk io 与 GFS2 使用

第一,先探讨一个问题,一个写IO的流程,什么样就算完成一次IO操作了。

"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_ratio
# sysctl -n vm.vfs_cache_pressure
The following commands adjust the values:
# sysctl -w vm.dirty_background_ratio=20
# sysctl -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)
 

猜你喜欢

转载自www.cnblogs.com/longchang/p/11096241.html
今日推荐