How to create metadata-snap for thin tools using?
Closed this issue · 3 comments
Hi @jthornber,
I have a thin pool and thin devs in it. I want to use thin_ls
to list the thin devs from the metadata dev
as below:
# thin_ls /dev/mapper/vg0-mythinpool_tmeta
syscall 'open' failed: Device or resource busy
Note: you cannot run this tool with these options on live metadata.
# thin_ls --metadata-snap /dev/mapper/vg0-mythinpool_tmeta
no current metadata snap
When using lvm tools to create snap on metadata lv:
# lvcreate -L1G -n matadata-snap -s vg0/mythinpool_tmeta
Snapshots of hidden volumes are not supported.
When using dmsetup:
dmsetup message /dev/mapper/vg0-mythinpool 0 "create_snap metadata_snap vg0-mythinpool_tmeta"
device-mapper: message ioctl on vg0-mythinpool failed: invalid ...
I know all these can be done by lvm, but I'm thinking about to use dmsetup+thin_xxx
to replace lvm. dmsetup can not list thin devs on metadata disk, so I'm trying to list them by thin_ls :-)
Thanks,
Eric
Hi,
After deactivating all LVs and create the metadata dev using dmsetup, I can use thin_ls/thin_dump to get what I want, but still don't know how to snap metadata dev
easily when LVs are active.
[root@iZuf6dbyd7ede51sykedamZ ~]# dmsetup create vg0-mythinpool_tmeta --table "0 4194304 striped 2 128 253:16 264192 253:32 264192"
[root@iZuf6dbyd7ede51sykedamZ ~]# dmsetup ls
vg0-mythinpool_tmeta (252:0)
[root@iZuf6dbyd7ede51sykedamZ ~]# thin_ls /dev/mapper/vg0-mythinpool_tmeta
DEV MAPPED CREATE_TIME SNAP_TIME
1 134MiB 0 12
2 0 11 11
[root@iZuf6dbyd7ede51sykedamZ ~]# thin_dump /dev/mapper/vg0-mythinpool_tmeta
<superblock uuid="" time="15" transaction="32" flags="0" version="2" data_block_size="256" nr_data_blocks="8337344">
<device dev_id="1" mapped_blocks="1072" transaction="0" creation_time="0" snap_time="12">
<range_mapping origin_begin="0" data_begin="0" length="34" time="0"/>
<single_mapping origin_block="289" data_block="34" time="0"/>
<single_mapping origin_block="1024" data_block="35" time="0"/>
<single_mapping origin_block="3072" data_block="36" time="0"/>
<single_mapping origin_block="5120" data_block="37" time="0"/>
<single_mapping origin_block="7168" data_block="38" time="0"/>
<single_mapping origin_block="9216" data_block="39" time="0"/>
<single_mapping origin_block="16384" data_block="40" time="0"/>
<single_mapping origin_block="25600" data_block="41" time="0"/>
<single_mapping origin_block="27648" data_block="42" time="0"/>
<single_mapping origin_block="32768" data_block="43" time="0"/>
<range_mapping origin_begin="33792" data_begin="44" length="1024" time="0"/>
<single_mapping origin_block="49152" data_block="1068" time="0"/>
<single_mapping origin_block="50176" data_block="1069" time="0"/>
<single_mapping origin_block="65536" data_block="1070" time="0"/>
<single_mapping origin_block="81919" data_block="1071" time="0"/>
</device>
<device dev_id="2" mapped_blocks="0" transaction="23" creation_time="11" snap_time="11">
</device>
</superblock>
Hi Eric,
I don't think LVM provides any support for metadata snapshots so you will need to drive this process through dmsetup. The kernel interface is described here:
https://github.com/torvalds/linux/blob/master/Documentation/device-mapper/thin-provisioning.txt
Don't get confused between a normal data snapshot, which takes a snapshot of a thin volume, and a metadata snapshot, which takes a snapshot of the metadata. Both of these commands that you used are for taking data snapshots (there are other reasons why those commands wouldn't work):
lvcreate -L1G -n matadata-snap -s vg0/mythinpool_tmeta
dmsetup message /dev/mapper/vg0-mythinpool 0 "create_snap metadata_snap vg0-mythinpool_tmeta"
You want to do something like:
dmsetup message /dev/mapper/vg0-mythinpool 0 "reserve_metadata_snap"
You will then be able to run thin_ls --metadata-snap on the live metadata.
Note that the kernel driver doesn't use names for thin volumes, only 32bit identifiers, so you will need to store some metadata of your own mapping user friendly names to ids if you don't want to use LVM.
Make sure you release the metadata snap as soon as you're finished with it:
dmsetup message /dev/mapper/vg0-mythinpool 0 "release_metadata_snap"
It might be helpful for you to look through this file of the dm test suite:
Thanks very much!