요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
Block과 transaction 계층
persistent-data.rst:31-54고정 크기 block access, locking, copy-on-write와 commit durability를 제공합니다.
Space map과 B-tree
persistent-data.rst:55-88Reference-count allocator와 여러 64-bit key를 지원하는 중첩 B-tree를 설명합니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
===============
Persistent data
===============
Introduction
============
The more-sophisticated device-mapper targets require complex metadata
that is managed in kernel. In late 2010 we were seeing that various
different targets were rolling their own data structures, for example:
- Mikulas Patocka's multisnap implementation
- Heinz Mauelshagen's thin provisioning target
- Another btree-based caching target posted to dm-devel
- Another multi-snapshot target based on a design of Daniel Phillips
Maintaining these data structures takes a lot of work, so if possible
we'd like to reduce the number.
The persistent-data library is an attempt to provide a re-usable
framework for people who want to store metadata in device-mapper
targets. It's currently used by the thin-provisioning target and an
upcoming hierarchical storage target.
Overview
========
The main documentation is in the header files which can all be found
under drivers/md/persistent-data.
The block manager
-----------------
dm-block-manager.[hc]
This provides access to the data on disk in fixed sized-blocks. There
is a read/write locking interface to prevent concurrent accesses, and
keep data that is being used in the cache.
Clients of persistent-data are unlikely to use this directly.
The transaction manager
-----------------------
dm-transaction-manager.[hc]
This restricts access to blocks and enforces copy-on-write semantics.
The only way you can get hold of a writable block through the
transaction manager is by shadowing an existing block (ie. doing
copy-on-write) or allocating a fresh one. Shadowing is elided within
the same transaction so performance is reasonable. The commit method
ensures that all data is flushed before it writes the superblock.
On power failure your metadata will be as it was when last committed.
The Space Maps
--------------
dm-space-map.h
dm-space-map-metadata.[hc]
dm-space-map-disk.[hc]
On-disk data structures that keep track of reference counts of blocks.
Also acts as the allocator of new blocks. Currently two
implementations: a simpler one for managing blocks on a different
device (eg. thinly-provisioned data blocks); and one for managing
the metadata space. The latter is complicated by the need to store
its own data within the space it's managing.
The data structures
-------------------
dm-btree.[hc]
dm-btree-remove.c
dm-btree-spine.c
dm-btree-internal.h
Currently there is only one data structure, a hierarchical btree.
There are plans to add more. For example, something with an
array-like interface would see a lot of use.
The btree is 'hierarchical' in that you can define it to be composed
of nested btrees, and take multiple keys. For example, the
thin-provisioning target uses a btree with two levels of nesting.
The first maps a device id to a mapping tree, and that in turn maps a
virtual block to a physical block.
Values stored in the btrees can have arbitrary size. Keys are always
64bits, although nesting allows you to use multiple keys.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Device Mapper metadata framework의 배경
1-23정교한 Device Mapper target은 kernel 안에서 관리하는 복잡한 metadata가 필요합니다. 2010년 말에는 서로 다른 target이 각자 data structure를 구현하는 상황이 반복되고 있었습니다.
- Mikulas Patocka의 multisnap 구현
- Heinz Mauelshagen의 thin provisioning target
- `dm-devel`에 게시된 또 다른 B-tree 기반 caching target
- Daniel Phillips의 설계를 바탕으로 한 또 다른 multi-snapshot target
여러 target이 비슷한 persistent metadata 문제를 독립적으로 풀고 있었습니다.
이러한 data structure를 유지하는 데 많은 작업이 필요하므로 가능한 한 구현 수를 줄이고자 했습니다.
`persistent-data` library는 Device Mapper target에서 metadata를 저장하려는 개발자가 재사용할 수 있는 framework를 제공하려는 시도입니다. 현재 thin-provisioning target과 앞으로 제공될 hierarchical storage target이 사용합니다.
Target마다 metadata engine을 다시 만드는 대신 공통 block·transaction·allocation·index 계층을 사용합니다.
고정 크기 block 접근과 cache
24-40주요 문서는 다음 header file directory에서 찾을 수 있습니다.
under drivers/md/persistent-data.
Block manager 구현 파일은 다음과 같습니다.
dm-block-manager.[hc]
Block manager는 disk data를 고정 크기 block 단위로 접근하게 합니다. Concurrent access를 막는 read/write locking interface를 제공하고, 사용 중인 data는 cache에 유지합니다. `persistent-data` client가 이 계층을 직접 사용할 가능성은 낮습니다.
상위 metadata 계층에 안전하고 cache 가능한 block I/O primitive를 제공합니다.
Copy-on-write transaction과 crash consistency
41-54Transaction manager 구현 파일은 다음과 같습니다.
dm-transaction-manager.[hc]
Transaction manager는 block 접근을 제한하고 copy-on-write semantics를 강제합니다. Writable block을 얻는 방법은 기존 block을 shadow하여 copy-on-write를 수행하거나 새 block을 할당하는 것뿐입니다.
같은 transaction 안에서는 중복 shadowing을 생략하므로 성능을 합리적인 수준으로 유지합니다. Commit method는 superblock을 쓰기 전에 모든 data가 flush됐음을 보장합니다. 전원이 끊기면 metadata는 마지막으로 commit한 시점의 상태로 남습니다.
새 metadata tree를 완성하고 durable하게 만든 뒤 마지막에 superblock이 새 상태를 가리키게 합니다.
Reference count와 block allocation
55-68Space map 관련 구현 파일은 다음과 같습니다.
dm-space-map.h
dm-space-map-metadata.[hc]
dm-space-map-disk.[hc]
Space map은 block의 reference count를 추적하는 on-disk data structure이며 새 block allocator 역할도 합니다. 현재 구현은 두 가지입니다.
관리 대상이 data device인지 metadata 자체 공간인지에 따라 구현 복잡도가 달라집니다.
첫 구현은 thinly-provisioned data block처럼 다른 장치의 block을 관리합니다. 두 번째 구현은 metadata space를 관리하며, 자신의 data structure를 자신이 관리하는 바로 그 공간에 저장해야 하므로 더 복잡합니다.
Reference count와 free-space allocation을 하나의 persistent 계층에서 관리합니다.
여러 key를 지원하는 계층형 B-tree
69-88현재 data structure 구현 파일은 다음과 같습니다.
dm-btree.[hc]
dm-btree-remove.c
dm-btree-spine.c
dm-btree-internal.h
현재 제공되는 data structure는 hierarchical B-tree 하나뿐이며, 앞으로 array와 비슷한 interface처럼 활용도가 높은 구조를 더 추가할 계획입니다.
이 B-tree는 B-tree를 중첩해 여러 key를 받을 수 있다는 의미에서 'hierarchical'합니다. Thin-provisioning target은 두 단계로 중첩된 B-tree를 사용합니다. 첫 단계는 device id를 mapping tree로 mapping하고, 그 tree가 다시 virtual block을 physical block으로 mapping합니다.
첫 key가 device별 mapping tree를 고르고 두 번째 key가 실제 data block 위치를 찾습니다.
B-tree에 저장하는 value 크기는 임의로 정할 수 있습니다. Key는 항상 64-bit이지만, tree nesting을 통해 여러 key를 사용할 수 있습니다.
고정 크기 key와 가변 크기 value를 중첩 tree로 조합합니다.
재사용 가능한 metadata framework
persistent-data.rst:1-30여러 target의 중복 metadata 구현을 공통 persistent-data library로 통합합니다.