Raw and qcow2 disks are never preallocated on systems with newer util-linux
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Fix Released
|
Medium
|
Matthew Booth |
Bug Description
imagebackend.
fallocate -n -l 1 <image path>.fallocate
where <image path> exists, but <image path>.fallocate
On RHEL 7, which has util-linux-
$ fallocate -n -l 1 foo
$ ls -lh foo
-rw-r--r--. 1 mbooth mbooth 0 Feb 8 15:33 foo
$ du -sh foo
4.0K foo
On Fedora 23, which has util-linux-
$ fallocate -n -l 1 foo
fallocate: cannot open foo: No such file or directory
The F23 behaviour actually makes sense. From the fallocate man page:
-n, --keep-size
Do not modify the apparent length of the file.
This doesn't make any sense if the file doesn't exist. That is, the -n option makes sense when preallocating an existing disk image, but not when testing if fallocate works on a given filesystem and the test file doesn't already exist.
You could also reasonably argue that util-linux probably should be breaking an interface like this, even when misused. However, that's a separate discussion. We shouldn't be misusing it.
Changed in nova: | |
assignee: | nobody → Matthew Booth (mbooth-9) |
status: | New → In Progress |
tags: | added: libvirt |
Changed in nova: | |
importance: | Undecided → Medium |
Reviewed: https:/ /review. openstack. org/277402 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=33749d2875b 4e63ad8f663a734 cd087980489b6e
Committed: https:/
Submitter: Jenkins
Branch: master
commit 33749d2875b4e63 ad8f663a734cd08 7980489b6e
Author: Matthew Booth <email address hidden>
Date: Mon Feb 8 12:41:06 2016 +0000
Fix fallocate test on newer util-linux
Newer util-linux raises an error when calling fallocate with the -n
option if the target file does not already exist. This is because the
-n option directs it to retain the file's existing size. A
non-existent file does not have an existing size. fallocate in older
releases of util-linux creates a zero-sized file in this case. This
results in _can_fallocate() always returning false, and therefore
never preallocating.
While this may reasonably be argued to be a regression in util-linux,
the -n option doesn't make sense here anyway, so we remove it.
Closes-Bug: #1543181
Change-Id: Ie96fa71e7d2641 d30572b8eda5609 dd3ca5b6708