JF Linux Kernel 2.6 Documentation: /usr/src/linux/Documentation/device-mapper/snapshot.txt

device-mapper/snapshot.txt

Linux 2.6 のデバイスマッパーによる LVM のスナップショット機能の解説 [プレインテキスト版]


Device-mapper snapshot support
==============================

デバイスマッパー スナップショットサポート
=========================================

Device-mapper allows you, without massive data copying:

デバイスマッパーは巨大なデータコピーなしで下記を可能にします:

*) To create snapshots of any block device i.e. mountable, saved states of
the block device which are also writable without interfering with the
original content;

*) あらゆるブロックデバイスのスナップショット (=マウント可能で、元の
内容に影響を与えない書き込みも可能なブロックデバイスの保存された状態) 
の作成

*) To create device "forks", i.e. multiple different versions of the
same data stream.

*) デバイスの「分岐」(=同じデータストリームの複数の異なるバージョン)
の作成

In both cases, dm copies only the chunks of data that get changed and
uses a separate copy-on-write (COW) block device for storage.

どちらの場合でも、デバイスマッパーは変更されたデータの塊(chunk:訳注 
1) とストレージに分離された copy-on-write (COW:訳注 2) ブロックデバイ
スのみコピーします。

訳注 1: ブロックデバイスにおけるブロックの単位集合数を示す用語。ディス
クアクセス時など、ある程度まとまった数のブロック I/O があった方が性能
が出たり管理領域が節約できたりするが、その際の単位ブロック数を指す。
ファイルシステムやソフトウェア RAID のドキュメント参照。

訳注 2: copy-on-write (COW) …書き込みによるデータ更新があった部分だけ
新たに領域を確保してそこに更新データを書き込む方式の事。更新のない部分
は元の領域を使用する為、無駄が少ない。Linux のメモリ管理や各種仮想マシ
ンのディスクスナップショット等のドキュメント参照。

There are two dm targets available: snapshot and snapshot-origin.
2つのデバイスマッパーターゲット(snapshot, snapshot-origin)が利用可能
です。

*) snapshot-origin <origin>

which will normally have one or more snapshots based on it.
Reads will be mapped directly to the backing device. For each write, the
original data will be saved in the <COW device> of each snapshot to keep
its visible content unchanged, at least until the <COW device> fills up.

これは通常オリジナルに1つまたはそれ以上のスナップショットがあります。
読み込みは直接バックアップデバイスにマッピングされます。各書き込みでは、
見た目の内容に変更ないように、少なくとも <COW デバイス> がいっぱいにな
るまでオリジナルデータを各スナップショットの <COW デバイス> に保存しま
す。

*) snapshot <origin> <COW device> <persistent?> <chunksize>

A snapshot of the <origin> block device is created. Changed chunks of
<chunksize> sectors will be stored on the <COW device>.  Writes will
only go to the <COW device>.  Reads will come from the <COW device> or
from <origin> for unchanged data.  <COW device> will often be
smaller than the origin and if it fills up the snapshot will become
useless and be disabled, returning errors.  So it is important to monitor
the amount of free space and expand the <COW device> before it fills up.

<元の>ブロックデバイスのスナップショットが作られます。<chunksize>セク
タ (訳注3) 変更されたチャンクが <COW デバイス> 上に保存されます。書き
込みは単に <COW デバイス> 上に行きます。読み込みは <COW デバイス> また
は無変更データは <origin> から行われます。<COW デバイス> はしばしば 
origin より小さく、これがいっぱいになったら snapshot は使いものになら
ず、無効化されてしまい、エラーが返されます。なので、空きスペースの量の
監視と、いっぱいになる前の <COW デバイス> の拡張は重要です。

訳注3:1セクタ=ここでは 512 バイト

<persistent?> is P (Persistent) or N (Not persistent - will not survive
after reboot).

<persistent?> は P (Persistent=永続) または N (Not persistent=非永続
=再起動後は残らない) です。

The difference is that for transient snapshots less metadata must be
saved on disk - they can be kept in memory by the kernel.

これらの違いは、一時的スナップショットの為にはディスクに保存されるメタ
データがより小さい=これらはカーネルによってメモリ上に保存されるという
事です。

How this is used by LVM2
========================

LVM2 でのスナップショットの使い方
=================================

When you create the first LVM2 snapshot of a volume, four dm devices are used:

最初にあるボリュームの LVM2 スナップショットを作成する際、4つのデバイ
スマッパーデバイスが使用されます。

1) a device containing the original mapping table of the source volume;

1) ソースボリュームの元々のマッピングテーブルを持つデバイス

2) a device used as the <COW device>;

2) <COW デバイス> として使われるデバイス

3) a "snapshot" device, combining #1 and #2, which is the visible snapshot
   volume;

3) 可視スナップショットボリュームとしての「スナップショット」デバイス
   (1 と 2 の組み合わせ)

4) the "original" volume (which uses the device number used by the original
   source volume), whose table is replaced by a "snapshot-origin" mapping
   from device #1.

4) 1番目のデバイスから「snapshot-origin」マッピングにテーブルが置換さ
   れた「元々のボリューム」(元々のソースボリュームが使っていたデバイス
   番号を使用する)

A fixed naming scheme is used, so with the following commands:

固定命名規則が使用されるので、次のコマンドでは:

lvcreate -L 1G -n base volumeGroup
lvcreate -L 100M --snapshot -n snap volumeGroup/base

we'll have this situation (with volumes in above order):

こんな状態になります (ボリュームが下記の順番):

# dmsetup table|grep volumeGroup
volumeGroup-base-real: 0 2097152 linear 8:19 384
volumeGroup-snap-cow: 0 204800 linear 8:19 2097536
volumeGroup-snap: 0 2097152 snapshot 254:11 254:12 P 16
volumeGroup-base: 0 2097152 snapshot-origin 254:11

# ls -lL /dev/mapper/volumeGroup-*
brw-------  1 root root 254, 11 29 ago 18:15 /dev/mapper/volumeGroup-base-real
brw-------  1 root root 254, 12 29 ago 18:15 /dev/mapper/volumeGroup-snap-cow
brw-------  1 root root 254, 13 29 ago 18:15 /dev/mapper/volumeGroup-snap
brw-------  1 root root 254, 10 29 ago 18:14 /dev/mapper/volumeGroup-base

Linux カーネル 2.6 付属文書一覧へ戻る