Documentation/translations/zh_CN/block/data-integrity.rst
Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/block/data-integrity.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/translations/zh_CN/block/data-integrity.rst- Extension
.rst- Size
- 9279 bytes
- Lines
- 192
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
.. SPDX-License-Identifier: GPL-2.0
.. include:: ../disclaimer-zh_CN.rst
:Original: Documentation/block/data-integrity.rst
:翻译:
柯子杰 kezijie <kezijie@leap-io-kernel.com>
:校译:
==========
数据完整性
==========
1. 引言
=======
现代文件系统对数据和元数据都进行了校验和保护以防止数据损坏。然而,这种损坏的
检测是在读取时才进行,这可能发生在数据写入数月之后。到那时,应用程序尝试写入
的原始数据很可能已经丢失。
解决方案是确保磁盘实际存储的内容就是应用程序想存储的。SCSI 协议族(如 SBC
数据完整性字段、SCC 保护提案)以及 SATA/T13(外部路径保护)最近新增的功能,
通过在 I/O 中附加完整性元数据的方式,试图解决这一问题。完整性元数据(在
SCSI 术语中称为保护信息)包括每个扇区的校验和,以及一个递增计数器,用于确保
各扇区按正确顺序被写入盘。在某些保护方案中,还能保证 I/O 写入磁盘的正确位置。
当前的存储控制器和设备实现了多种保护措施,例如校验和和数据清理。但这些技术通
常只在各自的独立域内工作,或最多仅在 I/O 路径的相邻节点之间发挥作用。DIF 及
其它数据完整性拓展有意思的点在于保护格式定义明确,I/O 路径上的每个节点都可以
验证 I/O 的完整性,如检测到损坏可直接拒绝。这不仅可以防止数据损坏,还能够隔
离故障点。
2. 数据完整性拓展
=================
如上所述,这些协议扩展只保护控制器与存储设备之间的路径。然而,许多控制器实际
上允许操作系统与完整性元数据(IMD)交互。我们一直与多家 FC/SAS HBA 厂商合作,
使保护信息能够在其控制器与操作系统之间传输。
SCSI 数据完整性字段通过在每个扇区后附加8字节的保护信息来实现。数据 + 完整
性元数据存储在磁盘的520字节扇区中。数据 + IMD 在控制器与目标设备之间传输
时是交错组合在一起的。T13 提案的方式类似。
由于操作系统处理520字节(甚至 4104 字节)扇区非常不便,我们联系了多家 HBA
厂商,并鼓励它们分离数据与完整性元数据的 scatter-gather lists。
控制器在写入时会将数据缓冲区和完整性元数据缓冲区的数据交错在一起,并在读取时
会拆分它们。这样,Linux 就能直接通过 DMA 将数据缓冲区传输到主机内存或从主机
内存读取,而无需修改页缓存。
此外,SCSI 与 SATA 规范要求的16位 CRC 校验在软件中计算代价较高。基准测试发
现,计算此校验在高负载情形下显著影响系统性能。一些控制器允许在操作系统接口处
使用轻量级校验。例如 Emulex 支持 TCP/IP 校验。操作系统提供的 IP 校验在写入
时会转换为16位 CRC,读取时则相反。这允许 Linux 或应用程序以极低的开销生成
完整性元数据(与软件 RAID5 相当)。
IP 校验在检测位错误方面比 CRC 弱,但关键在于数据缓冲区与完整性元数据缓冲区
的分离。只有这两个不同的缓冲区匹配,I/O 才能完成。
数据与完整性元数据缓冲区的分离以及校验选择被称为数据完整性扩展。由于这些扩展
超出了协议主体(T10、T13)的范围,Oracle 及其合作伙伴正尝试在存储网络行业协
会内对其进行标准化。
3. 内核变更
===========
Linux 中的数据完整性框架允许将保护信息固定到 I/O 上,并在支持该功能的控制器
之间发送和接收。
Annotation
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.