Raw and qcow2 disks are never preallocated on systems with newer util-linux

Bug #1543181 reported by Matthew Booth
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Matthew Booth

Bug Description

imagebackend.Image._can_fallocate tests if fallocate works by running the following command:

  fallocate -n -l 1 <image path>.fallocate_test

where <image path> exists, but <image path>.fallocate_test does not. This command line is copied from the code which actually fallocates a disk. However, while this works on systems with an older version of util-linux, such as RHEL 7, it does not work on systems with a newer version of util-linux, such as Fedora 23. The result of this is that this test will always fail, and preallocation with fallocate will be erroneously disabled.

On RHEL 7, which has util-linux-2.23.2-26.el7.x86_64 on my system:

$ 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-2.27.1-2.fc23.x86_64 on my system:

$ 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.

Tags: libvirt
Changed in nova:
assignee: nobody → Matthew Booth (mbooth-9)
status: New → In Progress
melanie witt (melwitt)
tags: added: libvirt
Matt Riedemann (mriedem)
Changed in nova:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/277402
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=33749d2875b4e63ad8f663a734cd087980489b6e
Submitter: Jenkins
Branch: master

commit 33749d2875b4e63ad8f663a734cd087980489b6e
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: Ie96fa71e7d2641d30572b8eda5609dd3ca5b6708

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/nova 13.0.0.0b3

This issue was fixed in the openstack/nova 13.0.0.0b3 development milestone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.