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