云计算国产化之路 vnc登录 文件系统直通(virtio-9p) 扩展qemu接口 gpg WARNING 珍藏博客 虚拟内存情况dommemstat分析 免密码自动登录脚本 Linux网桥 测试网段IP占用情况 Linux 进程状态 systemc强制依赖 调试openstack ut uefi p2v 重做ubuntu内核 virsh创建虚拟机简介 virtio IO路径 虚拟化层升级后磁盘无法卸载卷 vmtouch使用 Taint flags 主机和虚拟机文件共享处理的几种方法 kvm分析工具 kvm中对磁盘的io cache 虚拟化不同导致的guestos中软件安装差异(未解决) 设备直通(PCI Assignment)到底是咋整的 virtio到底是咋整的 内核启动参数 虚拟化实时性提升(零)之配置步骤 中断虚拟化(pic)到底是咋整的 中断虚拟化(apic)到底是咋整的 Raid卡配置丢失导致服务器无法启动 tainted kernels cpu stuck for 23s问题分析 虚拟化实时性提升(一)之hostOS切换为强实时系统 内存虚拟化到底是咋整的 qemu-kvm中vcpu虚拟化到底是咋整的 风河虚拟化技术点分析 使用qga的好处 qemu迁移代码分析 虚拟机串口配置及其导出到主机pts和console.log System-based I/O vs. Raw I/O 虚拟机使用Hugepage(大页) 硬件辅助分页(hardware assisted paging) 修改centos7默认启动项目 virtio的工作流程——kernel中virtio-pci初始化(2) virtio的工作流程——qemu中virtio-backend初始化(1) qmp ceilometer取不到memory.usage指标 Virtio-Balloon超详细分析 slabtop输出 虚拟机磁盘cache导致的host os kernel崩溃 虚拟机cpu和memory性能优化测评 PCI配置空间(PCI Configuration Space) centos下网卡设备直通(VT-dpci passthrough)遇到的问题及其解决思路 libguestfs详解 yum卸载软件包及其依赖 通过原始Centos ISO来定制自己的ISO centos下网卡设备直通(VT-d,pci passthrough) (占位符)window虚拟机中拔盘如何通知到libvirt和qemu后端的 cirrus漏洞分析CVE-2017-2615 XSA-208 qcow2随笔 控制寄存器概览 ceilometer对接postgresql 解压initrd和vmlinuz qemu guest agent验证 QEMU升级指南(待续) ubuntu中kdump的配置 qemu(2.3)接口梳理 热迁移导致的FC存储场景下的multipath卷残留问题分析 virsh命令(4)secret,snapshot,pool,volume部分 virsh命令(3)之interface,filter,network virsh命令(2)monitor,host,nodedev部分 virsh命令(1)之domain部分 QEMU内存管理之FlatView模型(QEMU2.0.0) ovirt基于sanock的高可用(主机粒度HA) Sanlock防脑裂场景功能测试用例 gnocchi配置及与ceilometer对接指南 make patch for libvirt in centos centos使用sanlock指导 高可用nfs资料 ubuntu14中使用sanlock指导 LVM操作指南 sanlock相关功能验证流程汇总 make patch for libvirt in ubuntu libvirt.so.0-version `LIBVIRT_PRIVATE_1.2.7' not found gdb debug libvirt 基于ubuntu社区源码包编译libvirt compile libvirt(centos) No PCI buses available nfs lead to Linux halt nfs install and config anti-virus for cloud platform nova fetch image from glance(something about _base) token auth process ovs入门指南 virt software anti-virus something about ceilometer disk sample context interview questions openstack vm injection openstack Restful and RPC murano 概览 创建虚拟机流程(compute节点)之网络创建 创建虚拟机流程之compute_api之虚拟机实例填充之配额检测 创建虚拟机流程之compute_api之基本参数生成 创建虚拟机流程之compute_api 创建虚拟机流程(主) 创建虚拟机之image 创建虚拟机流程之准备网桥 创建虚拟机流程之virt 创建虚拟机流程之compute节点 CI/CD研发流程之工程创建 CI/CD研发流程之代码合入 CI/CD研发流程之UT(单元测试) 向openstack社区合入代码记 openstack/ceilometer/gnocchi杂谈 影子页表原理 mem_add(exec.c) qemu编译安装调试 openstack/ceilometer/gnocchi之Grafana简介 openstack wiki etcd openstack计量ceilometer openstack计费cloudKitty enventlet backdoor USB 安装VMWARE ESX pycharm设置指南 无法执行modprobe -a kvm-intel解决办法 QEMU配置项 网络不通小记 libvirt之XML(虚拟机定义文件) openstack-horizon 证书认证 ceilometer与ceph对接 openstack定时任务剖析(TODO) 服务器重启后mongodb进程无法启动 ubuntu14下新增openstack服务到service的导引 ERROR 1045(28000)-数据库连不上 Python两个内置函数—locals和globals unknown exit, hardware reason 31

System-based I/O vs. Raw I/O

2017年04月06日

背景

本文讲述了传统的io和rawio的区别
简述了rawio的产生原因及其实现原理
本文转自这里

Before version 2.2, the Linux kernel supported only one type of disk

I/O – system-based I/O in which a process interacts with a physical

device through an intermediary kernel buffer. This intermediary buffer

is transparent to the user: calls to read() write() lseek() etc., seem

as if they access a physical file directly. In practice, however, the

kernel intercepts the calls and transfers the data to its own buffer

before passing it on to the physical device or process. System-based

I/O offers several advantages. The kernel can cache data and thus

reduce the overall physical I/O operations needed; the kernel controls

the overall system performance because it won’t allow an on-the-loose

process to starve other processes. Finally, certain devices are fussy

about the size of data being written or read (for instance, disk drives

usually handle fixed size chunks of 512 bytes on each I/O operation).

The kernel hides these physical limitations from the user. In raw disk

I/O, the process interacts with a physical device directly, without the

kernel’s brokerage.

Uses of raw disk I/O

Although the traditional system-based I/O is satisfactory in most

cases, some applications must use raw I/O. One common scenario is in

data-critical applications, where the user wants to ensure that the

data is written to a disk immediately so that it isn’t lost in the

event of a system failure. Specialized applications, say a relational

database engine, often use their own I/O caching algorithms. In such

applications, the overhead of the kernel’s caching is uncalled for.

Raw I/O Past, Present, and Future

The concept of raw disk I/O is hardly new. Several attempts have been

made in the past to introduce raw I/O to Unix. Indeed, quite a few

variants such as IBM’s AIX now support it. The problem, however, is

that most existing implementations require literally doubling the

number of device nodes. Linux creators rejected this approach. Instead,

kernel 2.4 uses a pool of device nodes that can be associated with any

arbitrary block device. A new object called “kiobuf” was introduced. A

kiobuf is an abstraction of a set of kernel pages set up during boot

time. Raw I/O is achieved by creating a kiobuf and populating it with

the physical pages a given process is using for I/O, without any

intermediate copies.

The kiobuf object is then passed to the I/O layers for reading and

writing. The current Linux implementation isn’t perfect yet but it’s

constantly improving. For further information, you can subscribe to the

kiobuf-io-devel list server or read prior postings here:

http://lists.sourceforge.net/lists/listinfo/kiobuf-io-devel