All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sd_many done right (1/5)
@ 2002-07-26 15:45 Kurt Garloff
  0 siblings, 0 replies; 12+ messages in thread
From: Kurt Garloff @ 2002-07-26 15:45 UTC (permalink / raw)
  To: Linux SCSI list; +Cc: Linux kernel list, Marcelo Tosatti


[-- Attachment #1.1: Type: text/plain, Size: 1279 bytes --]

Hi,

here comes patch 1/5 from a series of patches to support more than 128 (and
optionally more than 256) SCSI disks with Linux 2.4 by changing the sd driver
to dynamically allocate memory and register block majors as disks get
attached.

The patches are all available at
http://www.suse.de/~garloff/linux/scsi-many/

This patch (1/5) does implement some infrastructure that is useful: We
extend the format of /proc/scsi/scsi to report the attached high-level
drivers. 
This can be used by userspace applications to dynamically create device
nodes or to talk to the corresponding sg device (which otherwise is non-
trivial to find out!) and inquire extra information such as serial number
or WWID.

Here's a sample.
Host: scsi5 Channel: 00 Id: 04 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0003
  Type:   Direct-Access                    ANSI SCSI revision: 03
  Attached drivers: sdr(b:41:10) sg18(c:15:12)
      
Patch is against 2.4.19rc1.
Marcelo, these patches are meant for inclusion into 2.4.20pre.

Regards,
-- 
Kurt Garloff  <garloff@suse.de>                          Eindhoven, NL
GPG key: See mail header, key servers         Linux kernel development
SuSE Linux AG, Nuernberg, DE                            SCSI, Security

[-- Attachment #1.2: scsi-rep-hldevs-2419rc1.diff --]
[-- Type: text/plain, Size: 8450 bytes --]

diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/hosts.h linux-2.4.18.S18.scsirephl/drivers/scsi/hosts.h
--- linux-2.4.18.S18.fixed/drivers/scsi/hosts.h	Wed Jun 12 11:37:09 2002
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/hosts.h	Wed Jun 12 11:53:54 2002
@@ -530,6 +530,7 @@
     void (*detach)(Scsi_Device *);
     int (*init_command)(Scsi_Cmnd *);     /* Used by new queueing code. 
                                            Selects command for blkdevs */
+    int (*find_kdev)(Scsi_Device *, char*, kdev_t*);  /* find back dev. */
 };
 
 void  scsi_initialize_queue(Scsi_Device * SDpnt, struct Scsi_Host * SHpnt);
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/osst.c linux-2.4.18.S18.scsirephl/drivers/scsi/osst.c
--- linux-2.4.18.S18.fixed/drivers/scsi/osst.c	Fri Dec 21 18:41:55 2001
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/osst.c	Wed Jun 12 11:39:47 2002
@@ -156,6 +156,7 @@
 static int osst_attach(Scsi_Device *);
 static int osst_detect(Scsi_Device *);
 static void osst_detach(Scsi_Device *);
+static int osst_find_kdev(Scsi_Device *, char*, kdev_t*);
 
 struct Scsi_Device_Template osst_template =
 {
@@ -166,7 +167,8 @@
        detect:		osst_detect,
        init:		osst_init,
        attach:		osst_attach,
-       detach:		osst_detach
+       detach:		osst_detach,
+       find_kdev:	osst_find_kdev,
 };
 
 static int osst_int_ioctl(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt, unsigned int cmd_in,unsigned long arg);
@@ -5417,6 +5419,24 @@
 	return 0;
 }
 
+static int osst_find_kdev(Scsi_Device *sdp, char* nm, kdev_t *dev)
+{
+	int i;
+	OS_Scsi_Tape *ostp;
+	
+	if (sdp && sdp->type == TYPE_TAPE && osst_supports(sdp)) {
+		for (ostp = os_scsi_tapes[i = 0]; i < osst_template.dev_max;
+		     ostp = os_scsi_tapes[++i]) {
+			if (ostp && ostp->device == sdp) {
+				sprintf (nm, "osst%i", i);
+				*dev = MKDEV(OSST_MAJOR, i);
+				return 0;
+			}
+		}
+	}
+	return 1;
+}
+
 static int osst_attach(Scsi_Device * SDp)
 {
 	OS_Scsi_Tape * tpnt;
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/scsi_proc.c linux-2.4.18.S18.scsirephl/drivers/scsi/scsi_proc.c
--- linux-2.4.18.S18.fixed/drivers/scsi/scsi_proc.c	Thu Jun 28 02:10:55 2001
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/scsi_proc.c	Thu Jun 20 18:08:40 2002
@@ -261,6 +261,10 @@
 
 	int x, y = *size;
 	extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
+	char nm[16];
+	kdev_t kdev;
+	int att = scd->attached;
+	struct Scsi_Device_Template *sd_t = scsi_devicelist;
 
 	y = sprintf(buffer + len,
 	     "Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n  Vendor: ",
@@ -296,7 +300,24 @@
 		y += sprintf(buffer + len + y, " CCS\n");
 	else
 		y += sprintf(buffer + len + y, "\n");
+	
+	/* Report high level devices attached */
+	y += sprintf (buffer + len + y, "  Attached drivers:");
 
+	while (att && sd_t) {
+		if (sd_t->find_kdev) {
+			if (!(sd_t->find_kdev(scd, nm, &kdev))) {
+				y += sprintf(buffer + len + y,
+					     " %s(%c:%02x:%02x)",
+					     nm, (sd_t->blk? 'b': 'c'),
+					     MAJOR(kdev), MINOR(kdev));
+				--att;
+			}
+		}
+		sd_t = sd_t->next;
+	}
+
+	y += sprintf(buffer + len + y, "\n");
 	*size = y;
 	return;
 }
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/sd.c linux-2.4.18.S18.scsirephl/drivers/scsi/sd.c
--- linux-2.4.18.S18.fixed/drivers/scsi/sd.c	Wed Jun 12 11:37:13 2002
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/sd.c	Wed Jun 12 11:39:47 2002
@@ -109,6 +109,7 @@
 static int sd_detect(Scsi_Device *);
 static void sd_detach(Scsi_Device *);
 static int sd_init_command(Scsi_Cmnd *);
+static int sd_find_kdev(Scsi_Device*, char*, kdev_t*);
 
 static struct Scsi_Device_Template sd_template = {
 	name:"disk",
@@ -127,6 +128,7 @@
 	attach:sd_attach,
 	detach:sd_detach,
 	init_command:sd_init_command,
+	find_kdev:sd_find_kdev,
 };
 
 
@@ -281,6 +283,23 @@
 	}
 }
 
+static int sd_find_kdev(Scsi_Device *sdp, char* nm, kdev_t *dev)
+{
+	Scsi_Disk *dp; 
+	int i;
+	
+	if (sdp && (sdp->type == TYPE_DISK || sdp->type == TYPE_MOD)) {
+		for (dp = rscsi_disks, i = 0; i < sd_template.dev_max; ++i, ++dp) {
+			if (dp->device == sdp) {
+				sd_devname(i, nm);
+				*dev = MKDEV_SD(i);
+				return 0;
+			}
+		}
+	}
+	return 1;
+}
+
 static request_queue_t *sd_find_queue(kdev_t dev)
 {
 	Scsi_Disk *dpnt;
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/sg.c linux-2.4.18.S18.scsirephl/drivers/scsi/sg.c
--- linux-2.4.18.S18.fixed/drivers/scsi/sg.c	Wed Jun 12 11:37:04 2002
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/sg.c	Wed Jun 12 15:27:55 2002
@@ -115,6 +115,7 @@
 static void sg_finish(void);
 static int sg_detect(Scsi_Device *);
 static void sg_detach(Scsi_Device *);
+static int sg_find_kdev(Scsi_Device *, char*, kdev_t*);
 
 static Scsi_Request * dummy_cmdp;	/* only used for sizeof */
 
@@ -123,6 +124,7 @@
 
 static struct Scsi_Device_Template sg_template =
 {
+      name:"generic",
       tag:"sg",
       scsi_type:0xff,
       major:SCSI_GENERIC_MAJOR,
@@ -130,7 +132,8 @@
       init:sg_init,
       finish:sg_finish,
       attach:sg_attach,
-      detach:sg_detach
+      detach:sg_detach,
+      find_kdev:sg_find_kdev
 };
 
 
@@ -2696,6 +2699,36 @@
 }
 
 #ifdef CONFIG_PROC_FS
+static int sg_find_kdev(Scsi_Device* sdp, char *nm, kdev_t *dev)
+{
+    unsigned long iflags;
+    int err = 1; 
+
+    if (sdp && sg_dev_arr) {
+	int k;
+	read_lock_irqsave(&sg_dev_arr_lock, iflags);
+	for (k = 0; k < sg_template.dev_max; ++k) {
+	    if (sg_dev_arr[k] && sg_dev_arr[k]->device == sdp) {
+		sprintf (nm, "sg%i", k);
+	        *dev = sg_dev_arr[k]->i_rdev;
+		err = 0;
+		break;
+	    }
+	}
+	read_unlock_irqrestore(&sg_dev_arr_lock, iflags);
+    }
+    return err;
+}
+#else
+/* Not needed without procfs support */
+static int sg_find_kdev(Scsi_Device* sdp, char *nm, kdev_t *dev)
+{
+    *nm = 0; *kdev = MKDEV(255,255);
+    return 1;
+}
+#endif
+
+#ifdef CONFIG_PROC_FS
 
 static struct proc_dir_entry * sg_proc_sgp = NULL;
 
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/sr.c linux-2.4.18.S18.scsirephl/drivers/scsi/sr.c
--- linux-2.4.18.S18.fixed/drivers/scsi/sr.c	Wed Jun 12 11:37:15 2002
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/sr.c	Wed Jun 12 11:39:47 2002
@@ -69,6 +69,8 @@
 
 static int sr_init_command(Scsi_Cmnd *);
 
+static int sr_find_kdev(Scsi_Device*, char*, kdev_t*);
+
 static struct Scsi_Device_Template sr_template =
 {
 	name:"cdrom",
@@ -81,7 +83,8 @@
 	finish:sr_finish,
 	attach:sr_attach,
 	detach:sr_detach,
-	init_command:sr_init_command
+	init_command:sr_init_command,
+	find_kdev:sr_find_kdev,
 };
 
 Scsi_CD *scsi_CDs;
@@ -586,6 +589,22 @@
 	return 0;
 }
 
+static int sr_find_kdev(Scsi_Device *sdp, char* nm, kdev_t *dev)
+{
+	Scsi_CD *srp;
+	int i;
+	
+	if (sdp && (sdp->type == TYPE_ROM || sdp->type == TYPE_WORM)) {
+		for (srp = scsi_CDs, i = 0; i < sr_template.dev_max; ++i, ++srp) {
+			if (srp->device == sdp) {
+				sprintf(nm, "sr%i", i);
+				*dev = MKDEV(SCSI_CDROM_MAJOR,i);
+				return 0;
+			}
+		}
+	}
+	return 1;
+}
 
 void get_sectorsize(int i)
 {
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/st.c linux-2.4.18.S18.scsirephl/drivers/scsi/st.c
--- linux-2.4.18.S18.fixed/drivers/scsi/st.c	Mon Feb 25 20:38:04 2002
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/st.c	Wed Jun 12 11:39:47 2002
@@ -164,6 +164,7 @@
 static int st_attach(Scsi_Device *);
 static int st_detect(Scsi_Device *);
 static void st_detach(Scsi_Device *);
+static int st_find_kdev(Scsi_Device*, char*, kdev_t*);
 
 static struct Scsi_Device_Template st_template =
 {
@@ -174,7 +175,8 @@
 	detect:st_detect, 
 	init:st_init,
 	attach:st_attach, 
-	detach:st_detach
+	detach:st_detach,
+	find_kdev:st_find_kdev,
 };
 
 static int st_compression(Scsi_Tape *, int);
@@ -3827,6 +3829,23 @@
 	return 1;
 }
 
+static int st_find_kdev(Scsi_Device * sdp, char* nm, kdev_t *dev)
+{
+	int i;
+	Scsi_Tape *stp;
+	
+	if (sdp && sdp->type == TYPE_TAPE && !st_incompatible(sdp)) {
+		for (stp = scsi_tapes[0], i = 0; i < st_template.dev_max; stp=scsi_tapes[++i]) {
+			if (stp && stp->device == sdp) {
+				sprintf(nm, "st%i", i);
+				*dev = MKDEV (SCSI_TAPE_MAJOR, i);
+				return 0;
+			}
+		}
+	}
+	return 1;
+}
+
 static int st_registered = 0;
 
 /* Driver initialization (not __init because may be called later) */

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] sd_many done right (1/5)
  2002-07-27  9:41           ` Christoph Hellwig
@ 2002-07-28  0:42             ` Kurt Garloff
  0 siblings, 0 replies; 12+ messages in thread
From: Kurt Garloff @ 2002-07-28  0:42 UTC (permalink / raw)
  To: Christoph Hellwig, Alexander Viro, Linux SCSI list, Linux kernel list

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

Hi Christoph, Al,

On Sat, Jul 27, 2002 at 10:41:19AM +0100, Christoph Hellwig wrote:
> On Sat, Jul 27, 2002 at 12:32:24AM +0200, Kurt Garloff wrote:
> Linus wants this, and he stated that again on the kernel summit.  

I've not been there :-(

> But to do this porperly (= not the EVMS way) it needs preparation.  
> Al currently does lots of work in that area to make the block drivers
> largely independent of the major number.

So he should port my sd patch to 2.5. All the data it uses is in a per-major
data structure. Currently, in most function it uses the kdev_t passed to find
the right pointer. But that's very easy to replace.
Of course, sd still assumes it gets a whole major and not parts of one. Other-
wise, more splitting would be needed.

> Once the drivers don't need the major number anymore
> internally the only that needs sorting out is userlevel backwards-compatinlity.

That takes more effort than the change itself, I guess.

> I'm pretty sure the preparation will be finished for 2.6, also I can't comment
> whether the unified disk major will be done. (Al?)

Would certainly be nice.

Regards,
-- 
Kurt Garloff  <garloff@suse.de>                          Eindhoven, NL
GPG key: See mail header, key servers         Linux kernel development
SuSE Linux AG, Nuernberg, DE                            SCSI, Security

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] sd_many done right (1/5)
  2002-07-26 22:32         ` Kurt Garloff
@ 2002-07-27  9:41           ` Christoph Hellwig
  2002-07-28  0:42             ` Kurt Garloff
  0 siblings, 1 reply; 12+ messages in thread
From: Christoph Hellwig @ 2002-07-27  9:41 UTC (permalink / raw)
  To: Kurt Garloff, Alexander Viro, Linux SCSI list, Linux kernel list

On Sat, Jul 27, 2002 at 12:32:24AM +0200, Kurt Garloff wrote:
> But the idea of having a number of majors assigned to disks, no matter what
> the driver below is looks certainly like a good idea. With the current
> approach, we'll need way too many majors, even if we'd have some more bits
> in the future. Why not have a pool of disk majors and sd, hd, dasd, rd
> (DAC960), the IDE-Raids, and ... allocate some of these as needed.

Linus wants this, and he stated that again on the kernel summit.  But to do
this porperly (= not the EVMS way) it needs preparation.  Al currently does
lots of work in that area to make the block drivers largely independent of
the major number.  Once the drivers don't need the major number anymore
internally the only that needs sorting out is userlevel backwards-compatinlity.

I'm pretty sure the preparation will be finished for 2.6, also I can't comment
whether the unified disk major will be done. (Al?)


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

* Re: [PATCH] sd_many done right (1/5)
  2002-07-26 16:54   ` Kurt Garloff
  2002-07-26 17:50     ` Andreas Dilger
@ 2002-07-26 23:28     ` Greg KH
  1 sibling, 0 replies; 12+ messages in thread
From: Greg KH @ 2002-07-26 23:28 UTC (permalink / raw)
  To: Kurt Garloff, Linux SCSI list, Linux kernel list

On Fri, Jul 26, 2002 at 06:54:11PM +0200, Kurt Garloff wrote:
> Hi Al,
> 
> On Fri, Jul 26, 2002 at 12:45:41PM -0400, Alexander Viro wrote:
> > On Fri, 26 Jul 2002, Kurt Garloff wrote:
> > > The patches are all available at
> > > http://www.suse.de/~garloff/linux/scsi-many/
> > 
> > As long as you realize that it won't go in 2.5 in that form...
> 
> The sd parts can and should be ported to 2.5, I think.
> The /proc/scsi/scsi extensions and other stuff I wrote to support it, 
> won't be needed, as we have driverfs in 2.5.
> And, of course, the device number management will be solved in a more
> general way, but I do not yet see how. 

Why that's quite simple (with apologies to South Park) :
	1) finish the driver model code and banish devfs to a corner of
	the kernel where it will not do any harm.
	2) {silence}
	3) Purely dynamic major and minors now work.

:)

It will happen, eventually.  Most of us are busy laying the groundwork
right now...

thanks,

greg k-h

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

* Re: [PATCH] sd_many done right (1/5)
  2002-07-26 17:55       ` Christoph Hellwig
@ 2002-07-26 22:32         ` Kurt Garloff
  2002-07-27  9:41           ` Christoph Hellwig
  2002-07-26 22:32         ` Kurt Garloff
  1 sibling, 1 reply; 12+ messages in thread
From: Kurt Garloff @ 2002-07-26 22:32 UTC (permalink / raw)
  To: Christoph Hellwig, Alexander Viro, Linux SCSI list,
	Linux kernel list, Marcelo Tosatti

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

Hi Christoph, Andreas,

On Fri, Jul 26, 2002 at 06:55:45PM +0100, Christoph Hellwig wrote:
> On Fri, Jul 26, 2002 at 11:50:27AM -0600, Andreas Dilger wrote:
> > Actually, one interesting aspect of the EVMS vs. device-mapper argument
> > going on that has totally been missed is that EVMS can do management of
> > ALL disk block devices.
> 
> That's only natural as it try to duplicate the whole Linux block layer.
> But it's everything but a good idea.

I won't go into that discussion ... Duplicating the Linux block layer is
certainly not such a good idea as the block layer is getting really nice
nowadays. But I have no idea to what extent something like this is done in
EVMS.

But the idea of having a number of majors assigned to disks, no matter what
the driver below is looks certainly like a good idea. With the current
approach, we'll need way too many majors, even if we'd have some more bits
in the future. Why not have a pool of disk majors and sd, hd, dasd, rd
(DAC960), the IDE-Raids, and ... allocate some of these as needed.

driverfs + some userspace tool will be needed to provide a consistent view
on them and to handle the permissions. Fortunately, disk devs tend to all
have the same perms, so we can start before this is addressed to its
full extent.

Regards,
-- 
Kurt Garloff  <garloff@suse.de>                          Eindhoven, NL
GPG key: See mail header, key servers         Linux kernel development
SuSE Linux AG, Nuernberg, DE                            SCSI, Security

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] sd_many done right (1/5)
  2002-07-26 17:55       ` Christoph Hellwig
  2002-07-26 22:32         ` Kurt Garloff
@ 2002-07-26 22:32         ` Kurt Garloff
  1 sibling, 0 replies; 12+ messages in thread
From: Kurt Garloff @ 2002-07-26 22:32 UTC (permalink / raw)
  To: Christoph Hellwig, Alexander Viro, Linux SCSI list,
	Linux kernel list, Marcelo Tosatti

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

Hi Christoph, Andreas,

On Fri, Jul 26, 2002 at 06:55:45PM +0100, Christoph Hellwig wrote:
> On Fri, Jul 26, 2002 at 11:50:27AM -0600, Andreas Dilger wrote:
> > Actually, one interesting aspect of the EVMS vs. device-mapper argument
> > going on that has totally been missed is that EVMS can do management of
> > ALL disk block devices.
> 
> That's only natural as it try to duplicate the whole Linux block layer.
> But it's everything but a good idea.

I won't go into that discussion ... Duplicating the Linux block layer is
certainly not such a good idea as the block layer is getting really nice
nowadays. But I have no idea to what extent something like this is done in
EVMS.

But the idea of having a number of majors assigned to disks, no matter what
the driver below is looks certainly like a good idea. With the current
approach, we'll need way too many majors, even if we'd have some more bits
in the future. Why not have a pool of disk majors and sd, hd, dasd, rd
(DAC960), the IDE-Raids, and ... allocate some of these as needed.

driverfs + some userspace tool will be needed to provide a consistent view
on them and to handle the permissions. Fortunately, disk devs tend to all
have the same perms, so we can start before this is addressed to its
full extent.

Regards,
-- 
Kurt Garloff  <garloff@suse.de>                          Eindhoven, NL
GPG key: See mail header, key servers         Linux kernel development
SuSE Linux AG, Nuernberg, DE                            SCSI, Security

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] sd_many done right (1/5)
  2002-07-26 17:50     ` Andreas Dilger
  2002-07-26 17:55       ` Christoph Hellwig
@ 2002-07-26 17:55       ` Christoph Hellwig
  2002-07-26 22:32         ` Kurt Garloff
  2002-07-26 22:32         ` Kurt Garloff
  1 sibling, 2 replies; 12+ messages in thread
From: Christoph Hellwig @ 2002-07-26 17:55 UTC (permalink / raw)
  To: Kurt Garloff, Alexander Viro, Linux SCSI list, Linux kernel list,
	Marcelo Tosatti

On Fri, Jul 26, 2002 at 11:50:27AM -0600, Andreas Dilger wrote:
> Actually, one interesting aspect of the EVMS vs. device-mapper argument
> going on that has totally been missed is that EVMS can do management of
> ALL disk block devices.

That's only natural as it try to duplicate the whole Linux block layer.
But it's everything but a good idea.


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

* Re: [PATCH] sd_many done right (1/5)
  2002-07-26 17:50     ` Andreas Dilger
@ 2002-07-26 17:55       ` Christoph Hellwig
  2002-07-26 17:55       ` Christoph Hellwig
  1 sibling, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2002-07-26 17:55 UTC (permalink / raw)
  To: Kurt Garloff, Alexander Viro, Linux SCSI list, Linux kernel list,
	Marcelo Tosatti

On Fri, Jul 26, 2002 at 11:50:27AM -0600, Andreas Dilger wrote:
> Actually, one interesting aspect of the EVMS vs. device-mapper argument
> going on that has totally been missed is that EVMS can do management of
> ALL disk block devices.

That's only natural as it try to duplicate the whole Linux block layer.
But it's everything but a good idea.


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

* Re: [PATCH] sd_many done right (1/5)
  2002-07-26 16:54   ` Kurt Garloff
@ 2002-07-26 17:50     ` Andreas Dilger
  2002-07-26 17:55       ` Christoph Hellwig
  2002-07-26 17:55       ` Christoph Hellwig
  2002-07-26 23:28     ` Greg KH
  1 sibling, 2 replies; 12+ messages in thread
From: Andreas Dilger @ 2002-07-26 17:50 UTC (permalink / raw)
  To: Kurt Garloff, Alexander Viro, Linux SCSI list, Linux kernel list,
	Marcelo Tosatti

On Jul 26, 2002  18:54 +0200, Kurt Garloff wrote:
> On Fri, Jul 26, 2002 at 12:45:41PM -0400, Alexander Viro wrote:
> > On Fri, 26 Jul 2002, Kurt Garloff wrote:
> > > The patches are all available at
> > > http://www.suse.de/~garloff/linux/scsi-many/
> > 
> > As long as you realize that it won't go in 2.5 in that form...
> 
> The sd parts can and should be ported to 2.5, I think.
> The /proc/scsi/scsi extensions and other stuff I wrote to support it, 
> won't be needed, as we have driverfs in 2.5.
> And, of course, the device number management will be solved in a more
> general way, but I do not yet see how. 

Actually, one interesting aspect of the EVMS vs. device-mapper argument
going on that has totally been missed is that EVMS can do management of
ALL disk block devices.

At startup time it "consumes" all of the disk block devices in order to
generate the various mappings (LVM, RAID, etc) and at the end it spits
out the resulting devices as EVMS major devices.  This includes devices
that have not been remapped, like hdXY or sdMN.  EVMS has facilities
to ensure that devices get repeatable major/minor numbers if needed,
but they are allocated on an as-needed basis.

Currently EVMS only has a single major number, but it is my understanding
that they could easily take over all of the IDE and SCSI major numbers.
We would not have to worry about sparse device number allocation anymore,
and could have thousands of disks/partitions without any problems.

Cheers, Andreas
--
Andreas Dilger
http://www-mddsp.enel.ucalgary.ca/People/adilger/
http://sourceforge.net/projects/ext2resize/


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

* Re: [PATCH] sd_many done right (1/5)
  2002-07-26 16:45 ` Alexander Viro
@ 2002-07-26 16:54   ` Kurt Garloff
  2002-07-26 17:50     ` Andreas Dilger
  2002-07-26 23:28     ` Greg KH
  0 siblings, 2 replies; 12+ messages in thread
From: Kurt Garloff @ 2002-07-26 16:54 UTC (permalink / raw)
  To: Alexander Viro; +Cc: Linux SCSI list, Linux kernel list, Marcelo Tosatti

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

Hi Al,

On Fri, Jul 26, 2002 at 12:45:41PM -0400, Alexander Viro wrote:
> On Fri, 26 Jul 2002, Kurt Garloff wrote:
> > The patches are all available at
> > http://www.suse.de/~garloff/linux/scsi-many/
> 
> As long as you realize that it won't go in 2.5 in that form...

The sd parts can and should be ported to 2.5, I think.
The /proc/scsi/scsi extensions and other stuff I wrote to support it, 
won't be needed, as we have driverfs in 2.5.
And, of course, the device number management will be solved in a more
general way, but I do not yet see how. 

Regards,
-- 
Kurt Garloff  <garloff@suse.de>                          Eindhoven, NL
GPG key: See mail header, key servers         Linux kernel development
SuSE Linux AG, Nuernberg, DE                            SCSI, Security

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] sd_many done right (1/5)
  2002-07-26 15:45 Kurt Garloff
@ 2002-07-26 16:45 ` Alexander Viro
  2002-07-26 16:54   ` Kurt Garloff
  0 siblings, 1 reply; 12+ messages in thread
From: Alexander Viro @ 2002-07-26 16:45 UTC (permalink / raw)
  To: Kurt Garloff; +Cc: Linux SCSI list, Linux kernel list, Marcelo Tosatti



On Fri, 26 Jul 2002, Kurt Garloff wrote:

> Hi,
> 
> here comes patch 1/5 from a series of patches to support more than 128 (and
> optionally more than 256) SCSI disks with Linux 2.4 by changing the sd driver
> to dynamically allocate memory and register block majors as disks get
> attached.
> 
> The patches are all available at
> http://www.suse.de/~garloff/linux/scsi-many/

As long as you realize that it won't go in 2.5 in that form...


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

* [PATCH] sd_many done right (1/5)
@ 2002-07-26 15:45 Kurt Garloff
  2002-07-26 16:45 ` Alexander Viro
  0 siblings, 1 reply; 12+ messages in thread
From: Kurt Garloff @ 2002-07-26 15:45 UTC (permalink / raw)
  To: Linux SCSI list; +Cc: Linux kernel list, Marcelo Tosatti


[-- Attachment #1.1: Type: text/plain, Size: 1279 bytes --]

Hi,

here comes patch 1/5 from a series of patches to support more than 128 (and
optionally more than 256) SCSI disks with Linux 2.4 by changing the sd driver
to dynamically allocate memory and register block majors as disks get
attached.

The patches are all available at
http://www.suse.de/~garloff/linux/scsi-many/

This patch (1/5) does implement some infrastructure that is useful: We
extend the format of /proc/scsi/scsi to report the attached high-level
drivers. 
This can be used by userspace applications to dynamically create device
nodes or to talk to the corresponding sg device (which otherwise is non-
trivial to find out!) and inquire extra information such as serial number
or WWID.

Here's a sample.
Host: scsi5 Channel: 00 Id: 04 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0003
  Type:   Direct-Access                    ANSI SCSI revision: 03
  Attached drivers: sdr(b:41:10) sg18(c:15:12)
      
Patch is against 2.4.19rc1.
Marcelo, these patches are meant for inclusion into 2.4.20pre.

Regards,
-- 
Kurt Garloff  <garloff@suse.de>                          Eindhoven, NL
GPG key: See mail header, key servers         Linux kernel development
SuSE Linux AG, Nuernberg, DE                            SCSI, Security

[-- Attachment #1.2: scsi-rep-hldevs-2419rc1.diff --]
[-- Type: text/plain, Size: 8450 bytes --]

diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/hosts.h linux-2.4.18.S18.scsirephl/drivers/scsi/hosts.h
--- linux-2.4.18.S18.fixed/drivers/scsi/hosts.h	Wed Jun 12 11:37:09 2002
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/hosts.h	Wed Jun 12 11:53:54 2002
@@ -530,6 +530,7 @@
     void (*detach)(Scsi_Device *);
     int (*init_command)(Scsi_Cmnd *);     /* Used by new queueing code. 
                                            Selects command for blkdevs */
+    int (*find_kdev)(Scsi_Device *, char*, kdev_t*);  /* find back dev. */
 };
 
 void  scsi_initialize_queue(Scsi_Device * SDpnt, struct Scsi_Host * SHpnt);
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/osst.c linux-2.4.18.S18.scsirephl/drivers/scsi/osst.c
--- linux-2.4.18.S18.fixed/drivers/scsi/osst.c	Fri Dec 21 18:41:55 2001
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/osst.c	Wed Jun 12 11:39:47 2002
@@ -156,6 +156,7 @@
 static int osst_attach(Scsi_Device *);
 static int osst_detect(Scsi_Device *);
 static void osst_detach(Scsi_Device *);
+static int osst_find_kdev(Scsi_Device *, char*, kdev_t*);
 
 struct Scsi_Device_Template osst_template =
 {
@@ -166,7 +167,8 @@
        detect:		osst_detect,
        init:		osst_init,
        attach:		osst_attach,
-       detach:		osst_detach
+       detach:		osst_detach,
+       find_kdev:	osst_find_kdev,
 };
 
 static int osst_int_ioctl(OS_Scsi_Tape *STp, Scsi_Request ** aSRpnt, unsigned int cmd_in,unsigned long arg);
@@ -5417,6 +5419,24 @@
 	return 0;
 }
 
+static int osst_find_kdev(Scsi_Device *sdp, char* nm, kdev_t *dev)
+{
+	int i;
+	OS_Scsi_Tape *ostp;
+	
+	if (sdp && sdp->type == TYPE_TAPE && osst_supports(sdp)) {
+		for (ostp = os_scsi_tapes[i = 0]; i < osst_template.dev_max;
+		     ostp = os_scsi_tapes[++i]) {
+			if (ostp && ostp->device == sdp) {
+				sprintf (nm, "osst%i", i);
+				*dev = MKDEV(OSST_MAJOR, i);
+				return 0;
+			}
+		}
+	}
+	return 1;
+}
+
 static int osst_attach(Scsi_Device * SDp)
 {
 	OS_Scsi_Tape * tpnt;
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/scsi_proc.c linux-2.4.18.S18.scsirephl/drivers/scsi/scsi_proc.c
--- linux-2.4.18.S18.fixed/drivers/scsi/scsi_proc.c	Thu Jun 28 02:10:55 2001
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/scsi_proc.c	Thu Jun 20 18:08:40 2002
@@ -261,6 +261,10 @@
 
 	int x, y = *size;
 	extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
+	char nm[16];
+	kdev_t kdev;
+	int att = scd->attached;
+	struct Scsi_Device_Template *sd_t = scsi_devicelist;
 
 	y = sprintf(buffer + len,
 	     "Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n  Vendor: ",
@@ -296,7 +300,24 @@
 		y += sprintf(buffer + len + y, " CCS\n");
 	else
 		y += sprintf(buffer + len + y, "\n");
+	
+	/* Report high level devices attached */
+	y += sprintf (buffer + len + y, "  Attached drivers:");
 
+	while (att && sd_t) {
+		if (sd_t->find_kdev) {
+			if (!(sd_t->find_kdev(scd, nm, &kdev))) {
+				y += sprintf(buffer + len + y,
+					     " %s(%c:%02x:%02x)",
+					     nm, (sd_t->blk? 'b': 'c'),
+					     MAJOR(kdev), MINOR(kdev));
+				--att;
+			}
+		}
+		sd_t = sd_t->next;
+	}
+
+	y += sprintf(buffer + len + y, "\n");
 	*size = y;
 	return;
 }
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/sd.c linux-2.4.18.S18.scsirephl/drivers/scsi/sd.c
--- linux-2.4.18.S18.fixed/drivers/scsi/sd.c	Wed Jun 12 11:37:13 2002
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/sd.c	Wed Jun 12 11:39:47 2002
@@ -109,6 +109,7 @@
 static int sd_detect(Scsi_Device *);
 static void sd_detach(Scsi_Device *);
 static int sd_init_command(Scsi_Cmnd *);
+static int sd_find_kdev(Scsi_Device*, char*, kdev_t*);
 
 static struct Scsi_Device_Template sd_template = {
 	name:"disk",
@@ -127,6 +128,7 @@
 	attach:sd_attach,
 	detach:sd_detach,
 	init_command:sd_init_command,
+	find_kdev:sd_find_kdev,
 };
 
 
@@ -281,6 +283,23 @@
 	}
 }
 
+static int sd_find_kdev(Scsi_Device *sdp, char* nm, kdev_t *dev)
+{
+	Scsi_Disk *dp; 
+	int i;
+	
+	if (sdp && (sdp->type == TYPE_DISK || sdp->type == TYPE_MOD)) {
+		for (dp = rscsi_disks, i = 0; i < sd_template.dev_max; ++i, ++dp) {
+			if (dp->device == sdp) {
+				sd_devname(i, nm);
+				*dev = MKDEV_SD(i);
+				return 0;
+			}
+		}
+	}
+	return 1;
+}
+
 static request_queue_t *sd_find_queue(kdev_t dev)
 {
 	Scsi_Disk *dpnt;
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/sg.c linux-2.4.18.S18.scsirephl/drivers/scsi/sg.c
--- linux-2.4.18.S18.fixed/drivers/scsi/sg.c	Wed Jun 12 11:37:04 2002
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/sg.c	Wed Jun 12 15:27:55 2002
@@ -115,6 +115,7 @@
 static void sg_finish(void);
 static int sg_detect(Scsi_Device *);
 static void sg_detach(Scsi_Device *);
+static int sg_find_kdev(Scsi_Device *, char*, kdev_t*);
 
 static Scsi_Request * dummy_cmdp;	/* only used for sizeof */
 
@@ -123,6 +124,7 @@
 
 static struct Scsi_Device_Template sg_template =
 {
+      name:"generic",
       tag:"sg",
       scsi_type:0xff,
       major:SCSI_GENERIC_MAJOR,
@@ -130,7 +132,8 @@
       init:sg_init,
       finish:sg_finish,
       attach:sg_attach,
-      detach:sg_detach
+      detach:sg_detach,
+      find_kdev:sg_find_kdev
 };
 
 
@@ -2696,6 +2699,36 @@
 }
 
 #ifdef CONFIG_PROC_FS
+static int sg_find_kdev(Scsi_Device* sdp, char *nm, kdev_t *dev)
+{
+    unsigned long iflags;
+    int err = 1; 
+
+    if (sdp && sg_dev_arr) {
+	int k;
+	read_lock_irqsave(&sg_dev_arr_lock, iflags);
+	for (k = 0; k < sg_template.dev_max; ++k) {
+	    if (sg_dev_arr[k] && sg_dev_arr[k]->device == sdp) {
+		sprintf (nm, "sg%i", k);
+	        *dev = sg_dev_arr[k]->i_rdev;
+		err = 0;
+		break;
+	    }
+	}
+	read_unlock_irqrestore(&sg_dev_arr_lock, iflags);
+    }
+    return err;
+}
+#else
+/* Not needed without procfs support */
+static int sg_find_kdev(Scsi_Device* sdp, char *nm, kdev_t *dev)
+{
+    *nm = 0; *kdev = MKDEV(255,255);
+    return 1;
+}
+#endif
+
+#ifdef CONFIG_PROC_FS
 
 static struct proc_dir_entry * sg_proc_sgp = NULL;
 
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/sr.c linux-2.4.18.S18.scsirephl/drivers/scsi/sr.c
--- linux-2.4.18.S18.fixed/drivers/scsi/sr.c	Wed Jun 12 11:37:15 2002
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/sr.c	Wed Jun 12 11:39:47 2002
@@ -69,6 +69,8 @@
 
 static int sr_init_command(Scsi_Cmnd *);
 
+static int sr_find_kdev(Scsi_Device*, char*, kdev_t*);
+
 static struct Scsi_Device_Template sr_template =
 {
 	name:"cdrom",
@@ -81,7 +83,8 @@
 	finish:sr_finish,
 	attach:sr_attach,
 	detach:sr_detach,
-	init_command:sr_init_command
+	init_command:sr_init_command,
+	find_kdev:sr_find_kdev,
 };
 
 Scsi_CD *scsi_CDs;
@@ -586,6 +589,22 @@
 	return 0;
 }
 
+static int sr_find_kdev(Scsi_Device *sdp, char* nm, kdev_t *dev)
+{
+	Scsi_CD *srp;
+	int i;
+	
+	if (sdp && (sdp->type == TYPE_ROM || sdp->type == TYPE_WORM)) {
+		for (srp = scsi_CDs, i = 0; i < sr_template.dev_max; ++i, ++srp) {
+			if (srp->device == sdp) {
+				sprintf(nm, "sr%i", i);
+				*dev = MKDEV(SCSI_CDROM_MAJOR,i);
+				return 0;
+			}
+		}
+	}
+	return 1;
+}
 
 void get_sectorsize(int i)
 {
diff -uNr linux-2.4.18.S18.fixed/drivers/scsi/st.c linux-2.4.18.S18.scsirephl/drivers/scsi/st.c
--- linux-2.4.18.S18.fixed/drivers/scsi/st.c	Mon Feb 25 20:38:04 2002
+++ linux-2.4.18.S18.scsirephl/drivers/scsi/st.c	Wed Jun 12 11:39:47 2002
@@ -164,6 +164,7 @@
 static int st_attach(Scsi_Device *);
 static int st_detect(Scsi_Device *);
 static void st_detach(Scsi_Device *);
+static int st_find_kdev(Scsi_Device*, char*, kdev_t*);
 
 static struct Scsi_Device_Template st_template =
 {
@@ -174,7 +175,8 @@
 	detect:st_detect, 
 	init:st_init,
 	attach:st_attach, 
-	detach:st_detach
+	detach:st_detach,
+	find_kdev:st_find_kdev,
 };
 
 static int st_compression(Scsi_Tape *, int);
@@ -3827,6 +3829,23 @@
 	return 1;
 }
 
+static int st_find_kdev(Scsi_Device * sdp, char* nm, kdev_t *dev)
+{
+	int i;
+	Scsi_Tape *stp;
+	
+	if (sdp && sdp->type == TYPE_TAPE && !st_incompatible(sdp)) {
+		for (stp = scsi_tapes[0], i = 0; i < st_template.dev_max; stp=scsi_tapes[++i]) {
+			if (stp && stp->device == sdp) {
+				sprintf(nm, "st%i", i);
+				*dev = MKDEV (SCSI_TAPE_MAJOR, i);
+				return 0;
+			}
+		}
+	}
+	return 1;
+}
+
 static int st_registered = 0;
 
 /* Driver initialization (not __init because may be called later) */

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2002-07-28  0:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-26 15:45 [PATCH] sd_many done right (1/5) Kurt Garloff
  -- strict thread matches above, loose matches on Subject: below --
2002-07-26 15:45 Kurt Garloff
2002-07-26 16:45 ` Alexander Viro
2002-07-26 16:54   ` Kurt Garloff
2002-07-26 17:50     ` Andreas Dilger
2002-07-26 17:55       ` Christoph Hellwig
2002-07-26 17:55       ` Christoph Hellwig
2002-07-26 22:32         ` Kurt Garloff
2002-07-27  9:41           ` Christoph Hellwig
2002-07-28  0:42             ` Kurt Garloff
2002-07-26 22:32         ` Kurt Garloff
2002-07-26 23:28     ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.