LVM: Pass volume size in MiB to copy_volume() during volume migration
Currently migrate_volume() in lvm.py does not pass volume size in
MiB but passes volume size in GiB to copy_volume(). The size argument
of copy_volume() requires MiB value. As a result, if the volume size
is 1GiB, copy_volume() copies only 1MiB head of 1GiB volume to the
destination volume, and then the volume data is corrupted.
This patch fixes to pass volume size in MiB.
Closes-bug: #1454835
Change-Id: I8e06195dc3625ef07bc9858d844541e37a231b73
LVM: Support efficient data copy using "dd" for create_cloned_volume
The create_cloned_volume uses dd command for data copy, but the
copy always copy full blocks even if the source data contains
many null or zero blocks. When we use thin provisioned LVM,
blocks are not pre-allocated, so unused region returns zero.
If we copy full block for destination volume, unnecessary blocks
will be allocated and the usage will be 100%.
The dd command has conv=sparse option in order to copy data more
efficiently. This patch enables conv=sparse option as an argument
of dd command for create_cloned_volume when we use thin provisioned
LVM.
[NOTE]
This patch only enables conv=sparse parameter of dd command for
create_cloned_volume() path of LVM driver. There are some places
using dd in Cinder, but we should carefully consider to apply
this parameter for other places because misuse of this parameter
causes security issues or data corruptions. Also we DO NOT use this
parameter for volume wiping case because the volume is not cleared
at all.
Here are some results for this option.
- Without conv=sparse option
LV VG Attr LSize Pool Origin Data%
vg1-pool vg1 twi-a-tz-- 3.80g 31.45
volume-clone vg1 Vwi-a-tz-- 1.00g vg1-pool 100.00
volume-source vg1 Vwi-a-tz-- 1.00g vg1-pool 19.53
- With conv=sparse option
LV VG Attr LSize Pool Origin Data%
vg1-pool vg1 twi-a-tz-- 3.80g 10.28
volume-clone vg1 Vwi-a-tz-- 1.00g vg1-pool 19.53
volume-source vg1 Vwi-a-tz-- 1.00g vg1-pool 19.53
Change-Id: I743f823ca38529b12301a89308d1d406aa3fa45f
Closes-bug: #1224671