Bug 1745443

Summary: qemu, qemu-img fail to detect alignment with XFS and Gluster/XFS on 4k block device [rhel-7.7.z]
Product: Red Hat Enterprise Linux 7 Reporter: RAD team bot copy to z-stream <autobot-eus-copy>
Component: qemu-kvm-rhevAssignee: Hanna Czenczek <hreitz>
Status: CLOSED ERRATA QA Contact: Xueqiang Wei <xuwei>
Severity: high Docs Contact:
Priority: high    
Version: 7.8CC: coli, hreitz, jen, jinzhao, juzhang, mrezanin, mtessun, nsoffer, rcyriac, virt-maint, vjuranek
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-rhev-2.12.0-33.el7_7.3 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1743365 Environment:
Last Closed: 2019-10-22 15:24:05 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1743365    
Bug Blocks: 1748022    

Description RAD team bot copy to z-stream 2019-08-26 07:25:59 UTC
This bug has been copied from bug #1743365 and has been proposed to be backported to 7.7 z-stream (EUS).

Comment 7 Xueqiang Wei 2019-09-16 11:24:09 UTC
Hi Max,

According to steps in https://bugzilla.redhat.com/show_bug.cgi?id=1743365#c0, can not create loop device with 4 sector size on rhel7.

losetup -f backing-file --show --sector-size=4096 (not support on rhel7)

 -b, --sector-size size
   Set the logical sector size of the loop device in bytes (since
   Linux 4.14). The option may be used when create a new loop
   device as well as stand-alone command to modify sector size of
   the already existing loop device.


So I think verify it by Comment 3 in bug[1] and Comment 31 in bug[2] are OK. And then do dd test on 4k disk.
Do you agree with me? If they are not enough. Please correct me. Thank you very much. 

 
[1] Bug 1743360 - qemu, qemu-img fail to detect alignment with XFS and Glsuter/XFS on 4k block device
[2] Bug 1738839 - I/O error when virtio-blk disk is backed by a raw image on 4k disk



Details as below:

Version:
Host:
kernel-3.10.0-1062.1.1.el7.x86_64
qemu-kvm-rhev-2.12.0-33.el7_7.3

Guest:
kernel-3.10.0-1062.el7.x86_64



Scenario 1(Installation)

# fdisk -l /dev/sdc 

Disk /dev/sdc: 599.6 GB, 599550590976 bytes, 146374656 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

1. Create a raw image on the xfs with 4k sectors
# mkfs.xfs /dev/sdc
# mount /dev/sdc /mnt/sdc
# qemu-img create -f raw /mnt/sdc/base.img 20G

2. install guest on it
/usr/libexec/qemu-kvm \
        -name 'guest-rhel77' \
        -machine q35 \
        -nodefaults \
        -vga qxl \
        -drive id=drive_cd1,if=none,snapshot=off,aio=threads,cache=unsafe,media=cdrom,file=/home/kvm_autotest_root/iso/linux/RHEL-7.7-20190723.1-Server-x86_64-dvd1.iso \
        -device ide-cd,id=cd1,drive=drive_cd1,bus=ide.0,unit=0 \
        -device pcie-root-port,id=pcie.0-root-port-9,slot=9,chassis=9,addr=0x9,bus=pcie.0 \
        -drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=raw,file=/mnt/sdc/base.img \
        -device virtio-blk-pci,id=virtio_blk_pci0,drive=drive_image1,bus=pcie.0-root-port-9,addr=0x0,bootindex=0 \
        -vnc :0 \
        -monitor stdio \
        -m 8192 \
        -smp 8 \
        -device pcie-root-port,id=pcie.0-root-port-8,slot=8,chassis=8,addr=0x8,bus=pcie.0 \
        -device virtio-net-pci,mac=9a:b5:b6:b1:b2:b3,id=idMmq1jH,vectors=4,netdev=idxgXAlm,bus=pcie.0-root-port-8,addr=0x0  \
        -netdev tap,id=idxgXAlm \
        -chardev socket,id=qmp_id_qmpmonitor1,path=/var/tmp/hucheng/monitor-qmpmonitor1-20180220-094308-h9I6hRsI,server,nowait \
        -mon chardev=qmp_id_qmpmonitor1,mode=control  \

after step 2, install successfully.


Scenario 2(Convert)
1. Create a test image on the xfs with 4k sectors
# dd if=/dev/urandom of=/mnt/sdc/test.img bs=1M count=2048
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 11.5596 s, 186 MB/s

2. Convert the image to the xfs with 512 bytes sectors
# qemu-img convert -f raw -O raw /mnt/sdc/test.img /home/tgt.img -t none -T none -p
    (100.00/100%)

3. Convert back to xfs with 4k sectors
# qemu-img convert -f raw -O raw /home/tgt.img /mnt/sdc/tgt.img -t none -T none -p
    (100.00/100%)

after step 3, not hit any error.


Scenario 3(dd test)
1. Create a test image on the xfs with 4k sectors
qemu-img create -f raw /mnt/sdc/test.raw 1G

2. boot guest with below cmd lines:
/usr/libexec/qemu-kvm \
    -S  \
    -name 'avocado-vt-vm1' \
    -machine q35  \
    -nodefaults \
    -device VGA,bus=pcie.0,addr=0x1  \
    -chardev socket,id=qmp_id_qmpmonitor1,path=/var/tmp/avocado_vkzzzsjy/monitor-qmpmonitor1-20190827-054125-X8YHvELh,server,nowait \
    -mon chardev=qmp_id_qmpmonitor1,mode=control  \
    -chardev socket,id=qmp_id_catch_monitor,path=/var/tmp/avocado_vkzzzsjy/monitor-catch_monitor-20190827-054125-X8YHvELh,server,nowait \
    -mon chardev=qmp_id_catch_monitor,mode=control \
    -device pvpanic,ioport=0x505,id=idnZn1j7 \
    -chardev socket,nowait,server,path=/var/tmp/avocado_vkzzzsjy/serial-serial0-20190827-054125-X8YHvELh,id=chardev_serial0 \
    -device isa-serial,id=serial0,chardev=chardev_serial0  \
    -chardev socket,id=seabioslog_id_20190827-054125-X8YHvELh,path=/var/tmp/avocado_vkzzzsjy/seabios-20190827-054125-X8YHvELh,server,nowait \
    -device isa-debugcon,chardev=seabioslog_id_20190827-054125-X8YHvELh,iobase=0x402 \
    -device pcie-root-port,id=pcie.0-root-port-2,slot=2,chassis=2,addr=0x2,bus=pcie.0 \
    -device qemu-xhci,id=usb1,bus=pcie.0-root-port-2,addr=0x0 \
    -drive id=drive_image1,if=none,snapshot=off,cache=none,format=qcow2,file=/home/kvm_autotest_root/images/rhel77-64-virtio.qcow2 \
    -device pcie-root-port,id=pcie.0-root-port-3,slot=3,chassis=3,addr=0x3,bus=pcie.0 \
    -device virtio-blk-pci,id=image1,drive=drive_image1,bootindex=0,bus=pcie.0-root-port-3,addr=0x0 \
    -device pcie-root-port,id=pcie.0-root-port-4,slot=4,chassis=4,addr=0x4,bus=pcie.0 \
    -device virtio-net-pci,mac=9a:c8:3a:2f:3f:1c,id=idXNk6ZE,netdev=id595yhy,bus=pcie.0-root-port-4,addr=0x0  \
    -netdev tap,id=id595yhy,vhost=on \
    -m 14336  \
    -smp 24,maxcpus=24,cores=12,threads=1,sockets=2  \
    -cpu 'Skylake-Server',+kvm_pv_unhalt \
    -device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1  \
    -vnc :0  \
    -rtc base=localtime,clock=host,driftfix=slew  \
    -boot order=cdn,once=c,menu=off,strict=off \
    -enable-kvm \
    -monitor stdio \
    -drive id=drive_data,if=none,snapshot=off,cache=none,format=raw,file=/mnt/sdc/test.raw \
    -device pcie-root-port,id=pcie.0-root-port-5,slot=5,chassis=5,addr=0x5,bus=pcie.0 \
    -device virtio-blk-pci,id=data1,drive=drive_data,bus=pcie.0-root-port-5,addr=0x0 \

3. create partition and format it in guest
# parted /dev/vdb mktable gpt
# parted /dev/vdb mkpart primary xfs "0%" "100%"
# mkfs.xfs /dev/vdb1
# mount /dev/vdb1 /mnt/
# dmesg |grep vdb
[    3.083553] virtio_blk virtio2: [vdb] 2097152 512-byte logical blocks (1.07 GB/1.00 GiB)
[  110.115527]  vdb:
[  116.953808]  vdb: vdb1
[  164.698477] XFS (vdb1): Mounting V5 Filesystem
[  164.706986] XFS (vdb1): Ending clean mount

4. dd test
# dd if=/dev/zero of=/mnt/test1/test.img bs=512k count=100 oflag=direct
100+0 records in
100+0 records out
52428800 bytes (52 MB) copied, 0.254502 s, 206 MB/s

# dd if=/dev/zero of=/mnt/test1/test.img bs=4096k count=100 oflag=direct
100+0 records in
100+0 records out
419430400 bytes (419 MB) copied, 1.56952 s, 267 MB/s

# dd if=/mnt/test1/test.img of=/dev/null bs=512k count=100 iflag=direct
100+0 records in
100+0 records out
52428800 bytes (52 MB) copied, 0.0557941 s, 940 MB/s

# dd if=/mnt/test1/test.img of=/dev/null bs=4096k count=100 iflag=direct
100+0 records in
100+0 records out
419430400 bytes (419 MB) copied, 0.359295 s, 1.2 GB/s

# dmesg |grep error


Scenario 4(Convert: tested with gluster)

gluster volume set gv0 performance.strict-o-direct on
mount.glusterfs gluster-virt-qe-01.lab.eng.pek2.redhat.com:/gv0 /mnt/gluster

1. Create a test image on the xfs with 4k sectors
# dd if=/dev/urandom of=/mnt/gluster/test.img bs=1M count=2048
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 58.3335 s, 36.8 MB/s

2. Convert the image to the xfs with 512 bytes sectors
# qemu-img convert -f raw -O raw /mnt/gluster/test.img /home/tgt.img -t none -T none -p
    (100.00/100%)

3. Convert back to xfs with 4k sectors
# qemu-img convert -f raw -O raw /home/tgt.img /mnt/gluster/tgt.img -t none -T none -p
    (100.00/100%)

after step 3, not hit any error.


Scenario 5(dd test with gluster)

# dd if=/dev/zero of=/mnt/gluster/test.img bs=512k count=100 oflag=direct
100+0 records in
100+0 records out
52428800 bytes (52 MB) copied, 4.00484 s, 13.1 MB/s

# dd if=/dev/zero of=/mnt/gluster/test.img bs=4096k count=100 oflag=direct
100+0 records in
100+0 records out
419430400 bytes (419 MB) copied, 30.3556 s, 13.8 MB/s

# dd if=/mnt/gluster/test.img of=/dev/null bs=512k count=100 iflag=direct
100+0 records in
100+0 records out
52428800 bytes (52 MB) copied, 0.628825 s, 83.4 MB/s

# dd if=/mnt/gluster/test.img of=/dev/null bs=4096k count=100 iflag=direct
100+0 records in
100+0 records out
419430400 bytes (419 MB) copied, 3.79064 s, 111 MB/s

# dmesg |grep error

Comment 8 Hanna Czenczek 2019-09-16 14:34:59 UTC
Yes, that looks good to me.

Comment 9 Xueqiang Wei 2019-09-17 02:03:47 UTC
According to Comment 7 and Comment 8, set status to VERIFIED.

Comment 11 errata-xmlrpc 2019-10-22 15:24:05 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/RHSA-2019:3179