mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Itai Nahshon <nahshon@actcom.co.il>
To: Richard Gooch <rgooch@ras.ucalgary.ca>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org, Pete Zaitcev <zaitcev@redhat.com>
Subject: [PATCH] [was SCSI host numbers? ]
Date: Thu, 21 Mar 2002 23:48:21 +0200	[thread overview]
Message-ID: <200203212148.g2LLmY426830@lmail.actcom.co.il> (raw)
In-Reply-To: <E16LjdE-0003m4-00@the-village.bc.nu> <200201160703.g0G73Sr27779@vindaloo.ras.ucalgary.ca> <200201160947.g0G9lxv15813@lmail.actcom.co.il>

[-- Attachment #1: Type: text/plain, Size: 1364 bytes --]

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


[-- Attachment #2: scsi-host_no.patch --]
[-- Type: text/x-diff, Size: 1441 bytes --]

--- 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);
 }
 

  reply	other threads:[~2002-03-21 21:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-02  1:19 SCSI host numbers? Itai Nahshon
2002-01-02 11:32 ` Alan Cox
2002-01-02 23:35   ` Itai Nahshon
2002-01-06  1:44   ` Richard Gooch
2002-01-13 20:41     ` Itai Nahshon
2002-01-14  6:36     ` Richard Gooch
2002-01-15 12:19       ` Itai Nahshon
2002-01-16  7:03       ` Richard Gooch
2002-01-16  9:47         ` Itai Nahshon
2002-03-21 21:48           ` Itai Nahshon [this message]
2002-01-02 19:31 ` Richard Gooch
2002-01-02 21:01   ` Alan Cox
2002-01-02 21:18   ` Richard Gooch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200203212148.g2LLmY426830@lmail.actcom.co.il \
    --to=nahshon@actcom.co.il \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rgooch@ras.ucalgary.ca \
    --cc=zaitcev@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®