very slow disk creation, snapshotting
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Native ZFS for Linux |
Fix Released
|
Unknown
|
|||
virt-manager |
Fix Released
|
Low
|
|||
libvirt (Ubuntu) |
Triaged
|
Low
|
Unassigned | ||
Bionic |
Invalid
|
Undecided
|
Unassigned | ||
Disco |
Won't Fix
|
Low
|
Unassigned | ||
Focal |
Triaged
|
Undecided
|
Unassigned | ||
Groovy |
Triaged
|
Low
|
Unassigned | ||
virt-manager (Ubuntu) |
Fix Released
|
Low
|
Unassigned | ||
Bionic |
Invalid
|
Undecided
|
Unassigned | ||
Disco |
Won't Fix
|
Low
|
Unassigned | ||
Focal |
Fix Released
|
Undecided
|
Unassigned | ||
zfs-linux (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned | ||
Bionic |
Won't Fix
|
Undecided
|
Unassigned | ||
Disco |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
[Impact]
* The defaults of virt-manager for disk allocation always worked fine
when qcow2 had nothing but sparse support. So sparse=True vs
sparse=False made no difference. So it always set sparse=False.
Then qcow2 grows non-sparse support, and virt-manager is suddenly
defaulting to it, which is not the intention.
* For upgraders from pre-Focal this was a regression in two ways:
a) allocation of qcow changed to non-sparse (fallocate based)
potentially consuming more space
b) depending on the underlying FS this made the allocation much
slower
* Fix by applying the upstream change that Defaults to sparse when
requested format isn't raw (for raw the assumption ill stay that
users do that for runtime performance, so non-sparse on those stays
as-is)
[Test Case]
* open virt-manager and create a new guest which includes creating a
new image for it
* when clicking "finish" the image will be created (which e.g. on ZFS
will take quite some time)
* In the background grep ps output if the qemu-img call for qcow (the
default) is using "preallocation=
"prealloca
[Regression Potential]
* For upgraders from pre-focal it actually ensures behavior stays as is
(no change/regression there)
* For users of ZFS where the allocation was slow it fixes this
slowness.
* But for people using Focal all the time and on non-ZFS there will be
a behavior change in no more doing falloc pre-allocating the qemu
image. To be cleear there are four modes:
1. no allocation
2. metadata allocation - is initially larger but can improve
performance when the image needs to grow
3. falloc - preallocates space for image by calling posix_fallocate
4. full - writes data to the underlying storage
The fix changes the default from 3->2 which it always was and should
be. As the patch says: "If users want to override it, they can
do it via custom created storage."
(To be clear, upstream changed this as we fixed it here, so on
further upgrades what we apply here will be the behavior anyway, it
seems wrong to keep Focal the only one in between kept different)
* [racb] The code path being added special cases the 'raw' format and in handling of the default sparse setting. Areas of potential regression are therefore in the handling of the default and override of the default in the cases of both 'raw' and not 'raw'.
[Other Info]
* The slowness effect might be further mitigated by ZFS implementing
more falloc options (thanks Richard for that hint) but that won't be
in Focal.
----
This is a regression in eoan for me. I use virt-manager to create vms, and I noticed that creating one now takes more than a minute.
Looking at the process listing while the backing disk is being created, I see this qemu-img command line:
15658 ? Ssl 0:00 /usr/sbin/libvirtd
23726 ? Sl 0:04 \_ /usr/bin/qemu-img create -f qcow2 -o preallocation=
If I run qemu-img with that preallocation parameter set, even on bionic, then it also takes a very long time.
On eoan, for comparison:
andreas@nsn7:~$ time qemu-img create -f qcow2 no-prealloc-
Formatting 'no-prealloc-
real 0m0,016s
user 0m0,010s
sys 0m0,006s
andreas@nsn7:~$ qemu-img info no-prealloc-
image: no-prealloc-
file format: qcow2
virtual size: 40G (42949672960 bytes)
disk size: 17K
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
andreas@nsn7:~$ du -hs no-prealloc-
17K no-prealloc-
andreas@nsn7:~$
and now with preallocation=
andreas@nsn7:~$ time qemu-img create -f qcow2 -o preallocation=
Formatting 'with-prealloc-
real 1m43,196s
user 0m3,564s
sys 1m26,720s
andreas@nsn7:~$ qemu-img info with-prealloc-
image: with-prealloc-
file format: qcow2
virtual size: 40G (42949672960 bytes)
disk size: 2.7M
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
andreas@nsn7:~$ du -hs with-prealloc-
2,8M with-prealloc-
andreas@nsn7:~$
ProblemType: Bug
DistroRelease: Ubuntu 19.10
Package: libvirt-daemon 5.4.0-0ubuntu5
ProcVersionSign
Uname: Linux 5.3.0-13-generic x86_64
NonfreeKernelMo
ApportVersion: 2.20.11-0ubuntu7
Architecture: amd64
Date: Mon Oct 7 11:36:03 2019
InstallationDate: Installed on 2019-10-07 (0 days ago)
InstallationMedia: Ubuntu 19.10 "Eoan Ermine" - Beta amd64 (20191006)
SourcePackage: libvirt
UpgradeStatus: No upgrade log present (probably fresh install)
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
modified.
Related branches
- Robie Basak: Approve (sru)
- Canonical Server: Pending requested
- git-ubuntu developers: Pending requested
-
Diff: 85 lines (+63/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/lp-1847105-addstorage-Return-to-using-qcow2-sparse-by-default.patch (+55/-0)
debian/patches/series (+1/-0)
- Andreas Hasenack (community): Approve
- Canonical Server: Pending requested
- git-ubuntu developers: Pending requested
-
Diff: 85 lines (+63/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/lp-1847105-addstorage-Return-to-using-qcow2-sparse-by-default.patch (+55/-0)
debian/patches/series (+1/-0)
- Canonical Server packageset reviewers: Pending requested
- Canonical Server: Pending requested
- git-ubuntu developers: Pending requested
-
Diff: 132 lines (+104/-0)4 files modifieddebian/changelog (+10/-0)
debian/patches/series (+2/-0)
debian/patches/ubuntu/lp-1847105-storage-only-fallocate-when-allocation-matches.patch (+51/-0)
debian/patches/ubuntu/lp-1847105-storage_util-fix-qemu-img-sparse-allocation.patch (+41/-0)
Changed in virt-manager: | |
importance: | Unknown → Undecided |
status: | Unknown → Confirmed |
Changed in virt-manager: | |
importance: | Undecided → Low |
Changed in zfs: | |
status: | Unknown → New |
Changed in libvirt (Ubuntu Disco): | |
status: | Triaged → Won't Fix |
Changed in virt-manager (Ubuntu Disco): | |
status: | Triaged → Won't Fix |
Changed in zfs-linux (Ubuntu Disco): | |
status: | New → Won't Fix |
Changed in virt-manager: | |
status: | Confirmed → Fix Released |
Changed in libvirt (Ubuntu Focal): | |
status: | New → Triaged |
Changed in zfs-linux (Ubuntu): | |
importance: | Undecided → Low |
Changed in virt-manager: | |
status: | Fix Released → Confirmed |
Changed in virt-manager: | |
status: | Confirmed → Fix Released |
description: | updated |
tags: | added: focal regression-release |
Changed in zfs-linux (Ubuntu): | |
importance: | Low → Undecided |
status: | New → Won't Fix |
Changed in zfs: | |
status: | New → Fix Released |
A quick check confirmed your report, thanks Andreas!
"preallocation" does exactly what expected and that takes the time you are seeing:
Preallocation mode (allowed values: "off", "falloc", "full"). "falloc" mode preallocates space for image by calling posix_fallocate(). "full" mode preallocates space for image by writing zeros to underlying storage.
It already uses fallocate which is better than writing zeros and much faster depending on the FS setup. But obviously bother are slower (on creation) than lazy allocation later.
The change of this should be in virt-manager, not libvirt I'd assume.
I'll take a look.
P.S. already ahead of time I'd think that creating with pre-alloc - while slower - is certainly much safer against later odd errors due to disk space.