RHV VM pauses due to 'qemu-kvm' getting EINVAL on i/o to a direct lun with scsi passthrough enabled

Solution Unverified - Updated

Environment

  • Red Hat Virtualization (RHV) 4.4.4
  • Red Hat Enterprise Linux (RHEL) 8.3 host;
    • kernel-4.18.0-240.10.1.el8_3.x86_64
    • qemu-kvm-5.1.0-14.module+el8.3.0+8790+80f9c6d8.1.x86_64

Issue

  • A RHV VM with a virtio-scsi direct lun configured with scsi passthrough, privileged i/o and scsi reservation enabled paused when a third-party script was executed.

Resolution

  • The bug is still currently under investigation.

  • The current workaround is to set max_sectors_kb to 512 inside the guest. In this specific case, this has allowed the i/o to complete and the VM not pause;

        e.g. if the device inside the guest is 'sdb';
    
        # echo 512 > /sys/block/sdb/queue/max_sectors_kb
    

Root Cause

  • An SG_IO ioctl returned an EINVAL error, resulting in the VM pausing.

  • A private RHEL platform bug, BZ 1943653, has been opened to address this.

Diagnostic Steps

  • Host's multipathed direct lun;

    36006016068bf5200d8ff1860f31231d7 dm-165 DGC,VRAID
    size=5.0G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
    |-+- policy='service-time 0' prio=50 status=active
    | |- 11:0:2:214 sdyk  129:576  active ready running
    | `- 12:0:3:214 sdavl 134:1200 active ready running
    `-+- policy='service-time 0' prio=10 status=enabled
      |- 11:0:3:214 sdacp 8:784    active ready running
      `- 12:0:2:214 sdaqz 71:1136  active ready running
    
  • Host's block device parameters;

# cat /sys/block/sdyk/queue/max_hw_sectors_kb
32767
# cat /sys/block/sdyk/queue/max_sectors_kb
4096
# cat /sys/block/sdyk/queue/max_segments
256
#  cat /sys/block/sdyk/queue/max_segment_size
65536
  • Guest's block device parameters;
# cat /sys/block/sdb/queue/max_hw_sectors_kb
32767
#  cat /sys/block/sdb/queue/max_sectors_kb
4096
#  cat /sys/block/sdb/queue/max_segments
254
#  cat /sys/block/sdb/queue/max_segment_size
65536

sg_inq --page 0xb0 /dev/sdb

VPD INQUIRY: Block limits page (SBC)
Maximum compare and write length: 1 blocks
Optimal transfer length granularity: 0 blocks [not reported]
Maximum transfer length: 4194303 blocks
Optimal transfer length: 8192 blocks
Maximum prefetch transfer length: 0 blocks [ignored]
Maximum unmap LBA count: 0 [Unmap command not implemented]
Maximum unmap block descriptor count: 0 [Unmap command not implemented]
Optimal unmap granularity: 0 blocks [not reported]
Unmap granularity alignment valid: false
Unmap granularity alignment: 0 [invalid]
Maximum write same length: 0 blocks [not reported]
Maximum atomic transfer length: 0 blocks [not reported]
Atomic alignment: 0 [unaligned atomic writes permitted]
Atomic transfer length granularity: 0 [no granularity requirement
Maximum atomic transfer length with atomic boundary: 0 blocks [not reported]
Maximum atomic boundary size: 0 blocks [can only write atomic 1 block]

  • Direct lun in XML;

          <disk type='block' device='lun' sgio='unfiltered' snapshot='no'>
            <driver name='qemu' type='raw' cache='none' error_policy='stop' io='native'/>
             <source dev='/dev/mapper/36006016068bf5200d8ff1860f31231d7' index='1'>
               <seclabel model='dac' relabel='no'/>
               <reservations managed='yes'>
                <source type='unix' path='/var/lib/libvirt/qemu/domain-27-xyz/pr-helper0.sock' mode='client'/>
              </reservations>
    
  • strace output;

    30482 17:45:30.109306 ioctl(24, SG_IO, {interface_id='S', dxfer_direction=SG_DXFER_TO_DEV, cmd_len=10, cmdp="\x2a\x00\x00\x00\x00\x00\x00\x1c\xb7\x00", mx_sb_len=252, iovec_count=58, dxfer_l
    en=3763712, timeout=4294967295, flags=SG_FLAG_DIRECT_IO, dxferp=[{iov_base="bys..mrq\1\0\0\0\267\34\0\0\4\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0
    \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0
    \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0
    \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0
    \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0
    \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0
    \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base
    ="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_
    base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {
    iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536
    }, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=6
    5536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_l
    en=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., i
    ov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..
    ., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\
    0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\
    0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\
    0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\
    0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\
    0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\
    0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=65536}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=28160}] <unfinished ..
    :
    .                 
    30482 17:45:30.109470 <... ioctl resumed>, status=0, masked_status=0, msg_status=0, sb_len_wr=0, sbp="", host_status=0, driver_status=0, resid=0, duration=0, info=0}) = -1 EINVAL (Invalid argument) <0.000062>
    

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.