不同的操作系统其io架构是不同,想更好的优化IO问题,掌握系统的IO架构会非常有用;下面对操作系统的IO架构做下简单总结;
UNIX
上图为 unix 的IO 架构;
Application/DB:
此处是 IO 请求的起点;应用层的IO包括:
IOPS
吞吐量
IO大小
读比率
磁盘空间的大小
I/O system calls layer:此层由OS提供,并通过系统调用将应用的IO请求发送到存储;默认情况下,I/O的操作都同步的;目前许多操作系统已经提供异步IO;
File system layer:
文件系统是 操作系统用来以文件的方式 组织和管理 系统数据的,文件系统本身可以支持 buffered 或者unbuffered IO;
Volume manager layer:
用来将IO负载分散到不同的LUN上,
Multipathing/Disk layer:
多路径可以分为以下类型:hardware multipath
Software path
Operation multipath
FC adapter:与操作系统和 存储厂商有关;
Fabric layer: san中用来连接存储设备的和服务器的
Array:具体的存储;
WINDOWS:
Windows 的IO架构,与unix 类似,需要注意的是,windows 的文件系统和unix 并不通用;
Linux:
Linux中整个Io过程大致如下:
1. A process requests to write a file through the write() system call.
2. The kernel updates the page cache mapped to the file.
3. A pdflush kernel thread takes care of flushing the page cache to disk.
4. The filesystem layer puts each block buffer together to a bio struct (see 12.2.3, “Block
layer” on page 449) and submits a write request to the block device layer.
5. The block device layer gets requests from upper layers and performs an I/O elevator
operation and puts the requests into the I/O request queue.
6. A device driver, such as Small Computer System Interface (SCSI) or other device-specific
drivers, takes care of the write operation. The SCSI subsystem contains three layers:
upper layer (block, tape, and generic), midlayer (common SCSI operations), and device
driver layer. See 12.2.4, “I/O device driver” on page 450.
7. A disk device firmware performs hardware operations, such as seek head, rotation, and
data transfer to the sector on the platter.
以上只是对io的简单总结,如果有兴趣还可以参考mos文档,ixora.com,IBM redbook, 虚拟内存架构等资料,这样才能对整个IO有一个完整的理解;