[linux-lvm] Bug in LVM2 tools

Xuân Baldauf xuan--2006.10.04--linux-lvm--redhat.com at baldauf.org
Wed Oct 4 21:05:51 UTC 2006


Hello,

I observed an obscure bug in the current LVM2 tools. Observe this:


# dd if=/dev/zero of=testfile bs=1024k count=1
1+0 records in
1+0 records out
1048576 bytes (1,0 MB) copied, 0,009037 seconds, 116 MB/s
# losetup /dev/loop4 testfile
# pvcreate /dev/loop4
  Physical volume "/dev/loop4" successfully created
# vgcreate --physicalextentsize=1k test.vg /dev/loop4
  Volume group "test.vg" successfully created
# lvcreate --name=test.lv --size=832k test.vg
  Insufficient free extents (640) in volume group test.vg: 832 required
# vgremove test.vg
  Volume group "test.vg" successfully removed
# vgcreate --physicalextentsize=1k test.vg /dev/loop4
  Volume group "test.vg" successfully created
# lvcreate --name=test.lv --size=832k test.vg
  Logical volume "test.lv" created
#

I create a file "testfile" of 1024KiB size and view it as /dev/loop4.
Then I create a physical volume on /dev/loop4 and a volume group
"test.vg" covering that physical volume. The metadata needs the first
192KiB. However, I cannot use the remaining 832KiB for a logical volume.
This is the bug.

However, if I remove the volume group "test.vg" and once more create it
again, now the remaining 832KiB are fully usable. This behaviour is
inconsistent.

Analyzing the metadata after the first "vgcreate", one can see that the
pe_count of the physical volume is too small. It seems that there is
space reserved for a second metadata copy at the end of /dev/loop4,
however, no second metadata copy is requrested at the invocation of
"pvcreate".

For me, it is in particuliar important that the first "vgcreate" does
not use any extra space at the end of the block device the physical
volume lives on, as, in my case, the physical volume contains already
data (which is to be made available as a logical volume).

ciao,
Xuân.




More information about the linux-lvm mailing list