LVM snapshotting missing symlinks

Bug #117225 reported by Kees Cook
2
Affects Status Importance Assigned to Milestone
devmapper (Ubuntu)
Fix Released
Undecided
Kees Cook

Bug Description

Binary package hint: udev

The gutsy udev seems to not handle LVM snapshots device symlink creation. Or, if it's a race, I always lose. :)

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)

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

Strangely, disabling /etc/udev/rules.d/65-dmsetup.rules leaves the /dev/mapper/systemvg-duplicate file (though /dev/mapper/systemvg-original still vanishes).

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

Ah-ha! dmsetup's rule was ignoring the final snapshot devices (once they were set up correctly), which meant that the final device state lacked a symlink, and udev prompted deleted it. On initial creation, it has a DM_TARGET_TYPES of "linear".

udev_event_run: seq 3143 forked, pid [24597], 'change' 'block', 0 seconds old
run_program: '/sbin/dmsetup export -j254 -m26'
run_program: '/sbin/dmsetup' (stdout) 'DM_NAME=systemvg-testsnap'
run_program: '/sbin/dmsetup' (stdout) 'DM_UUID=LVM-4R9E1MV0xLpEsR74zV3oOmJorMhb2Erw3tmXSDwEMd4nl2BxRjV429fgGeCPXKOB'
run_program: '/sbin/dmsetup' (stdout) 'DM_STATE=ACTIVE'
run_program: '/sbin/dmsetup' (stdout) 'DM_TABLE_STATE=LIVE'
run_program: '/sbin/dmsetup' (stdout) 'DM_OPENCOUNT=0'
run_program: '/sbin/dmsetup' (stdout) 'DM_LAST_EVENT_NR=0'
run_program: '/sbin/dmsetup' (stdout) 'DM_MAJOR=254'
run_program: '/sbin/dmsetup' (stdout) 'DM_MINOR=26'
run_program: '/sbin/dmsetup' (stdout) 'DM_TARGET_COUNT=1'
run_program: '/sbin/dmsetup' (stdout) 'DM_TARGET_TYPES=snapshot'
run_program: '/sbin/dmsetup' returned with status 0
udev_rules_get_name: no node name set, will use kernel name 'dm-26'
udev_device_event: device '/block/dm-26' already in database, cleanup
name_index: removing index: '/dev/.udev/names/dm-26/%2fblock%2fdm-26'
name_index: removing index: '/dev/.udev/names/mapper%2fsystemvg-testsnap/%2fblock%2fdm-26'
name_index: removing index: '/dev/.udev/names/disk%2fby-id%2fdm-name-systemvg-testsnap/%2fblock%2fdm-26'
name_index: removing index: '/dev/.udev/names/disk%2fby-id%2fdm-uuid-LVM-4R9E1MV0xLpEsR74zV3oOmJorMhb2Erw3tmXSDwEMd4nl2BxRjV429fgGeCPXKOB/%2fblock%2fdm-26'
udev_node_add: creating device node '/dev/dm-26', major = '254', minor = '26', mode = '0660', uid = '0', gid = '6'
udev_node_mknod: preserve file '/dev/dm-26', because it has correct dev_t
name_index: creating index: '/dev/.udev/names/dm-26/%2fblock%2fdm-26'
udev_node_update_symlinks: update old symlink 'mapper/systemvg-testsnap' no longer belonging to '/block/dm-26'
udev_db_get_devices_by_name: no index directory '/dev/.udev/names/mapper%2fsystemvg-testsnap': No such file or directory
update_link: found -1 devices with name 'mapper/systemvg-testsnap'
update_link: no reference left, remove 'mapper/systemvg-testsnap'
udev_node_update_symlinks: update old symlink 'disk/by-id/dm-name-systemvg-testsnap' no longer belonging to '/block/dm-26'

This would need to be fixed even after "udev-lvm-mdadm-evms-gutsy" is solved, since the "final" device will have the "snapshot" type, and will need device nodes created.

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

 devmapper (2:1.02.18-1ubuntu3) gutsy; urgency=low
 .
   * Adjust debian/dmsetup.udev rule to not ignore "snapshot" devices. This
     will be needed even after "udev-lvm-mdadm-evms-gutsy" is solved (LP:
     #117225).
   * Update Maintainer fields for Ubuntu.

Changed in udev:
assignee: nobody → keescook
status: Unconfirmed → Fix Released
Revision history for this message
Kees Cook (kees) wrote :

devmapper (2:1.02.18-1ubuntu3) gutsy; urgency=low

  * Adjust debian/dmsetup.udev rule to not ignore "snapshot" devices. This
    will be needed even after "udev-lvm-mdadm-evms-gutsy" is solved (LP:
    #117225).
  * Update Maintainer fields for Ubuntu.

 -- Kees Cook <email address hidden> Sun, 27 May 2007 12:12:22 -0700

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.