RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1537985 - luks image cannot be preallocated with full mode during resize operation once the image has been resized before
Summary: luks image cannot be preallocated with full mode during resize operation once...
Keywords:
Status: CLOSED DUPLICATE of bug 1566587
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.5
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Daniel Berrangé
QA Contact: Ping Li
URL:
Whiteboard:
Depends On: 1549231
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-01-24 09:08 UTC by Ping Li
Modified: 2018-04-18 03:26 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-17 13:45:11 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Ping Li 2018-01-24 09:08:22 UTC
Description of problem:
qemu-img supports to preallocate new disk space with full mode during resize operation on a luks image. However it cannot work when the luks image has been resized before. 

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.10.0-18.el7
kernel-3.10.0-836.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Preallocate with mode off, falloc, full, and falloc in turn.
# qemu-img create -f luks --object secret,id=sec0,data=test -o key-secret=sec0 test1.luks 5G
# ls -als test1.luks 
256 -rw-r--r-- 1 root root 5370777600 Jan 24 03:39 test1.luks

# qemu-img resize --preallocation=off --object secret,id=sec0,data=test --image-opts driver=luks,key-secret=sec0,file.filename=test1.luks +1G
Image resized.
# ls -als test1.luks 
256 -rw-r--r-- 1 root root 6444519424 Jan 24 03:40 test1.luks

# qemu-img resize --preallocation=falloc --object secret,id=sec0,data=test --image-opts driver=luks,key-secret=sec0,file.filename=test1.luks +1G
Image resized.
# ls -als test1.luks 
1048832 -rw-r--r-- 1 root root 7518261248 Jan 24 03:40 test1.luks

# qemu-img resize --preallocation=full --object secret,id=sec0,data=test --image-opts driver=luks,key-secret=sec0,file.filename=test1.luks +1G
Image resized.
# ls -als test1.luks    ----> Fail to preallocate with full mode
1048832 -rw-r--r-- 1 root root 8592003072 Jan 24 03:41 test1.luks

# qemu-img resize --preallocation=falloc --object secret,id=sec0,data=test --image-opts driver=luks,key-secret=sec0,file.filename=test1.luks +1G
Image resized.
# ls -als test1.luks 
2097408 -rw-r--r-- 1 root root 9665744896 Jan 24 03:41 test1.luks

2. Preallocate with mode off and full.
# qemu-img create -f luks --object secret,id=sec0,data=test -o key-secret=sec0 test2.luks 5G
# qemu-img resize --preallocation=off --object secret,id=sec0,data=test --image-opts driver=luks,key-secret=sec0,file.filename=test2.luks +1G
Image resized.
# ls -als test2.luks 
256 -rw-r--r-- 1 root root 6444519424 Jan 24 03:43 test2.luks
# qemu-img resize --preallocation=full --object secret,id=sec0,data=test --image-opts driver=luks,key-secret=sec0,file.filename=test2.luks +1G
Image resized.
# ls -als test2.luks    ----> Fail to preallocate with full mode
256 -rw-r--r-- 1 root root 7518261248 Jan 24 03:43 test2.luks

3. Repeat to preallocate with mode full
# qemu-img create -f luks --object secret,id=sec0,data=test -o key-secret=sec0 test3.luks 5G
# qemu-img resize --preallocation=full --object secret,id=sec0,data=test --image-opts driver=luks,key-secret=sec0,file.filename=test3.luks +1G
Image resized.
# ls -als test3.luks    ----> Success to preallocate with full mode
1048832 -rw-r--r-- 1 root root 6444519424 Jan 24 03:44 test3.luks
# qemu-img resize --preallocation=full --object secret,id=sec0,data=test --image-opts driver=luks,key-secret=sec0,file.filename=test3.luks +1G
Image resized.
# ls -als test3.luks    ----> Fail to preallocate with full mode
1048832 -rw-r--r-- 1 root root 7518261248 Jan 24 03:44 test3.luks

Actual results:


Expected results:


Additional info:
Cannot met the issue on qcow2 image
# qemu-img create -f qcow2 test.qcow2 5G
Formatting 'test.qcow2', fmt=qcow2 size=5368709120 cluster_size=65536 lazy_refcounts=off refcount_bits=16
# qemu-img map --output=json test.qcow2 
[{ "start": 0, "length": 5368709120, "depth": 0, "zero": true, "data": false}]

# qemu-img resize --preallocation=falloc test.qcow2 +1G
Image resized.
# qemu-img map --output=json test.qcow2 
[{ "start": 0, "length": 5368709120, "depth": 0, "zero": true, "data": false},
{ "start": 5368709120, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": 393216},
{ "start": 5368774656, "length": 1073676288, "depth": 0, "zero": true, "data": true, "offset": 458752}]

# qemu-img resize --preallocation=full test.qcow2 +1G
Image resized.
# qemu-img map --output=json test.qcow2 
[{ "start": 0, "length": 5368709120, "depth": 0, "zero": true, "data": false},
{ "start": 5368709120, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": 393216},
{ "start": 5368774656, "length": 1073676288, "depth": 0, "zero": true, "data": true, "offset": 458752},
{ "start": 6442450944, "length": 1073741824, "depth": 0, "zero": false, "data": true, "offset": 1074331648}]

# qemu-img resize --preallocation=full test.qcow2 +1G
Image resized.
# qemu-img map --output=json test.qcow2 
[{ "start": 0, "length": 5368709120, "depth": 0, "zero": true, "data": false},
{ "start": 5368709120, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": 393216},
{ "start": 5368774656, "length": 1073676288, "depth": 0, "zero": true, "data": true, "offset": 458752},
{ "start": 6442450944, "length": 1073741824, "depth": 0, "zero": false, "data": true, "offset": 1074331648},
{ "start": 7516192768, "length": 1073741824, "depth": 0, "zero": false, "data": true, "offset": 2148204544}]

Comment 3 Daniel Berrangé 2018-02-26 19:01:47 UTC
(In reply to Ping Li from comment #0)
> 1. Preallocate with mode off, falloc, full, and falloc in turn.
> # qemu-img create -f luks --object secret,id=sec0,data=test -o
> key-secret=sec0 test1.luks 5G
> # ls -als test1.luks 
> 256 -rw-r--r-- 1 root root 5370777600 Jan 24 03:39 test1.luks
> 
> # qemu-img resize --preallocation=off --object secret,id=sec0,data=test
> --image-opts driver=luks,key-secret=sec0,file.filename=test1.luks +1G
> Image resized.
> # ls -als test1.luks 
> 256 -rw-r--r-- 1 root root 6444519424 Jan 24 03:40 test1.luks
> 
> # qemu-img resize --preallocation=falloc --object secret,id=sec0,data=test
> --image-opts driver=luks,key-secret=sec0,file.filename=test1.luks +1G
> Image resized.
> # ls -als test1.luks 
> 1048832 -rw-r--r-- 1 root root 7518261248 Jan 24 03:40 test1.luks
> 
> # qemu-img resize --preallocation=full --object secret,id=sec0,data=test
> --image-opts driver=luks,key-secret=sec0,file.filename=test1.luks +1G
> Image resized.
> # ls -als test1.luks    ----> Fail to preallocate with full mode
> 1048832 -rw-r--r-- 1 root root 8592003072 Jan 24 03:41 test1.luks

I don't see this behaviour, instead I see a fatal error from qemu-img resize:

qemu-img: Failed to seek to the old end of file: Invalid argument

This is caused by 32-bit integer overflow, and unrelated to the luks driver. I've filed a separate bug

  https://bugzilla.redhat.com/show_bug.cgi?id=1549231


but it is possible, that the problem you see is simply a result of this integer overflow. So lets get that bug fixed before continuing to test this bug.


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