Copy-On-Write Strategy in ZFS

本文介绍了ZFS这一基于交易的文件系统,它结合了文件系统和卷管理器的功能,并通过数据管理单元(DMU)实现了所有交易的原子性,确保数据一致性。ZFS采用写时复制的操作方式,在修改数据时不会直接改动原有数据块,而是将更改后的信息写入新的数据块中,从而避免了数据不一致的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



 http://blogs.sun.com/bjoyes/entry/zfs

 

Zfs is a transaction-based filesystem, as ZFS makes copy-on-write operations when there are modifications of files from filesystems, by transactions. This means that we theorically should have on disks at a given moment a  kind of versioning of data, so an image of the data before file modification, or after, but never while the modification, so that filesystem inconsistency is normally impossible.

The transactionnal mode also means that when transaction is committed on disks, it is committed on the whole pool in an atomic way meaning that all pointers to data are updated in the same time, the uberblock and checksum for blocks too.

Here is a fantastic and very clear schema and explanation I'd like to copy from http://www.sun.com/bigadmin/.

Transaction-Based Copy-on-Write Operations

ZFS is a combination of file system and volume manager; the file system-level commands require no concept of the underlying physical disks because of storage pool virtualization. All of the high-level interactions occur through the data management unit (DMU), a concept similar to a memory management unit (MMU), only for disks instead of RAM. All of the transactions committed through the DMU are atomic, so data is never left in an inconsistent state.

In addition to being a transaction-based file system, ZFS only performs copy-on-write operations. This means that the blocks containing the in-use data on disk are never modified. The changed information is written to alternate blocks, and the block pointer to the in-use data is only moved once the write transactions are complete. This happens all the way up the file system block structure to the top block, called the uberblock.

As shown in Figure 1, transactions select unused blocks to write modified data and only then change the location to which the preceding block points.

Figure 1: Copy-On-Write Transactions
Image source: Jeff Bonwick

If the machine were to suffer a power outage in the middle of a data write, no corruption occurs because the pointer to the "good" data is not moved until the entire write is complete. (Note: The pointer to the data is the only thing that is moved.) This eliminates the need for a journaling or logging file system and any need for a fsck or mirror resync when a machine reboots unexpectedly.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值