]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virStorageFileResize: fallocate the whole capacity
authorJán Tomko <jtomko@redhat.com>
Mon, 25 Sep 2017 14:35:42 +0000 (16:35 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 27 Sep 2017 12:40:44 +0000 (14:40 +0200)
commit3f702f5ab1d8cfcfa41a49aa7f6e3881242d5f0f
tree90ce73a4f8583e9a0618bc5dfeb94446fb284466
parent5463d9596903b370e7d078eeacb0e3f3c71c526f
virStorageFileResize: fallocate the whole capacity

We have been trying to implement the ALLOCATE flag to mean
"the volume should be fully allocated after the resize".

Since commit b0579ed9 we do not allocate from the existing
capacity, but from the existing allocation value.
However this value is a total of all the allocated bytes,
not an offset.

For a sparsely allocated file:
$ perl -e 'print "x"x8192;' > vol1
$ fallocate -p -o 0 -l 4096 vol1
$ virsh vol-info vol1 default
Capacity:       8.00 KiB
Allocation:     4.00 KiB

Treating allocation as an offset would result in an incompletely
allocated file:
$ virsh vol-resize vol1 --pool default 16384 --allocate
Capacity:       16.00 KiB
Allocation:     12.00 KiB

Call fallocate from zero on the whole requested capacity to fully
allocate the file. After that, the volume is fully allocated
after the resize:
$ virsh vol-resize vol1 --pool default 16384 --allocate
$ virsh vol-info vol1 default
Capacity:       16.00 KiB
Allocation:     16.00 KiB
src/storage/storage_util.c
src/util/virstoragefile.c
src/util/virstoragefile.h