Commits
Kir Kolyshkin authored e921fce16ad
add_delta(): prevent multiple mounts Commit e644ed7 switched code to cookie-based registration, and if ploop cookie feature is supported by the kernel, [un]register_ploop_dev() are not doing anything. As a side effect, ploop_find_dev() check in register_ploop_dev() is not performed, and it is now possible to mount same image a few times (given that mount is read-only and NOT via dd.xml): # ploop mount -m mnt -r root.hdd Adding delta dev=/dev/ploop0 img=root.hdd (ro) Mounting /dev/ploop0p1 at mnt fstype=ext4 data='balloon_ino=12,' ro # ploop mount -m mnt2 -r root.hdd Adding delta dev=/dev/ploop1 img=root.hdd (ro) Mounting /dev/ploop1p1 at mnt2 fstype=ext4 data='balloon_ino=12,' ro I guess this is not the desired behavior. This patch tries to fix it by searching for existing ploop device corresponding to to the base image, right before adding this image. Still, there is a possibility of race here, and we can't use ploop_global_lock() because it is already used in ploop_find_dev(), so suggestions are welcome. NOTE: mounting via DiskDescriptor.xml is not affected, because ploop_mount_image() does proper check (with proper locking). Signed-off-by: Kir Kolyshkin <kir@openvz.org>