lkml.org 
[lkml]   [2002]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] [was SCSI host numbers? ]
Date
Hello all,

Under some scenarios Linux assigns the same
host_no to more than one scsi device.

I raised this problem a long time ago.

To repeat the problem (all recent 2.4.x and possibly 2.5.x kernels):
Use two scsi drivers that are not required for system
use (mean - not the one that drives your hard disk). I got
this problem the first time with ide-scsi and usb-storage.
Call these device drivers A and B.
Host numbers are remembered after they are assigned
until the next reboot (or until unloading scsi_mod if
it is compiled as a module). Start with a "clean" system.

modprobe A
rmmod A
modprobe B
modprobe A

And - the two adapters now have the same host number.
In this case, some functions of A will not work. Especially devices
attached to A cannot be accessed through the sg interface. I believe
that writes to /proc/scsi/scsi will not work for these devices too
(but these are useless for the drivers that I used in my tests).

See also <http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=55876>.

I gave it as much testing as I could, and I believe it is not worse
than it was. People with more SCSI hardware should be able to try
more complex cases.

I left the stuff in #ifdef + comments because I believe that the scsi
registration code needs more cleanup. I have some related questions
that I will post on a separate message to lkml.

-- Itai

--- drivers/scsi/hosts-2.4.19-pre4.c Thu Mar 21 03:35:41 2002
+++ drivers/scsi/hosts.c Thu Mar 21 04:02:18 2002
@@ -81,8 +81,8 @@
struct Scsi_Host * scsi_hostlist;
struct Scsi_Device_Template * scsi_devicelist;

-int max_scsi_hosts;
-int next_scsi_host;
+int max_scsi_hosts; /* host_no for next new host */
+int next_scsi_host; /* count of registered scsi hosts */

void
scsi_unregister(struct Scsi_Host * sh){
@@ -107,6 +107,18 @@
if (shn) shn->host_registered = 0;
/* else {} : This should not happen, we should panic here... */

+#if 1
+ /* We shoult not decrement max_scsi_hosts (and make this value
+ * candidate for re-allocation by a different driver).
+ * Reason: the device is _still_ on the
+ * scsi_host_no_list and it's identified by its name. When the same
+ * device is re-registered it will get the same host_no again while
+ * new devices may use the allocation scheme and get this very same
+ * host_no.
+ * It's OK to have "holes" in the allocation but it does not mean
+ * "leaks".
+ */
+#else // if 0
/* If we are removing the last host registered, it is safe to reuse
* its host number (this avoids "holes" at boot time) (DB)
* It is also safe to reuse those of numbers directly below which have
@@ -121,7 +133,9 @@
break;
}
}
+#endif
next_scsi_host--;
+
kfree((char *) sh);
}
\
 
 \ /
  Last update: 2005-03-22 13:25    [W:0.053 / U:2.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site