Fix up scsi_test_unit_ready() to work correctly with CD-ROMs
PATCH 1/1 Fix up scsi_test_unit_ready() to work correctly with CD-ROMs
Olaf Hering noticed that SG_IO was no-longer working correctly on some CD-ROMS. The reason is a change in behaviour induced by switching to the new scsi_test_unit_ready() API.
Apparently the CD-ROM special case needs to ignore both UNIT_ATTENTION and NOT_READY for removable media.
James
===== drivers/scsi/scsi_lib.c 1.133 vs edited =====
drivers/scsi/scsi_lib.c +4 -3
@@ -1585,11 +1585,12 @@if (!sreq)return -ENOMEM ; - sreq->sr_data_direction =DMA_NONE ; -scsi_wait_req (sreq, cmd,NULL ,0 , timeout, retries); + sreq->sr_data_direction =DMA_NONE ; +scsi_wait_req (sreq, cmd,NULL ,0 , timeout, retries);if ((driver_byte (sreq->sr_result) &DRIVER_SENSE ) && - (sreq->sr_sense_buffer[2 ] &0x0f ) ==UNIT_ATTENTION && + ((sreq->sr_sense_buffer[2 ] &0x0f ) ==UNIT_ATTENTION || + (sreq->sr_sense_buffer[2 ] &0x0f ) ==NOT_READY ) && sdev->removable) { sdev->changed =1 ; sreq->sr_result =0 ;
Quoted 15 lines · James Bottomley
Olaf Hering noticed that
SG_IOwas no-longer working correctly on some CD-ROMS. The reason is a change in behaviour induced by switching to the newscsi_test_unit_ready()API.Apparently the CD-ROM special case needs to ignore both
UNIT_ATTENTIONandNOT_READYfor removable media.James
=====
drivers/scsi/scsi_lib.c1.133 vs edited =====drivers/scsi/scsi_lib.c +0
-0@@ -1585,11 +1585,12 @@if (!sreq)return -ENOMEM ;
drivers/scsi/scsi_lib.c line 1593
Quoted 10 lines
drivers/scsi/scsi_lib.c +4
-3- sreq->sr_data_direction =DMA_NONE ; -scsi_wait_req (sreq, cmd,NULL ,0 , timeout, retries); + sreq->sr_data_direction =DMA_NONE ; +scsi_wait_req (sreq, cmd,NULL ,0 , timeout, retries); if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) && - (sreq->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION && + ((sreq->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION || + (sreq->sr_sense_buffer[2] & 0x0f) == NOT_READY) &&
James,
Is the "descriptor" sense data patch which Christoph and I worked on likely to be accepted?
That way awkward and descriptor format unfriendly code like:
sreq->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION
could be replaced with something like (after a little overhead):
sshd.sense_key == UNIT_ATTENTION
Doug Gilbert
Quoted 3 lines · Douglas Gilbert
James,
Is the "descriptor" sense data patch which Christoph and I worked on likely to be accepted?
That patch (and I'd rather say it's yours because you did the hard work :)) is in now.