SG_IO ioctl issued to a virtio device doesn't finish

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5 update 7 Beta
  • Architecture: x86_64
  • Kernel Version: 2.6.18-262.el5
  • Drivers or hardware or architecture dependency: virtio,qemu-kvm

Issue

  • With HostOS(RHEL6SP1)/GuestOS(RHEL5SP7 beta), SG_IO ioctl issued to a virtio device doesn't finish.
  • According ot a backtrace, it wait to finish I/O. But this process does not finish
    crash> bt 5785
    PID: 5785   TASK: e74d1000  CPU: 0   COMMAND: "a.out"
     #0 [cfa91ba8] schedule at c061e742
     #1 [cfa91c20] wait_for_completion at c061e8b0
     #2 [cfa91c48] blk_execute_rq at c04e22e5
     #3 [cfa91cd8] sg_io at c04e5e18
     #4 [cfa91d6c] scsi_cmd_ioctl at c04e6347
     #5 [cfa91e0c] blkdev_driver_ioctl at c04e41f4
     #6 [cfa91e28] blkdev_ioctl at c04e490d
     #7 [cfa91f24] block_ioctl at c047ca49
     #8 [cfa91f30] do_ioctl at c048634b
     #9 [cfa91f44] vfs_ioctl at c04868dc
    #10 [cfa91fa0] sys_ioctl at c048697c
    #11 [cfa91fb8] system_call at c0404f44
        EAX: ffffffda  EBX: 00000003  ECX: 00002285  EDX: bfb6439c 
        DS:  007b      ESI: 00a4fca0  ES:  007b      EDI: bfb643dc
        SS:  007b      ESP: bfb64368  EBP: bfb64918
        CS:  0073      EIP: 00289410  ERR: 00000036  EFLAGS: 00000246 
  • When they used GuestOS(RHEL6.0), SG_IO run normally.

Resolution

Root Cause

From Technical Notes:

SG_IO ioctls were not implemented correctly in the Red Hat Enterprise
Linux 5 virtio-blk driver. Sending an SG_IO ioctl request to a virtio-blk
disk caused the sending thread to enter an uninterruptible sleep state ("D"
state). With this update, SG_IO ioctls are rejected by the virtio-blk
driver: the ioctl system call will simply return an ENOTTY ("Inappropriate
ioctl for device") error and the thread will continue normally.

Diagnostic Steps

The application starts SG_IO.

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.

Comments