]> xenbits.xensource.com Git - libvirt.git/commit
storage: resize vol against real allocated size
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 16 Dec 2013 05:00:00 +0000 (13:00 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 18 Dec 2013 08:08:27 +0000 (09:08 +0100)
commitb0579ed9005370fcc22684722412984eb64d0617
tree42653bc21f3a3c6918b39e7e49c01fea596020eb
parent5d7e4f0cf335235c09e4c2d797fe1cf870f5cba9
storage: resize vol against real allocated size

Currently, 'vol-resize --allocate' allocates new space at the
vol->capacity offset. But the vol->capacity is not necessarily the same
as vol->allocation. For instance:.

[root@localhost ~]# virsh vol-list --pool tmp-pool --details
 Name      Path                   Type  Capacity  Allocation
-------------------------------------------------------------
 tmp-vol  /root/tmp-pool/tmp-vol  file  1.00 GiB  1.00 GiB

[root@localhost ~]# virsh vol-resize tmp-vol --pool tmp-pool 2G

[root@localhost ~]# virsh vol-list --pool tmp-pool --details
 Name      Path                   Type  Capacity  Allocation
-------------------------------------------------------------
 tmp-vol  /root/tmp-pool/tmp-vol  file  2.00 GiB  1.00 GiB

So, if we want to allocate more bytes, so the file is say 3G big, the
real allocated size is 2G actually:

[root@localhost ~]# virsh vol-resize tmp-vol --pool tmp-pool 3G --allocate

[root@localhost ~]# virsh vol-list --pool tmp-pool --details
 Name      Path                   Type  Capacity  Allocation
-------------------------------------------------------------
 tmp-vol  /root/tmp-pool/tmp-vol  file  3.00 GiB  2.00 GiB

This commit uses the correct vol->allocation instead of incorrect
vol->capacity, so the output of the commands above looks like this:

[root@localhost ~]# virsh vol-resize tmp-vol --pool tmp-pool 3G --allocate

[root@localhost ~]# virsh vol-list --pool tmp-pool --details
 Name      Path                   Type  Capacity  Allocation
-------------------------------------------------------------
 tmp-vol  /root/tmp-pool/tmp-vol  file  3.00 GiB  3.00 GiB

Moreover, if the '--alocate' flag was used, we must update the
vol->allocation member in storageVolResize API too, not just
vol->capacity.

Reported-by: Wang Sen <wangsen@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/storage/storage_backend_fs.c
src/storage/storage_driver.c