Patching K3B on Kubuntu Hardy Heron
May 6th, 2008I’ve recently built a new desktop machine - the subject of another post when I get time - and because the hardware is fairly recent I decided to try Ubuntu which I knew would support it rather than switch to an unstable branch of Debian.
My first impressions of Hardy Heron - Ubuntu’s latest release; I’m using the variant with the KDE desktop - are very positive. The installer is excellent and the hardware detection very impressive. As a comparison, it took me the better part of a day to install a fairly vanilla Windows XP Pro SP2 on the first partition of the box. Nearly every driver install required a reboot as did many of the security updates. By contrast, it took less than an hour to download and install Kubuntu and the installation includes a far greater range of packages than I have on the windows partition.
The one fly in the ointment has been a problem with K3b. If I started with a blank CD in the drive, all was fine but launching it with either an empty drive or a blank DVD caused the process to hang for a long while and finally launch with the warning:
“No CD/DVD writer found.
K3b did not find an optical writing device in your system. Thus, you will not be able to burn CDs or DVDs. However, you can still use other K3b features like audio track extraction or audio transcoding or ISO9660 image creation.”
After this the DVD drive was disabled, making it impossible to even eject until the machine had been shutdown completely and restarted.
Both growisofs and wodim worked from the command line so the problem had to be in the KDE application. Launching K3B from the console reveals debug information and showed the hang up was occurring after the step checking for RAW_R96R:
... (K3bDevice::Device) /dev/scd0: checking for RAW_R96R
After a long pause the process would continue:
(K3bDevice::ScsiCommand) failed:
command: GET PERFORMANCE (ac)
errorcode: 72
sense key: NO SENSE (2)
asc: 0
ascq: 3
(K3bDevice::Device) /dev/scd0: GET PERFORMANCE length det failed.
(K3bDevice::ScsiCommand) failed:
command: MODE SENSE (5a)
errorcode: 0
sense key: NO SENSE (2)
asc: 0
ascq: 0
(K3bDevice::Device) /dev/scd0: MODE SENSE length det failed.
(K3bDevice::ScsiCommand) failed:
command: MODE SENSE (5a)
errorcode: 0
sense key: NO SENSE (2)
asc: 0
ascq: 0
(K3bDevice::Device) /dev/scd0: MODE SENSE with real length 65535 failed.
(K3bDevice::Device) could not open device /dev/scd0 for reading
(No such device or address)
Error while retrieving capabilities.
Could not initialize device /dev/scd0
Could not resolve /dev/scd0
/dev/scd0 resolved to /dev/scd0
(K3bDevice::Device) could not open device /dev/scd0 for reading
(No such file or directory)
could not open device /dev/scd0 (No such file or directory)
Devices:
------------------------------
kdecore (KAction): WARNING: KActionCollection::operator+=(): function is severely deprecated.
removing udi /org/freedesktop/Hal/devices/pci_8086_2922_scsi_host_0_scsi_device_ lun0_scsi_generic
removing udi /org/freedesktop/Hal/devices/pci_8086_2922_scsi_host_0_scsi_device_ lun0
removing udi /org/freedesktop/Hal/devices/pci_8086_2922_scsi_host_0
removing udi /org/freedesktop/Hal/devices/storage_model_DVDRW_LH_20A1S
Unmapping udi /org/freedesktop/Hal/devices/storage_model_DVDRW_LH_20A1S from dev ice /dev/scd0
dmesg reveals the following occuring
May 1 23:52:15 mingus kernel: [ 3580.143800] cdb ac 00 00 00 00 00 00 00 00 01 03 00 00 00 00 00 May 1 23:52:15 mingus kernel: [ 3580.143801] res 40/00:03:00:00:00/00:00:00:00:00/a0 Emask 0x4 (timeout) May 1 23:52:15 mingus kernel: [ 3580.455532] ata6: soft resetting link May 1 23:52:15 mingus kernel: [ 3580.619411] ata6: SATA link up 1.5 Gbps (SStatus 113 SControl 300) May 1 23:52:45 mingus kernel: [ 3610.751976] ata6.00: qc timeout (cmd 0xa1) May 1 23:52:45 mingus kernel: [ 3610.751985] ata6.00: failed to IDENTIFY (I/O error, err_mask=0x5) May 1 23:52:45 mingus kernel: [ 3610.751993] ata6: failed to recover some devices, retrying in 5 secs May 1 23:52:50 mingus kernel: [ 3615.752086] ata6: hard resetting link May 1 23:52:56 mingus kernel: [ 3621.263794] ata6: port is slow to respond, please be patient (Status 0x80) May 1 23:53:00 mingus kernel: [ 3625.752312] ata6: hard resetting link May 1 23:53:06 mingus kernel: [ 3631.268013] ata6: port is slow to respond, please be patient (Status 0x80) May 1 23:53:11 mingus kernel: [ 3635.804490] ata6: hard resetting link May 1 23:53:16 mingus kernel: [ 3641.316197] ata6: port is slow to respond, please be patient (Status 0x80) May 1 23:53:46 mingus kernel: [ 3670.813264] ata6: limiting SATA link speed to 1.5 Gbps May 1 23:53:46 mingus kernel: [ 3670.813266] ata6: hard resetting link May 1 23:53:51 mingus kernel: [ 3675.821377] ata6.00: disabled May 1 23:53:51 mingus kernel: [ 3675.821404] ata6: hard resetting link May 1 23:53:57 mingus kernel: [ 3681.736761] ata6: port is slow to respond, please be patient (Status 0x80) May 1 23:54:01 mingus kernel: [ 3685.825584] ata6: hard resetting link May 1 23:52:15 mingus kernel: [ 3580.143800] cdb ac 00 00 00 00 00 00 00 00 01 03 00 00 00 00 00 May 1 23:52:15 mingus kernel: [ 3580.143801] res 40/00:03:00:00:00/00:00:00:00:00/a0 Emask 0x4 (timeout) May 1 23:52:15 mingus kernel: [ 3580.455532] ata6: soft resetting link May 1 23:52:15 mingus kernel: [ 3580.619411] ata6: SATA link up 1.5 Gbps (SStatus 113 SControl 300) May 1 23:52:45 mingus kernel: [ 3610.751976] ata6.00: qc timeout (cmd 0xa1) May 1 23:52:45 mingus kernel: [ 3610.751985] ata6.00: failed to IDENTIFY (I/O error, err_mask=0x5) May 1 23:52:45 mingus kernel: [ 3610.751993] ata6: failed to recover some devices, retrying in 5 secs May 1 23:52:50 mingus kernel: [ 3615.752086] ata6: hard resetting link May 1 23:52:56 mingus kernel: [ 3621.263794] ata6: port is slow to respond, please be patient (Status 0x80) May 1 23:53:00 mingus kernel: [ 3625.752312] ata6: hard resetting link May 1 23:53:06 mingus kernel: [ 3631.268013] ata6: port is slow to respond, please be patient (Status 0x80) May 1 23:53:11 mingus kernel: [ 3635.804490] ata6: hard resetting link May 1 23:53:16 mingus kernel: [ 3641.316197] ata6: port is slow to respond, please be patient (Status 0x80) May 1 23:53:46 mingus kernel: [ 3670.813264] ata6: limiting SATA link speed to 1.5 Gbps May 1 23:53:46 mingus kernel: [ 3670.813266] ata6: hard resetting link May 1 23:53:51 mingus kernel: [ 3675.821377] ata6.00: disabled May 1 23:53:51 mingus kernel: [ 3675.821404] ata6: hard resetting link May 1 23:53:57 mingus kernel: [ 3681.736761] ata6: port is slow to respond, please be patient (Status 0x80) May 1 23:54:01 mingus kernel: [ 3685.825584] ata6: hard resetting link May 1 23:54:07 mingus kernel: [ 3691.752971] ata6: port is slow to respond, please be patient (Status 0x80) May 1 23:54:11 mingus kernel: [ 3695.841797] ata6: hard resetting link May 1 23:54:17 mingus kernel: [ 3701.757192] ata6: port is slow to respond, please be patient (Status 0x80) May 1 23:54:46 mingus kernel: [ 3730.858562] ata6: limiting SATA link speed to 1.5 Gbps May 1 23:54:46 mingus kernel: [ 3730.858565] ata6: hard resetting link May 1 23:54:51 mingus kernel: [ 3735.884188] ata6: EH complete May 1 23:54:51 mingus kernel: [ 3735.884287] ata6.00: detaching (SCSI 5:0:0:0)
It looks like the bug is probably in the libsata code failing to handle an error rather than K3B but I haven’t had a chance to investigate further.
As a quick workaround, download the k3b source and hack bool K3bDevice::Device::getSupportedWriteSpeedsViaGP to return false immediately and shortcircuit the call to ioctl that locks the device. The code will fall back to setting a maximum speed determined by the previous call to getSupportedWriteSpeedsVia2A.