Bug 839312

Summary: 3.1 - _interImagesCopy will create fully allocated raw files when copying raw sparse file volumes between NFS domains.
Product: Red Hat Enterprise Linux 6 Reporter: Lee Yarwood <lyarwood>
Component: vdsmAssignee: Yeela Kaplan <ykaplan>
Status: CLOSED DUPLICATE QA Contact: Haim <hateya>
Severity: high Docs Contact:
Priority: high    
Version: 6.2CC: abaron, bazulay, iheim, oourfali, rhodain, sputhenp, yeylon, ykaul
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: storage
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-23 14:32:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 782183, 840699    

Description Lee Yarwood 2012-07-11 14:23:59 UTC
Description of problem:
_interImagesCopy (vdsm/storage/image.py) will create fully allocated raw files when copying raw sparse file volumes between NFS domains. At present we call misc.ddWatchCopy() to copy data between the source and destination volumes. Given the sparse nature of the files dd will fully allocate every block in the destination volume.

You can reproduce this behavior outside of vdsm with :

# qemu-img create test.img 10M
Formatting 'test.img', fmt=raw size=10485760 
# qemu-img info test.img 
image: test.img
file format: raw
virtual size: 10M (10485760 bytes)
disk size: 0

# dd if=test.img of=copy.img
20480+0 records in
20480+0 records out
10485760 bytes (10 MB) copied, 0.0347086 s, 302 MB/s
# qemu-img info copy.img 
image: copy.img
file format: raw
virtual size: 10M (10485760 bytes)
disk size: 10M

With a possible workaround being the use of cp and the --sparse flag :

# cp --sparse=always copy.img sparse.img
# qemu-img info sparse.img 
image: sparse.img
file format: raw
virtual size: 10M (10485760 bytes)
disk size: 0

Version-Release number of selected component (if applicable):
vdsm-4.9-113.1 (and upstream)

How reproducible:
Always

Steps to Reproduce:
1. Create a guest with thin provisioned disks on a NFS domain.
2. Review the current virtual and actual size of the volumes.
3. Move the guest to another NFS domain.
4. Review the current virtual and actual size of the volumes. The virtual and actual size will now both show the volume as fully allocated.
  
Actual results:
The destination volumes are fully allocated by DD.

Expected results:
The destination volumes are left sparse just as the source is.

Additional info:
WIP Workaround to this is to use the --sparse=always switch with cp to recreate the volume. Current testing with pre-installed guests suggests this copies _all_ the required data but I'm still attempting to verify.

Comment 2 Lee Yarwood 2012-07-11 18:29:55 UTC
WIP patch upstream http://gerrit.ovirt.org/#/c/6160/1 , currently based on some successful downstream testing but likely to change with review.