Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1605061

Summary: preallocation mode(full and falloc) is not supported when creating qcow2 file with iscsi backend
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Tingting Mao <timao>
Component: qemu-kvmAssignee: Virtualization Maintenance <virt-maint>
qemu-kvm sub component: iSCSI QA Contact: Xueqiang Wei <xuwei>
Status: CLOSED WONTFIX Docs Contact:
Severity: medium    
Priority: medium CC: chaoyang, coli, hreitz, jinzhao, juzhang, kanderso, kwolf, mtessun, ngu, rbalakri, virt-maint, zixchen
Version: ---Keywords: Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-15 07:40:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tingting Mao 2018-07-20 05:51:36 UTC
Description of problem:
Preallocation mode(full and falloc) is not supported when creating qcow2 file with iscsi backend 

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.12.0-7.el7
kernel-3.10.0-918

How reproducible:
100%

Steps to Reproduce:
1.Login iscsi target and create PV and VG and lv.
# vi /etc/iscsi/initiatorname.iscsi(update the value of InitiatorName)
# systemctl restart iscsid
# iscsiadm -m discovery -t st -p $iscsi_server_ip
# iscsiadm -m node -T iqn.2018-05.com.example.xxx -p $iscsi_server_ip:3260 -l
# pvcreate /dev/sdb
# vgcreate vgtest /dev/sdb
# lvcreate -L 5G -n test01 vgtest
2.Create qcow2 based on the lv.
2.1 Create with default mode.
# qemu-img create -f qcow2 /dev/vgtest/test01 2G
Formatting '/dev/vgtest/test01', fmt=qcow2 size=2147483648 cluster_size=65536 lazy_refcounts=off refcount_bits=16
2.2 Create with "metadata" preallocation mode.
# qemu-img create -f qcow2 /dev/vgtest/test01 2G -o preallocation=metadata
Formatting '/dev/vgtest/test01', fmt=qcow2 size=2147483648 cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16
2.3 Create with "full" preallocation mode.
# qemu-img create -f qcow2 /dev/vgtest/test01 2G -o preallocation=full
Formatting '/dev/vgtest/test01', fmt=qcow2 size=2147483648 cluster_size=65536 preallocation=full lazy_refcounts=off refcount_bits=16
qemu-img: /dev/vgtest/test01: Preallocation mode 'full' unsupported for this non-regular file
2.4 Create with "falloc" preallocation mode.
# qemu-img create -f qcow2 /dev/vgtest/test01 2G -o preallocation=falloc
Formatting '/dev/vgtest/test01', fmt=qcow2 size=2147483648 cluster_size=65536 preallocation=falloc lazy_refcounts=off refcount_bits=16
qemu-img: /dev/vgtest/test01: Preallocation mode 'falloc' unsupported for this non-regular file


Actual results:
As above, preallocation "full" and "falloc" mode is not supported.

Expected results:
All the preallocation modes should be supported, or there is special descriptions for the unsupported modes in qemu-img manpage.


Additional info:
For rhel7.5/qemu-kvm-2.10, all of the modes are supported well.

Steps(iscsi configure process is ignored there, for it is the same as above):
1. Check the version of QEMU
# qemu-img --version
qemu-img version 2.10.0(qemu-kvm-rhev-2.10.0-21.el7_5.1)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
2. Create image with default mode, and dump the metadata.
# qemu-img create -f qcow2 /dev/vg/testest 1G
Formatting '/dev/vg/testest', fmt=qcow2 size=1073741824 cluster_size=65536 lazy_refcounts=off refcount_bits=16
# qemu-img map --output=json /dev/vg/testest 
[{ "start": 0, "length": 1073741824, "depth": 0, "zero": true, "data": false}]
3. Create image with falloc mode, and dump the metadata
# qemu-img create -f qcow2 /dev/vg/testest 1G -o preallocation=falloc
Formatting '/dev/vg/testest', fmt=qcow2 size=1073741824 cluster_size=65536 preallocation=falloc lazy_refcounts=off refcount_bits=16
# qemu-img map --output=json /dev/vg/testest 
[{ "start": 0, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 327680},
{ "start": 536870912, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 537264128}]
4. Create image with full mode, and dump the metadata
# qemu-img create -f qcow2 /dev/vg/testest 1G -o preallocation=full
Formatting '/dev/vg/testest', fmt=qcow2 size=1073741824 cluster_size=65536 preallocation=full lazy_refcounts=off refcount_bits=16
# qemu-img map --output=json /dev/vg/testest 
[{ "start": 0, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 327680},
{ "start": 536870912, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 537264128}]
5. Create image with metadata mode, and dump the metadata
# qemu-img create -f qcow2 /dev/vg/testest 1G -o preallocation=metadata
Formatting '/dev/vg/testest', fmt=qcow2 size=1073741824 cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16
# qemu-img map --output=json /dev/vg/testest 
[{ "start": 0, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 327680},
{ "start": 536870912, "length": 536870912, "depth": 0, "zero": false, "data": true, "offset": 537264128}]

Comment 3 Tingting Mao 2018-07-20 06:21:39 UTC
For qemu-img resize, the "full" and "falloc" modes also do not work(the environment is the same as qemu-kvm-rhev-2.12.0-7.el7 part above). 

I have no idea if this is the same issue as comment 0. I just list it here, pls let me know if it is not suitable. 


Steps:
1. Create lv
# lvcreate -L 10G -n test01 vgtest
  Logical volume "test01" created.
2. Create qcow2 file 
# qemu-img create -f qcow2 /dev/vgtest/test01 2G
Formatting '/dev/vgtest/test01', fmt=qcow2 size=2147483648 cluster_size=65536 lazy_refcounts=off refcount_bits=16
3. Resize the image
3.1 Resize with "full" mode, the error info is not correct for the remaining size is large enough.
# qemu-img resize --preallocation=full /dev/vgtest/test01 +50M
qemu-img: Failed to resize refcount structures: No space left on device
qemu-img: Failed to flush the refcount block cache: No space left on device
3.2 Resize with "falloc" mode, the same
# qemu-img resize --preallocation=falloc /dev/vgtest/test01 +50M
qemu-img: Failed to resize refcount structures: No space left on device
qemu-img: Failed to flush the refcount block cache: No space left on device
3.3 Resize with "off" and "metadata" mode in turn, it works
# qemu-img resize --preallocation=metadata /dev/vgtest/test01 +50M
Image resized.
# qemu-img resize --preallocation=off /dev/vgtest/test01 +50M
Image resized.
# qemu-img map --output=json /dev/vgtest/test01
[{ "start": 0, "length": 2147483648, "depth": 0, "zero": true, "data": false},
{ "start": 2147483648, "length": 52428800, "depth": 0, "zero": false, "data": true, "offset": 327680},
{ "start": 2199912448, "length": 52428800, "depth": 0, "zero": true, "data": false}]

Comment 4 Fam Zheng 2018-07-27 06:44:34 UTC
The old version basically ignores the preallocation option, therefore it doesn't report an error like now.

QEMU cannot use fallocate on block devices. The 'falloc' mode relies on that to work.

We could probably implement the 'full' mode like the file driver.

Feature-wise I don't think this is a regression because we never really "supported" that.

Comment 5 Longxiang Lyu 2018-07-29 05:34:57 UTC
LVM has same issue.
# qemu-img --version
qemu-img version 2.12.0 (qemu-kvm-rhev-2.12.0-8.el7)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
# qemu-img create -f qcow2 /dev/mapper/vg--lolyu-img2 1G
Formatting '/dev/mapper/vg--lolyu-img2', fmt=qcow2 size=1073741824 cluster_size=65536 lazy_refcounts=off refcount_bits=16
# qemu-img resize --preallocation=full /dev/mapper/vg--lolyu-img2 +1G
qemu-img: Failed to resize refcount structures: No space left on device
qemu-img: Failed to flush the refcount block cache: No space left on device

Comment 6 Fam Zheng 2018-08-07 01:16:54 UTC
Based on comment 4 I'm moving this to 7.7. We'll have to implement falloc=full on upstream first. For falloc, the current behavior (reporting not supported) is expected.

Comment 7 Tingting Mao 2018-08-08 11:11:07 UTC
For libiscsi, preallocation could not work either.

# qemu-img create -f qcow2 iscsi://10.66.11.19/iqn.2018-07.com.example:t1/6 1G -o preallocation=full
Formatting 'iscsi://10.66.11.19/iqn.2018-07.com.example:t1/6', fmt=qcow2 size=1073741824 cluster_size=65536 preallocation=full lazy_refcounts=off refcount_bits=16
qemu-img: iscsi://10.66.11.19/iqn.2018-07.com.example:t1/6: Unsupported preallocation mode 'full'
# qemu-img create -f qcow2 iscsi://10.66.11.19/iqn.2018-07.com.example:t1/6 1G -o preallocation=falloc
Formatting 'iscsi://10.66.11.19/iqn.2018-07.com.example:t1/6', fmt=qcow2 size=1073741824 cluster_size=65536 preallocation=falloc lazy_refcounts=off refcount_bits=16
qemu-img: iscsi://10.66.11.19/iqn.2018-07.com.example:t1/6: Unsupported preallocation mode 'falloc'
# qemu-img create -f qcow2 iscsi://10.66.11.19/iqn.2018-07.com.example:t1/6 1G -o preallocation=metadata
Formatting 'iscsi://10.66.11.19/iqn.2018-07.com.example:t1/6', fmt=qcow2 size=1073741824 cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16
qemu-img: iSCSI WRITE10/16 failed at lba 2097919: SENSE KEY:ILLEGAL_REQUEST(5) ASCQ:LBA_OUT_OF_RANGE(0x2100)
qemu-img: iscsi://10.66.11.19/iqn.2018-07.com.example:t1/6: Could not preallocate metadata: No space left on device

Comment 12 Ademar Reis 2020-02-05 22:48:39 UTC
QEMU has been recently split into sub-components and as a one-time operation to avoid breakage of tools, we are setting the QEMU sub-component of this BZ to "General". Please review and change the sub-component if necessary the next time you review this BZ. Thanks

Comment 17 RHEL Program Management 2021-02-15 07:40:48 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.

Comment 18 Xueqiang Wei 2021-02-22 18:54:36 UTC
1. for block device, confirmed it with Kevin before, we don't do preallocation for block devices, only for regular files.
2. for libiscsi, allowed values: off
Versions:
kernel-4.18.0-289.el8.x86_64
qemu-kvm-5.2.0-8.module+el8.4.0+10093+e085f1eb

# qemu-img create -f iscsi -o ? iscsi:**
Supported options:
  preallocation=<str>    - Preallocation mode (allowed values: off)
  size=<size>            - Virtual disk size


So QE agrees to close this bug. Thanks.