Comment 1 for bug 117225

Revision history for this message
Kees Cook (kees) wrote :

First, create a test LV to serve as the "original" LV

# lvcreate -L1G -n original systemvg
  Logical volume "original" created
# ls -la /dev/systemvg/original
lrwxrwxrwx 1 root root 29 2007-05-27 09:59 /dev/systemvg/original -> /dev/mapper/systemvg-original
# ls -la /dev/mapper/systemvg-original
lrwxrwxrwx 1 root root 8 2007-05-27 09:59 /dev/mapper/systemvg-original -> ../dm-21
# mkfs.ext3 /dev/systemvg/original
# mount /dev/systemvg/original /mnt/test
# echo "original" > /mnt/test/what-am-i.txt
# umount /mnt/test

Now, create a snapshot named "duplicate" from the "original" LV

# lvcreate -s -L1G -n duplicate /dev/systemvg/original
  Logical volume "duplicate" created
# ls -la /dev/systemvg/duplicate
lrwxrwxrwx 1 root root 30 2007-05-27 10:01 /dev/systemvg/duplicate -> /dev/mapper/systemvg-duplicate
# ls -la /dev/mapper | grep duplicate
lrwxrwxrwx 1 root root 8 2007-05-27 10:01 systemvg-duplicate-cow -> ../dm-24
# ls -la /dev/mapper | grep original
lrwxrwxrwx 1 root root 8 2007-05-27 10:01 systemvg-original-real -> ../dm-23

At this point, things are very strange: neither the source nor the target
symlinks exist in /dev/mapper.

Checking on the newly create dm-* devices, we find:

# vol_id /dev/dm-21 | grep UUID=
ID_FS_UUID=341cab43-9dc2-4c45-97fd-5b9df09dd748
# vol_id /dev/dm-22 | grep UUID=
ID_FS_UUID=341cab43-9dc2-4c45-97fd-5b9df09dd748
# vol_id /dev/dm-23 | grep UUID=
ID_FS_UUID=341cab43-9dc2-4c45-97fd-5b9df09dd748
# vol_id /dev/dm-24
/dev/dm-24: unknown volume type

So, as I understand it, the mapping is:

dm-21 -> systemvg-original
dm-22 -> ??? (should be "systemvg-duplicate")
dm-23 -> systemvg-original-real (an LVM by-product)
dm-24 -> systemvg-duplicate-cow (an LVM by-product)

The LVM by-product devices are not for general consumption, which leaves
dm-22 as the likely candidate for being the snapshot. (Which is also
supported by the udevmonitor output log -- attached.)

# mount /dev/dm-23 /mnt/test
mount: /dev/dm-23 already mounted or /mnt/test busy
# mount /dev/dm-24 /mnt/test
mount: /dev/dm-24 already mounted or /mnt/test busy

Just to be sure, change the "what-am-i.txt" file:

# mount /dev/dm-22 /mnt/test
# cat /mnt/test/what-am-i.txt
original
# echo "duplicate?" > /mnt/test/what-am-i.txt
# umount /mnt/test

Drop the "duplicate" snapshot:

# lvremove /dev/systemvg/duplicate
Do you really want to remove active logical volume "duplicate"? [y/n]: y
  Logical volume "duplicate" successfully removed

Strangely, the source symlinks have returned:

# ls -la /dev/mapper | grep original
lrwxrwxrwx 1 root root 8 2007-05-27 10:07 systemvg-original -> ../dm-21

We verify that the original LV is unchanged:

# mount /dev/systemvg/original /mnt/test
# cat /mnt/test/what-am-i.txt
original
# umount /mnt/test

So, after "lvcreate -s" finishes, the problems are:

1) the source LV symlink has vanished
   ("systemvg-original" should still exist)
2) the target LV symlink isn't there
   ("systemvg-duplicate" should exist)