Bug 1599335 - Image creation locking is too tight and is not properly released
Summary: Image creation locking is too tight and is not properly released
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Max Reitz
QA Contact: Tingting Mao
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-07-09 14:24 UTC by Max Reitz
Modified: 2018-11-01 11:15 UTC (History)
10 users (show)

Fixed In Version: qemu-kvm-rhev-2.12.0-8.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-11-01 11:13:00 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:3443 None None None 2018-11-01 11:15:19 UTC

Description Max Reitz 2018-07-09 14:24:20 UTC
Description of problem:

Instead of forbidding concurrent truncations, file-posix does the opposite.  Because qemu always needs other permissions for truncation besides RESIZE itself, this still means concurrent truncations are effectively disallowed.  But it also means that valid concurrent uses are disallowed as well.

Furthermore, the file locks are not released before the FD is closed.  This may lead to locks staying applied when working with fdsets.


Steps to Reproduce:
$ qemu-img create -f raw -o preallocation=full foo.img 1G &; qemu-io -c info -c close -r foo.img

Actual results:
Formatting 'foo.img', fmt=raw size=1073741824 preallocation=full
can't open device foo.img: Failed to get "consistent read" lock
Is another process using the image?


Expected results:
Formatting 'foo.img', fmt=raw size=1073741824 preallocation=full
format name: raw
cluster size: 0 bytes
vm state offset: 0 bytes

Comment 2 Max Reitz 2018-07-09 14:40:28 UTC
Correction for the reproduction step:
$ qemu-img create -f raw -o preallocation=full foo.img 1G &; sleep 0.5; qemu-io -c info -c close -r foo.img

(Otherwise, the image file may or may not exist before qemu-io runs)

Comment 4 Miya Chen 2018-07-10 04:09:24 UTC
Max, we are not able to reproduce this bz by using the steps you provided:

# qemu-img create -f raw -o preallocation=full foo.img 1G &  sleep 0.5; qemu-io -c info -c close -r foo.img
[1] 16582
Formatting 'foo.img', fmt=raw size=1073741824 preallocation=full
format name: raw
cluster size: 0 bytes
vm state offset: 0 bytes

# rpm -qa |grep qemu-img
qemu-img-rhev-2.12.0-1.el7.x86_64

Comment 5 Ping Li 2018-07-10 05:48:53 UTC
Based on my testing results, this bz should be a regression since qemu-kvm-rhev-2.12.0-7.el7.

# qemu-img --version
qemu-img version 2.12.0 (qemu-kvm-rhev-2.12.0-6.el7)
# qemu-img create -f raw -o preallocation=full foo.img 1G &  sleep 0.5; qemu-io -c info -c close -r foo.img
[1] 19257
Formatting 'foo.img', fmt=raw size=1073741824 preallocation=full
format name: raw
cluster size: 0 bytes
vm state offset: 0 bytes

# qemu-img --version
qemu-img version 2.12.0 (qemu-kvm-rhev-2.12.0-7.el7)
# qemu-img create -f raw -o preallocation=full foo.img 1G &  sleep 0.5; qemu-io -c info -c close -r foo.img
[1] 19485
Formatting 'foo.img', fmt=raw size=1073741824 preallocation=full
can't open device foo.img: Failed to get "consistent read" lock
Is another process using the image?

Comment 6 Max Reitz 2018-07-11 09:56:29 UTC
Yes, that is correct.  This is an issue with the backport for BZ 1519144, which was included in 2.12.0-7.

Sorry I did not specify the downstream version.

Max

Comment 7 Miroslav Rezanina 2018-07-24 14:40:43 UTC
Fix included in qemu-kvm-rhev-2.12.0-8.el7

Comment 9 Tingting Mao 2018-07-26 05:15:57 UTC
Verified this issue like below.

Package tested:
qemu-kvm-rhev-2.12.0-8.el7
kernel-3.10.0-926.el7

Steps:
# qemu-img create -f raw -o preallocation=full foo.img 1G &  sleep 0.5; qemu-io -c info -c close -r foo.img
[1] 12008
Formatting 'foo.img', fmt=raw size=1073741824 preallocation=full
format name: raw
cluster size: 0 bytes
vm state offset: 0 bytes

Comment 10 errata-xmlrpc 2018-11-01 11:13:00 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3443


Note You need to log in before you can comment on or make changes to this bug.