[linux-lvm] insufficient cleanin in lvcreate

Mikulas Patocka mpatocka at redhat.com
Wed Jul 24 02:32:06 UTC 2013


There is a bug in lvm, it clears the newly created logical volume 

What actually happened to me:

I created a few linear logical volumes with lvcreate ("lvcreate -L 32m 
vg1"). The weird thing was that the volumes were open after creation, 
although I didn't run any command that would open them:
lvol0 vg1 -wi-ao--- 32,00m
lvol1 vg1 -wi-ao--- 32,00m
lvol2 vg1 -wi-ao--- 32,00m 
lvol3 vg1 -wi-ao--- 32,00m

I couldn't mount the volumes (it said that they are already mounted):
mount: /dev/mapper/vg1-lvol0 already mounted or /mnt/test busy

I couldn't delete the logical volumes (because they were open).

I rebooted the machine, on next reboot the bug occured again and the 
logical volumes were open again.

I tried to use fuser to find out what process keeps the logical volumes 
open, but there was none. I changed to single user mode and killed all 
daemons, but the logical volumes were still open.

I suspected a file handle leak in the kernel, I added stacktrace to the 
kernel to find out what kernel subsystem actually opened the logical 
volume - and found, it was md.

What really happened - lvm is supposed to clear filesystem superblocks and 
md superblocks when a logical volume is created, but it cleared the newly 
created logical volume insufficiently and left out a md superblock at 
sector 8. The md superblock was left out there in the unallocated part of 
the physical volume from some of my previous experiments. Some daemon in 
RHEL6 found that a newly created logical volume has a md superblock and 
activated it with mdadm.

This bug could have quite serious consequences, the administrator creates 
a logical volume with lvcreate, the volume is open, unmountable and 
undeletable, the administrator has no way to find out what keeps the 
volume open (fuser displays nothing). There is nothing that would suggest 
to the administrator that the volume is open by md.

I placed a script to reproduce this bug at 
http://people.redhat.com/~mpatocka/testcases/insufficient-cleaning/ - 
download both files, set "vg" variable in the script to some real volume 
group on the system and run the script. When the script finishes, the 
logical volume is open, unmountable and undeletable.


More information about the linux-lvm mailing list