dmsetup:持久元数据存储在哪里?

dmsetup:持久元数据存储在哪里?

dmsetup快照文档说:

<persistent?> is P (Persistent) or N (Not persistent - will not survive
after reboot).  O (Overflow) can be added as a persistent store option
to allow userspace to advertise its support for seeing "Overflow" in the
snapshot status.  So supported store types are "P", "PO" and "N".

The difference between persistent and transient is with transient
snapshots less metadata must be saved on disk - they can be kept in
memory by the kernel.

这些持久数据存储在哪里?

答案1

持久快照设备与瞬态快照设备的第一个块中的数据之间存在差异dmsetup

鉴于这些设备:

$ losetup
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                         DIO
/dev/loop1         0      0         0  0 /home/var/ravi/tmp/issue/snap-dev   0
/dev/loop0         0      0         0  0 /home/var/ravi/tmp/issue/base-dev   0

以及最初清零的快照设备支持文件:

$ od -xc snap-dev
0000000    0000    0000    0000    0000    0000    0000    0000    0000
         \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
*
3751613000

使用非持久N标志时会发生以下情况:

$ sudo dmsetup -v create snapdev --table '0 8 snapshot /dev/loop0 /dev/loop1 N 1'
Name:              snapdev
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        0
Event number:      0
Major, minor:      254, 5
Number of targets: 1

$ od -xc snap-dev
0000000    0000    0000    0000    0000    0000    0000    0000    0000
         \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
*
3751613000

请注意,后备文件未更改 - 它仍然是\0字节。

现在,再次尝试使用P持久性标志:

$ sudo dmsetup remove snapdev
$ sudo dmsetup -v create snapdev --table '0 8 snapshot /dev/loop0 /dev/loop1 P 1'
Name:              snapdev
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        0
Event number:      0
Major, minor:      254, 5
Number of targets: 1

$ od -xc snap-dev
0000000    6e53    7041    0001    0000    0001    0000    0001    0000
          S   n   A   p 001  \0  \0  \0 001  \0  \0  \0 001  \0  \0  \0
0000020    0000    0000    0000    0000    0000    0000    0000    0000
         \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
*
3751613000

在这种情况下,设备的第一个字节是SnAp\001


我的猜测是,持久数据存储在快照设备本身的第一个块或多个块中。

相关内容