Bug 698658

Summary: vol-wipe will not work well when allocation all the capacity for raw type volume
Product: Red Hat Enterprise Linux 6 Reporter: weizhang <weizhan>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.1CC: berrange, dyuan, gren, llim, mzhan, yanyang, yoyzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-04-21 15:30:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description weizhang 2011-04-21 13:37:19 UTC
Description of problem:
I create a volume with xml
<volume>
  <name>vol-raw</name>
  <capacity unit="G">1</capacity>
<allocation unit='G'>1</allocation>
  <target>
    <path>/var/lib/libvirt/images/vol-raw</path>
    <format type="raw"/>
  </target>
</volume>
on dir/fs pool and get the vol-info
# virsh vol-info --pool dir_pool vol-raw
Name:           vol-raw
Type:           file
Capacity:       1.00 GB
Allocation:     1.00 GB

after I wipe the volume and see the vol-info, the allocation still 1G. If I allocation with 1023M, then after volume wiping, the allocation will change to 0.

Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.159.el6.x86_64
libvirt-0.8.7-18.el6.x86_64
kernel-2.6.32-130.el6.x86_64


How reproducible:
100%

Steps to Reproduce:
1. define and start a dir/fs pool with
<pool type='dir'>
  <name>dir_pool</name>
  <uuid>70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2</uuid>
  <capacity>0</capacity>
  <allocation>0</allocation>
  <available>0</available>
  <source>
  </source>
  <target>
    <path>/var/lib/libvirt/images</path>
    <permissions>
      <mode>0700</mode>
      <owner>0</owner>
      <group>0</group>
      <label>some_label_t</label>
    </permissions>
  </target>
</pool>
# virsh pool-define /tmp/dir_pool.xml
# virsh pool-start dir_pool      
2. create raw type volume with xml
<volume>
  <name>vol-raw</name>
  <capacity unit="G">1</capacity>
<allocation unit='G'>1</allocation>
  <target>
    <path>/var/lib/libvirt/images/vol-raw</path>
    <format type="raw"/>
  </target>
</volume>
# virsh vol-info --pool dir_pool vol-raw
Name:           vol-raw
Type:           file
Capacity:       1.00 GB
Allocation:     1.00 GB

3. wipe volume 
# virsh vol-wipe --pool dir_pool vol-raw

4. see vol-info
#  virsh vol-info --pool dir_pool vol-raw
Name:           vol-raw
Type:           file
Capacity:       1.00 GB
Allocation:     1.00 GB
 
Actual results:
allocation still 1G

Expected results:
allocation should be 0G

Additional info:

Comment 1 Daniel Berrangé 2011-04-21 15:30:35 UTC
> Actual results:
> allocation still 1G
>
> Expected results:
> allocation should be 0G

This is a mis-understanding of what wipe will do.

The 'wipe' operation is defined to clear all data in the file, such that future reads return all zeros. The effect of 'wipe' on the allocation is left undefined, though the ideal goal is to preserve the existing allocation as closely as possible.

Currently if the file is fully allocated, it will remain fully allocated. If it is at all sparse, it will be made completely sparse.