public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* 2.4.20: possibly wrong handling of removeable scsi disks
@ 2003-02-23 12:17 Andreas Steinmetz
  2003-02-23 13:20 ` Willem Riede
  2003-02-24 23:10 ` Andries Brouwer
  0 siblings, 2 replies; 6+ messages in thread
From: Andreas Steinmetz @ 2003-02-23 12:17 UTC (permalink / raw)
  To: linux-scsi

[Please CC me on replies, I'm not subscribed to the list]

There is possibly a wrong handling of removable disks with no medium 
inserted in the sd driver. From 2.4.20 drivers/scsi/sd.c (...=snip):

static int sd_init_onedisk(int i)
{
    ...
     do {
             retries = 0;

             while (retries < 3) {
                     cmd[0] = TEST_UNIT_READY;
                    ...
                    if (the_result == 0
                         || SRpnt->sr_sense_buffer[2] != UNIT_ATTENTION)
                             break;
             }

             /*
              * If the drive has indicated to us that it doesn't have
              * any media in it, don't bother with any of the rest of
              * this crap.
              */
             if( the_result != 0
                 && ((driver_byte(the_result) & DRIVER_SENSE) != 0)
===>            && SRpnt->sr_sense_buffer[2] == UNIT_ATTENTION
                 && SRpnt->sr_sense_buffer[12] == 0x3A ) {
                     rscsi_disks[i].capacity = 0x1fffff;
                     sector_size = 512;
                     rscsi_disks[i].device->changed = 1;
                     rscsi_disks[i].ready = 0;
===>                break;
             }
            ...
     } while (the_result && spintime &&
              time_after(spintime_value + 100 * HZ, jiffies));
    ...

Now look at the marked (===>) lines above. I dont believe the test for 
UNIT_ATTENTION is correct. As far as I could find out the sense 
information from TEST_UNIT_READY should be either NO_SENSE, 
ILLEGAL_REQUEST or NOT_READY. As there is a check for 'medium not 
present' (0x3A) the test should be for NOT_READY instead of 
UNIT_ATTENTION. Furthermore the 'break;' statement seems wrong to me as 
the function lateron does e.g. things like READ_CAPACITY which doesn't 
make any sense if no medium is present. The correct statement seems to 
me 'return i;'.

As a sidenote sd_init_onedisk() should be changed to return void. It is 
static and the return value is nowhere used.

If my above assumptions are right please let me know, I'll submit 
patches in this case.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-02-24 23:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-23 12:17 2.4.20: possibly wrong handling of removeable scsi disks Andreas Steinmetz
2003-02-23 13:20 ` Willem Riede
2003-02-23 13:41   ` Andreas Steinmetz
2003-02-23 16:14     ` Scott Merritt
2003-02-24 23:10 ` Andries Brouwer
2003-02-24 23:46   ` Scott Merritt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox