[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: [dm-devel] Using dmsetup to create a snapshot...



Hi Kevin,
I tried the steps you have mentioned. I was close to creating a snapshot but
am missing something.
The problem is that in step number 8 you mentioned, when I try to resume
my_data_snap, I get the following error:

		"device-mapper: Invalid/corrupt snapshot"

Another problem I noticed was difference in the tables created when using
EVMS Vs when using dmsetup.

EVMS tables:
snap: 0 977066 snapshot 254:007 254:008 P 128
hdb1#origin#: 0 977066 snapshot-origin 254:007
hdb2: 0 204120 linear 003:064 977130
lvm|My Container|My Region: 0 163840 linear 254:005 33152
hdb1: 0 977067 linear 003:064 63
snap#sibling#: 0 163837 linear 254:006 0

dmsetup tables:
my_data_org: 0 1953100 linear 003:065 63
my_data: 0 1953100 snapshot-origin 254:001
my_data_snap: 0 1953100 snapshot 254:001 003:066 P 64

Where is the missing step?

If you want to know what all I tried, following is the information:

Steps used to create a snapshot using Devive-Mapper:
1. /usr/src/device-mapper.1.00.18/scripts/devmap_mknod.sh
2. echo " 0 1953100 linear /dev/hdb1 63" | /sbin/dmsetup create my_data
3. /sbin/dmsetup suspend my_data
4. /sbin/dmsetup create my_data_org --notable
5. /sbin/dmsetup table my_data | /sbin/dmsetup load my_data_org
6. /sbin/dmsetup resume my_data_org
7. /sbin/dmsetup create my_data_snap --notable
8. echo "0 `/sbin/blockdev --getsize /dev/mapper/my_data` snapshot
/dev/mapper/my_data_org /dev/hdb2 p 64" | /sbin/dmsetup load my_data_snap
9. echo "0 `/sbin/blockdev --getsize /dev/mapper/my_data` snapshot-origin
/dev/mapper/my_data_org" | /sbin/dmsetup load my_data
10. /sbin/dmsetup resume my_data_snap
OUTPUT I GOT: device-mapper: Invalid/corrupt snapshot
11. /sbin/dmsetup resume my_data


Steps to create a snap shot and rollback using EVMS:
1. Attach a new hard disk to system
2. Delete all the partitions and volumes from the new hard disk
3. Created a new partition and installed ext2 in it. Called it /dev/hdb1.
4. Started EVMS and executed the following commands:
 a) Create:Segment,hdb_freespace1,size=100MB
 b) Create:Container,LvmRegMgr={name="My Container",pe_size=16MB},hdb2
 c) Create:region,LvmRegMgr={name="My Region", size=100MB},"lvm/My
Container/Freespace"
 d) create:object,Snapshot={original=/dev/evms/hdb1, snapshot=snap},"lvm/My
Container/My Region"
 e) c:v , snap, n="My Volume"
5. Mounted /dev/evms/hdb1 and created a few files and directories in the
same.
6. Mounted /dev/evms/My\ Volume and did not see the created files and dirs.
7. Unmounted both the volumes.
8. Started EVMS and executed the following command:
 task:rollback,snap
9. Mounted /dev/evms/hdb1 and saw the rolled back state. 


Regards,
Manu.


-----Original Message-----
From: Kevin Corry [mailto:kevcorry us ibm com]
Sent: Thursday, July 22, 2004 9:01 PM
To: dm-devel redhat com
Cc: Manu Tayal
Subject: Re: [dm-devel] Using dmsetup to create a snapshot...


On Wednesday 21 July 2004 7:57 am, Manu Tayal wrote:
> Hi,
> I have installed device-mapper.1.00.18 on kernel 2.4.26. Now I want to
> create a snapshot using "dmsetup". I could not get hold of enough
> documentation to do the same. Can somebody tell me the steps which are
> required to do the same.
>
> My Setup: I have two hard disks on my system and I am using the second hard
> disk to experiment with device mapper. What I was trying to do was create a
> volume and install etx3 on the same. Then create a snapshot of it, mount
> the snapshot and view the same. I was able to achieve this via EVMS but not
> with dmsetup.
>
> Any pointers to good documentation would also help.

At this point, there isn't any written documentation about DM's snapshot 
implementation. I had hoped to write some to go into the 
Documentation/device-mapper/ directory in the kernel tree, but I got 
distracted with other work. I'm sure I'll get around to it eventually. For 
now I'd recommend looking through drivers/md/dm-snap.[ch] and 
drivers/md/dm-exception-store.c in the kernel source.

As for using dmsetup to create snapshots, I can't say I'd recommend that 
approach. The activation sequence is very tricky. To simply create a DM 
snapshot device, you'd do something like:

echo "0 <device_size_in_sectors> snapshot <origin_device> <cow_device> <p|n>
\ 
<chunk_size_in_sectors> | dmsetup create <new_snapshot_name>

But, that's only part of the story. You also need a snapshot-origin device to

actually monitor the I/Os to the origin volume and perform the 
copy-on-writes, which you create with:

echo "0 <device_size_in_sectors> snapshot-origin <origin_device>" \
| dmsetup create <new_origin_name>

Where <origin_device> is the same for both the snapshot and the origin. But, 
this isn't *really* what you want, either. Because for this to work, you 
would have you unmount the <origin_device> device and mount the 
<new_origin_name> device, so that I/O will actually go through the 
snapshot-origin device and be subject to the COW monitoring. But unmounting 
your origin volume and remounting through a different device is, of course, 
undesireable. You'd rather just allow the origin volume to remain mounted 
while you create the snapshot, since the whole point of snapshotting is to 
make backups of a live volume.

In order to do this properly, your origin volume must also be a DM device.
For 
example, a simple dm-linear or dm-stripe device, like the ones created by 
EVMS or LVM2. You can obviously also create such a device with dmsetup. For 
this example let's say you have a dm-linear device named "my_data", which was

created with dmsetup and is mounted using the device /dev/mapper/my_data, and

let's also say that this device has the mapping "0 12345 linear /dev/hdc1 0",

which means the device is 12345 sectors long and maps to /dev/hdc1 with no 
offset.

To create a proper snapshot of my_data while the device is mounted and in
use, 
you need to do the following:

1. Suspend my_data to temporarily stop any I/O while the snapshot is being 
activated.
   dmsetup suspend my_data

2. Create the snapshot-origin device with no table.
   dmsetup create my_data_org

3. Read the table from my_data and load it into my_data_org.
   dmsetup table my_data | dmsetup load my_data_org

4. Resume this new table.
   dmsetup resume my_data_org

5. Create the snapshot device with no table.
   dmsetup create my_data_snap

6. Load the table into my_data_snap. This uses /dev/hdd1 as the COW device
and 
uses a 32kB chunk-size.
   echo "0 `blockdev --getsize /dev/mapper/my_data` snapshot \
    /dev/mapper/my_data_org /dev/hdd1 p 64" | dmsetup load my_data_snap

7. Reload my_data as a snapshot-origin device that points to my_data_org.
   echo "0 `blockdev --getsize /dev/mapper/my_data` snapshot-origin \
    /dev/mapper/my_data_org" | dmsetup load my_data

8. Resume the snapshot and origin devices.
   dmsetup resume my_data_snap
   dmsetup resume my_data

With this setup, a filesystem mounted on /dev/mapper/my_data will not need to

be remounted on a different device, but will now go through the 
snapshot-origin device and be subject to the COW monitoring. You can then 
mount /dev/mapper/my_data_snap to view the snapshot device and make your 
backup. I'll leave it as an exercise to the reader to figure out how to 
properly tear all this down. And if I've made any slight errors in this 
sequence, hopefully Alasdair will correct me. :)

If you're simply interested in using snapshots to do data backups, just stick

with EVMS or LVM2 and save yourself a lot of headache. :)

-- 
Kevin Corry
kevcorry us ibm com
http://evms.sourceforge.net/


DISCLAIMER:
This message (including attachment if any) is confidential and may be privileged. Before opening attachments please check them for viruses and defects. MindTree Consulting Private Limited (MindTree) will not be responsible for any viruses or defects or any forwarded attachments emanating either from within MindTree or outside. If you have received this message by mistake please notify the sender by return  e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited.  Please note that e-mails are susceptible to change and MindTree shall not be liable for any improper, untimely or incomplete transmission.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]